Sensor de Temp. Labview
Sensor de Temp. Labview
Introduction
The following application demonstrates how LabVIEW can be used with ADR interfaces, or any ASCII based serial data acquisition and control interface. The application is a simple temperature measurement and plot using an ADR112
and an LM335 solid-state temperature sensor. It is assumed the user has a basic knowledge of LabVIEW, however, no prior experience with LabVIEW is required as long as the user manual is available to help with the generic tasks. Figure 1 shows our final operating panel for the application in operation. The panel allows adjustment of the sample rate via a rotary knob, and displays temperature vs. time in a graph format. A digital reading of present temperature is also provided. The hardware consists of an ADR112 connected to com2, interfaced to an LM335 temperature sensor connected to AN0.
A vertical switch from CONTROLS/BOOLEAN/VERTICAL SWITCH A numeric indicator from CONTROLS/NUMERIC/DIGITAL INDICATOR. Arrange the items as shown in Figure 2 using the pointer to add labels by right clicking on each item and typing it in. Change the scale on the waveform chart vertical axis to 0 to 4095 using the hand icon.
Figure 2 : Initial Panel Layout Use the hot key, CTRL-F to show the control diagram. Arrange the items to the positions shown in Figure 3.
Figure 4 : Adding the While Loop We will now add the components required to have the loop execute at an adjustable interval by adding a few more components. Add the following three components; A wait function timer from FUNCTIONS/TIMEANDDIALOG/WAIT A multiply function from FUNCTIONS/ARITHMATIC/MULTIPLY A numeric constant from FUNCTIONS/STUCTSANDCONSTANTS/NUMERICCONSTANT Position the items as shown in Figure 5 and wire them as shown using the wiring tool. The timer will now delay repeated execution of the loop by 1000 times the setting of the sample rate knob on the front panel.( in ms). If the knob is set at one, the sample rate will be 1 second ( 1000 X 1=1000ms ), if the knob is set at 0.5 the sample rate will be 0.5 seconds ( 1000 X 0.5 = 500ms), etc. The on/off slide switch is wired as shown to enable or disable the loop from running. It will serve as a simple enable/stop function on the front panel.
4. The Sequencer
The software in the loop must now be set up to send and receive ASCII data to the ADR112 via Com2. This is accomplished by using a sequencer and a number of serial port functions provided by LabVIEW. The sequence, as the name implies, allows the execution of code in a specific sequence similar to that of a PLC. The sequencer is a series of frames that code is placed into, that determines the actual execution sequence of the code. Add a sequencer to the control diagram using FUNCTIONS/STUCTSANDCONSTANTS/SEQUENCER. position the sequencer as shown in figure 6.
6. Adding a Step
A second step is to be added to the sequencer where the serial read function will be placed. this is done by right clicking on the sequencer frame indicator and selecting " ADD FRAME AFTER". The sequencer will appear as shown in Figure 8.
9. Finalizing Application
Finalizing the application involves converting the ASCII data to Celsius. This is done with a one arithmetic subtraction and one division function added to the second step in the sequencer as shown in Figure 11. These functions are necessary to convert the 12-bit data to Celsius and are explained in the application note "Using the LM335 Temperature Sensor"
Figure 11 : The Final Code The display can then be customized to give the VI a more pleasing appearance. See your user manual for the various customizing options. The scale of the graph can also set using the hand icon to whatever range is to be measured in the application. Our final version was saved as "ADR112.VI" as appears as in Figure 12.
simply by adding steps to the sequencer with additional write and read operations. All of the functions found on ADR interfaces including, counters, PWM, digital I/O, analog outputs, interuppts and stepper indexers can be utilized with LabVIEW. Programs can be as complex or as simple as the application requires. The people at National Instruments have done an outstanding job developing LabVIEW and it is easy to see why it has become so popular. Note: The VI used in this example can be downloaded in zip format using the following link; ADR112.VI in ZIP Format (13KB)