Let's learn how to develop a simple timer in LabVIEW NXG. The image shows the labVIEW Panel with

  • three Numeric Controls to set hours, minutes and seconds,
  • a Power Button to start the contdown,
  • a Numeric Indicator to display the remaining seconds to count,
  • a Round LED that lights up at the end of the countdown. 

The VI is simple, so we can see in the Diagram below. It requires principally:

  • a While Loop that repeats the code on its subdiagram until a specific condition occurs: a While Loop always executes at least one time and behaves similarly to a do while loop in other programming languages (for example C),
  • an Elapsed Time VI that indicates the amount of time that has elapsed since the target time we specify.

20190115 Timer NXG1.0

I want to connect two LM35, one in basic mode to measure the temparature in my room at home and one in full-range mode to measure the temparature outside my window.
20171206 LM35 Basic and Full range 01

I connect the two transducers to myDAQ using the +15V positive supply for the first LM35 and the negative supply -15V for the second device. These supplies and the relative AGND ground are available at the myQAD terminals. I calculate the resistance R1 = 300kΩ which produces the voltage level translation as indicated in the LM35 datasheet (it would be better to use a trimmer to calibrate the resistance correctly, considering the resistive tolerances, or I can insert a Slide in LabVIEW to perform a measurement correction of temperature).
20171206 LM35 Basic and Full range 05

Then I open an Analog Input task in LabVIEW NXG for the transducer connected to AI0 and click on Create New Input to open another Analog Input task to acquire the measurements from the transducer in AI1. I can leave Analog Input as default, between -10V and + 10V, because the acquisition range in full-range mode is -0.5V and + 1.5V.
20171206 LM35 Basic and Full range 02

I create a New VI that acquires the temperature value from the two transducers. Initially I put them close and I adjust their measurements with a reference thermometer. After I put the full-range transducer out of my home window and I leave the other transducer inside the house.
I create a new VI by clicking with left mouse button in white area of Navigation panel and choosing Add new > VI on the cascade menu. So I use 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 two elements of Waveform from the Waveforms array (the last acquired from AI0 channel is in 0 position, and from AI1 is in position 1). 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.

I try some software solutions, as you can see in the front Panel of LabVIEW in the following figure:

  1. publish the two temperatures with Tanks and Charts;
  2. provide the user of the Slide to be able to properly calibrate the measurement, considering the resistive tolerances (the fourth band of the resistor is gold = 5%) and those of the LM35 (0.5°C ensured accuracy at 25°C);
  3. publish the difference between the two temperatures with an Indicator and a Chart.
  4. publish the average values ​​of each of the two measures with Indicators and Charts.20171206 LM35 Basic and Full range 03

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.
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.
I provide the user of the Slide to be able to properly calibrate the measurement of both transducer.
After I program two Shift Registers to print the trend of the average temperature, 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.
To publish on the same Chart the four graphs of instantaneous and average temperature for the two trasducers I have to gather the four values ​​in a single cluster through Buid Cluster and then send them to the graph.
The following figure shows the snippet of the block Diagram, that you can save in PNG format from this web page and open with LabVIEW. It is important to have a myDAQ or a DAQ of any kind to connect to your PC and replace the two Analog Input with new created by you.
20171206 LM35 Basic and Full range Snippet

In another example we are able to perform measurements at two points of the same environment (room, silos, tank, etc.) and evaluate:

  1. if one or both temperatures exceed a maximum value allowed (HIGH Alarm LED) or fall below a minimum value allowed (LOW Alarm LED); the alarm values ​​are set by the user using Knobs;
  2. if the temperature in the environment remains constant, or the difference between the two temperatures is about zero or within a range setted by a Knob (MAX Alarm LED).

A possible solution is shown in the front Panel below:
20171206 LM35 Basic and Full range 04

To publish on the same Chart the two graphs from the two trasducers 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. In the next image is reported the relative block Diagram:

20171206 LM35 Basic or Full range Snippet2

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

From the middle of november 2017 I tried to program with NXG, instead of LabVIEW 2017 that represents probably the biggest change in LabVIEW.
In fact, a few weeks ago I had an interesting training day with Massimo who is a truly competent Academic sales engineering in IRS, a National Instruments partner in Italy.
The training day was for high school electronics teachers and was called Learn and Teach 2017. So in the future I will begin teaching NXG to my students in my class of Electronic Systems at IIS Mawell Institute in Milan.
LabVIEW NXG is designed to improve the initial user experience, as well as offer improved features for experienced users. It has a similar, yet still different, look-and-feel than LabVIEW 2017.
LabVIEW NXG can connect hardware devices like DAQ very fast. These devices can be acquired instantly without creating an application.

To control 2 rotatory potentiometers with myDAQ and LabVIEW, we mount on our breadboard the schematic reported in the next figure and we connect it with myDAQ.

We have to use only one DAQ Assistant VI with two voltage input like reported in the last figure (but not two DAQ Assistant because this procedure causes an error type “The specified resource is reserved…”). We will use both the ai0 and ai1 analog channels on myDAQ.

Values that we will read inside the Numerical indicators will be between 0 and 5V. Before these VI we have to use Split Signals to split signal into two values.

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.