APLICAȚIA NR



APLICAȚIA NR. 8

Măsurarea temperaturii utilizând senzorul TMP36 și LabVIEW

I. Teorie

The TMP35/TMP36/TMP37 are low voltage, precision centigrade temperature sensors. They provide a voltage output that is linearly proportional to the Celsius (centigrade) temperature. The TMP35/ TMP36/TMP37 do not require any external calibration to provide typical accuracies of ±1°C at +25°C and ±2°C over the −40°C to +125°C temperature range.

The low output impedance of the TMP35/TMP36/TMP37 and its linear output and precise calibration simplify interfacing to temperature control circuitry and ADCs. All three devices are intended for single-supply operation from 2.7 V to 5.5 V maximum. The supply current runs well below 50 μA, providing very low self-heating—less than 0.1°C in still air. In addition, a shutdown function is provided to cut the supply current to less than 0.5 μA.

The TMP35 is functionally compatible with the LM35/LM45 and provides a 250 mV output at 25°C. The TMP35 reads temperatures from 10°C to 125°C. The TMP36 is specified from −40°C to +125°C, provides a 750 mV output at 25°C, and operates to 125°C from a single 2.7 V supply. The TMP36 is functionally compatible with the LM50. Both the TMP35 and TMP36 have an output scale factor of 10 mV/°C.

The TMP37 is intended for applications over the range of 5°C to 100°C and provides an output scale factor of 20 mV/°C. The TMP37 provides a 500 mV output at 25°C. Operation extends to 150°C with reduced accuracy for all devices when operating from a 5 V supply.

The TMP35/TMP36/TMP37 are available in low cost 3-lead TO-92, 8-lead SOIC_N, and 5-lead SOT-23 surface-mount packages.

[pic]

II. Aplicație

The steps we will follow are:

– Configure the DAQ device in the Measurement & Automation Explorer (MAX).

– Open LabVIEW.

– Create the DAQ Assistant on the block diagram window.

– Configure the measurement.

– Create the conversion equation from volts to ºC on the block diagram window.

– Create the chart indicator on the front panel window.

– Wire the DAQ Assistant, conversion equation, and chart indicator.

– Save and run the program.

Temperature Measurement Program

[pic]

Temperature Transducer

– Analog Devices TMP36 Low Voltage, Precision, Centigrade

Temperature Sensor

– Applications: HVAC, automotive, electronics

– Features:

• Temperature span: -40ºC to +125ºC

• Accuracy ± 2ºC

• Linearity ± 0.5ºC

• Temperature coefficient of 10 mV/ºC with 5V supply

• Output voltage is 750 mV at 25ºC using a single 5V supply

• Output Voltage (volts) for T (ºC):

Vout= 0.5 + (0.01)T

• Single-supply operation

• High-level, low-impedance output

[pic]

DAQ Device

– NI USB 6008

– Analog Input Resolution

• 12 bits differential

• 11 bits single-ended

– Maximum Analog Input Sample Rate (single channel)

• 10,000 samples / second

– Analog Input: ± 10V (single-ended)

– Analog Output: 0 to 5V, 12-bit resolution

Digitizing Resolution

– The NI USB 6008 converts the analog voltage signal to digital values for the computer.

– A low-resolution converter creates a step-type graph while a higher-resolution converter creates a more continuous graph.

– The difference can be seen in the graph below.

[pic]

Digitizing Resolution Error

– Digitizing Resolution Error is the difference between the measured and actual voltage when using an analog-to-digital converter (ADC).

– Digitizing Resolution Error = (Input voltage range)/(2N) where N = the ADC resolution.

– The digitizing resolution error is shown in the table below for the different input voltage ranges for 12-bit resolution.

[pic]

Initializing the DAQ

– The first step to using the DAQ is to instruct the operating system to communicate with it.

– To do this use the Measurement and Automation Explorer (MAX)

– MAX can be opened from LabVIEW by selecting Tools >> Measurement & Automation Explorer.

