20171129 myDAQ LM35

Today I would like to find out how to use DAQ acquisition hardware to start acquiring analog input measurements with LabVIEW NXG.
I get using Hardware panel in LabVIEW NXG to connect and configure myDAQ hardware to instantly view data. Also here I coud start to automate data acquisition using either a built-in example as a starting point to developing a LabVIEW NXG program or reuse hardware configuration when I start writing my own program from the beginning.
I choose to read a temparature signal that comes from a LM35 trasducer, so I've 10mV/°C in the range 2÷150°C with 0.5°C of misure accuracy (at 25°C). The transducer operates from 4÷30V, so I connect to +15V from myDAQ. I use LabVIEW NXG to instantly connect my measurement hardware to begin acquiring data quickly. In the first figure I show how configure myDAQ devices and LM35 to tailor measurements to meet my project needs. In myDAQ I've 2 analog input and I choose AI1 channel.
20171129 NXG myDAQAfter I connect myDAQ device to my computer, the device is immediately discovered in the Hardware tab of LabVIEW NXG. In the Hardware tab, I can validate hardware connections with access to the pinout, manual, and specifications and perform basic troubleshooting steps.
From the Hardware tab, I use a Measurement Panel to begin visualizing data. In the Measurement Panel, I could directly record measurement data to be analyzed offline, but now I'm not interested in this scope.
Now I create a New > Project and I click with left mouse button in white area of Navigation pane (on the left) and on the cascade menu I choose Add new > Analog Input, so I configure my hardware channel AI1 for the signal from LM35 sensor.
After, I create a new VI, clicking with left mouse button in white area of Navigation pane and choosing Add new > VI on the cascade menu, I reuse my Analog Input that I created, to start writing my program from the beginning. I drag Analog Input into the VI Diagram and incorporate it into a While Loop. The output from DAQmx Read VI is 1D array of Waveform signal. With Index Array VI I just pick one element of Waveform from the Waveforms array (the last acquired from myDAQ, that is in 0 position). After I use Waveform properties VI to index the 1D Waveform array and get the individual elements from a single Waveform cluster. The Waveform data type is a special type of cluster made up of 4 elements:

  • Y - This is a 1D Array of the amplitude measurements of your data.
  • t0 - This is a time stamp signifying the start time of your measurement.
  • dt - This is a scalar that describes the uniform time division of the signal in seconds.
  • attributes - This is a variant data type containing all of the waveform metadata, such as the hardware device number or the channel names.

20171129 instant and medium temperature LM35 Diagram

I get the actual voltage value of the Waveform from Y node and I multiply it by 100, so obtain the temperature value in Celsius degrees. I use the scalar dt to index a new array using Index Array VI and thus can represent the temperature on a Tank or on a Chart graph.
In addition to the instantaneous temperature, which is acquired by the myDAQ at the frequency of 1Hz (period set by the Numeric Constant = 1s), I want to print the trend of the average temperature, so I program a Shift Register, by clicking with the right mouse button on the edge of the While Loop and setting a Numeric Constant = 0 as the initial condition. The shift register serves me to realize the operation sum = previous sum + current value. Then I divide the partial sums by the number of current iterations i of the While Loop.
20171129 instant and medium temperature LM35 PanelTo publish on the same Chart the two graphs of instantaneous and average temperature I have to gather the two values ​​in a single cluster through Buid Cluster and then send them to the graph.
In the previous figure I am running the VI and in the Panel I see the result of the acquisition and processing that I have programmed.
If you want to use the VI already built, you can save the PNG image and load it with LabVIEW NXG or later and dragging it inside an empty Diagram window.
It is important to have a DAQ of any kind to connect to your PC and replace my Analog Input with a new one created by you. This is the snippet:

20171129 Snippet Thermometer with LM35


Advertising

Advertising

Advertising

We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.