LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading an analogue signal using MYRIO

Solved!
Go to solution

Hi, i am trying to read an analogue signal from an LM35 temperature sensor using the MYRIO. the sensor is connected to 5V, Analogue ground and AI0 on the B block of the MYRIO. i am attempting to read the signal from an FPGA  and set the sampling rate and number of samples. i am doing this from the picture below. In the real time VI i convert the data from the input into a voltage and then change to a temperature reading, but on the graph it is not displayed correctly it seems to be reading the desired temperature then constantly going to zero. any help in resolving this issue would be greatly appreciated

FPGA.PNG

Reading signal.PNGCapture.PNG

Download All
0 Kudos
Message 1 of 4
(2,810 Views)

I have changed the analogue input the AI1+ on the MSP C block and have connected AI1- to analogue ground, from the middle picture above i changed the 0.001221 to 0.004883 for the change in type of analogue input, the graph turns out the same

0 Kudos
Message 2 of 4
(2,793 Views)
Solution
Accepted by topic author Dewey89

I'm pretty sure that your problem is in the "Number of Elements" input on the RT system.

You see the 0 values when you read an empty array - in that case, the Index Array operation returns the "default default" value for DBL, or 0.

I'd guess your code does something like

  • Read some elements (unknown number)
  • Check remaining elements (=0, because you just read all of the elements into the array)
  • Pass 0 to SR
  • Read 0 elements - calculate 0 temperature
  • Check remaining elements (!=0, because some time passed during the loop iteration and you didn't read any here)
  • Pass ! 0 to SR
  • repeat

 

If you modify your code to ensure that "Number of Elements" is always > 0, then it should be fine.

However, since you're discarding lots of data (potentially), why not set a specific value (e.g. 1?) and then you'll know what your data rate is?

 

I didn't check the behaviour of the PID loop on the right hand side - maybe that's related to your decisions about loop rate etc.


GCentral
Message 3 of 4
(2,777 Views)

Thanks very much for your help, it was greatly appreciated. By changing the number of elements to a constant of 1 the signal on the graph is coming out as expected.

0 Kudos
Message 4 of 4
(2,767 Views)