[pic]

We will be using the NI USB 6008 to make temperature measurements

– Plug in the USB 6008 to the computer USB port.

– Open up the Measurement & Automation Explorer (MAX).

– Once MAX has opened, expand the Devices and Interfaces folder.

– After this, expand the Ni-DAQmx devices folder.

– Note under the NI-DAQmx Devices the NI USB-6008: “Dev 1”

– See the screen shot on the next slide.

[pic]

Opening the DAQ Assistant

– Open a blank VI in LabVIEW and expose the Block Diagram.

– Right click anywhere on the block diagram.

– Add the DAQ assistant by opening the functions palette and selecting measurements I/O.

– Next open DAQmx, then click on DAQ Assistant.

– Drag the DAQ Assistant to the block diagram.

– The DAQ Assistant is a graphical interface for configuring measurement tasks, channels, and scales.

– See screen shots on the next slides.

[pic]

[pic]

• Selecting the Signal

– The DAQ assistant opens a new window.

– Expand Acquire Signal, then expand Analog Input.

– Click on the Voltage icon.

• Selecting the Sensor Channel

– The temperature sensor is connected to channel 0, so select ai0 from the DAQ Assistant.

• Sensor Setup

– Maximum voltage 1.5 (corresponds to 100ºC)

– Minimum voltage 0.5 (corresponds to 0ºC)

– Number of samples: 20 Sample Rate: 2 Hz

• Create Conversion Equation

– Right click on the block diagram. Functions >>Programming >> Numeric

[pic]

[pic]

[pic]

[pic]

[pic]

[pic]

[pic]

[pic]

[pic]

[pic]

[pic]

Continuous Temperature Measurement

• We will modify the current program:

– Add a Case Structure to the block diagram.

– Add a control for acquisition time.

– Add a control for the sample interval.

– Code the False Case to convert voltage to ºF and the True Case to convert voltage to ºC.

– Add a Boolean Control for choice of units.

– Add a While Loop and Stop control.

– Add time conversion code.

– Add a greater than or equal to function.

– Add a wait function.

– Wire the nodes.

– Save a run the program.

[pic]

[pic]

• Implementing User Preferences

– A key element in software design is to understand the needs of whoever is going to use the program.

– Here we want the user to be able to change the sample rate, the number of samples, and the temperature units easily with a GUI (graphical user interface) when making a series of measurements.

– To control the sample rate and number of samples, use the terminals on the DAQ Assistant. Move the cursor to the first and second terminals on the left side of the DAQ

Assistant. Right click and select Create >> Control

[pic]

• Algorithms, Pseudo Code, and Flowcharts

– Sophisticated applications require planning and design. A good design will make the software and hardware easier to build initially and easier to modify and maintain in the

future.

– Here we begin the design by developing an algorithm – a procedure or method for solving a problem or producing a desired result with a computer. The procedure or method contains the actions the computer should execute and the order in which they are executed. The procedure requires us to decompose the problem into small tasks and to define the relationships between the tasks.

– When designing an algorithm that requires user input, we must think of the possible ways the user could interact and design our code to deal with them.

– Here the steps in our algorithm written in English, the pseudo code, might be:

• Open the program.

• Run the program.

• Read sampling parameters and units from the user inputs.

• Acquire a measurement from the temperature transducer signal.

• If ºC units are selected

– Convert the units and display temperature in ºC

[pic]

• Else use ºF units

– Convert the units and display temperature in ºF

[pic]

• End the program.

• Flowcharts are often used to represent programs graphically.

• Different symbols represent different operations:

– Ovals represent program start and termination.

– Diamonds represent selections.

– Parallelograms represent input and output.

– Rectangles represent all processes.

[pic]

• Selection with a Case Structure

– Next we will give the user the choice of units using the LabVIEW Case Structure to control the flow of the program.

– If the user selects ºC, one case will implement the ºC conversion formula, or another case will execute the ºF formula.

– Create space on the block diagram for the Case Structure.

– Insert the Case Structure: Functions >> Programming >>Structures >> Case Structure

– After we place the Case Structure on the block diagram, the Run Button arrow is broken to remind us there are additional steps to programming the Case Structure.

– The green ? on the left side of the Case Structure is the Case Structure selector terminal. In the default condition, it accepts a Boolean (True or False) data type control or constant as input. The value wired to the selector terminal determines which one of the Case Structure subdiagrams executes, allowing us to implement the decision from the flowchart. If the input is true, the program executes the code inside the True case.

– Move the green ? Lower on the Case Structure border. Move the cursor over the selector terminal and right-click.

Use the menu to create a control. Label it F or C? (F) to inform the user that this control changes the units and F is the default.

– The True Case is displayed when we first add the Case Structure to the block diagram. The True Case implements the voltage to ºC formula, and the data flows out of the structure to the chart. When wires cross the border of a structure such as the Case Structure, they create a tunnel for the data to flow into or out of the structure.

– We need to switch to the case that implements the ºF conversion, code the formula, and wire to the tunnel.

– Switch from the True Case to the False Case by clicking on one of the arrows in the Case Structure selector label.

– Complete the coding.

– The Boolean control default is False.

– Compare the block diagram to the flowchart.

[pic]

[pic]

[pic]

[pic]

[pic]

[pic]

[pic]

[pic]

• Repetition with a While Loop

– So far we have used sequence and selection. We need one more form of control to build powerful, complex programs – repetition. There are several repetition structures in

LabVIEW, including a While Loop and a For Loop. Here we will use the While Loop.

– The While Loop will allow the user to display a series of values continuously without pushing the Run button each time or without using the Continuous Run button.

– The addition of the While Loop changes the pseudo

code to the following:

• Open the program.

• Run the program.

• Read sampling parameters and units from the user inputs.

• Acquire a measurement from the temperature transducer signal.

• If ºC units are selected, convert the units and display temperature in ºC

• Else use ºF units and convert the units and display temperature in ºF

• If Stop is true, end the program. Else return to step 3.

– The While Loop repeats the code it encloses until the While-Loop Conditional Terminal receives a Boolean value of True.

– Note that the data from the previous loop iteration remains on the graph until it is replaced by the data from the next iteration.

– We can change the sampling parameters while the program is running and LabVIEW will read them before acquiring data in each while-loop iteration.

To implement repetition in the program, insert a While Loop: Functions >> Programming >> Structures >> While Loop.

[pic]

[pic]

[pic]

• Display Data As It Is Acquired

– Rather than waiting for 20 samples to be acquired, converted, and displayed, we can observe the value of each data point as acquired and converted.

– Open the DAQ Assistant and change it to acquire one sample on demand.

– Delete the controls for sample rate and number of samples, as you do not need them anymore.

– In order to display previous data, we will change the Graph to a Chart. Right-click on the Graph. Select Replace >> Modern >>Graph >> Waveform Chart.

– A graph will erase and replot each time the While Loop iterates, but a Chart will retain the data from previous iterations.

– To clear the Chart for subsequent runs, right-click on the Chart,choose Data Operations >> Clear Chart.

– Save the Program: Temperature Measurement One Sample on Demand

• Explicit Execution Timing

– The While Loop will run as fast as it can and essentially take all of the computer’s resources from other important activities. Most times, we don’t need that level of resources or speed.

– We will slow the While Loop’s iteration frequency by adding the Time Delay VI (On the Block Diagram: Functions >> Programming >> Timing >> Time Delay)

– Place the Time Delay VI on the block diagram window, a dialog box appears prompting the user to set the amount of time delay. Set it to 0.25 s.

– This type of timing is called explicit execution timing. It controls how quickly a program executes on the computer processor. It executes the code in the loop and then “sleeps” until the wait time has elapsed.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download