LabVIEW
LabVIEW
EIM DEPARTMENT
This project will take you through the steps in order to make your own weather station using a
National Instruments myDAQ.
This project will enable you to understand the fundamentals of data acquisition (DAQ) using
LabVIEW as well as implementing a well-known programming architecture often used in
LabVIEW applications, the State Machine Architecture. The project encompasses analog input
and digital output, reading in temperature, atmospheric pressure and light levels.
1. Plug in the USB cable into the myDAQ and then into a spare USB port on your computer
2. Locate to Start » All Programs » National Instruments » Measurement and Automation
Explorer.
3. Once opened, under ‘My System’ » ‘Devices and Interfaces’ you should be able to see your
myDAQ as NI myDAQ “<device name>”. Select the myDAQ and click ‘Self-Test’ on the
top toolbar, this will do a hardware check to ensure communications are solid.
An Absolute pressure sensor measures the current atmospheric pressure in relation to a vacuum.
This means that these types of sensors are ideal for atmospheric pressure (barometer) readings.
The pressure sensor used is the MPX5100AP manufactured by Freescale Semiconductor. The
sensor gives out an analog voltage between 0 and 5 Volts. This voltage is fed into the myDAQ via
a multiplexer and a transfer function is then used within LabVIEW to convert this voltage into
pressure.
Transfer Function:
𝑉𝑜𝑢𝑡
𝑃𝑟𝑒𝑠𝑠𝑢𝑟𝑒 = 11.1112 𝑋 { + 0.095} 𝑋 10
𝑉𝑠
Where:
Vout = voltage output
Vs = supply voltage (5V)
ECE | LabVIEW 1
BATANGAS STATE UNIVERSITY
EIM DEPARTMENT
This transfer function will give out atmospheric pressure in Millibars (mb). To calibrate the
pressure, compare the pressure reading with one online for my location. I added 10 mb to the
program to be more accurate.
Thermistor –
Thermistors are commonly used to measure temperature. A Thermistor is a special type of resistor
whose resistance changes with temperature a lot more than normal resistors.
The Thermistor used is the MCP9701A manufactured by Microchip Technology Inc. It outputs a
voltage based on its resistance. It can measure temperatures between -40°C and 125°C. The
transfer function is used to convert the voltage output into degrees Celsius.
Transfer Function:
𝑉𝑜𝑢𝑡 − 𝑉𝑜°𝐶
𝑇𝑒𝑚𝑝𝑒𝑟𝑎𝑡𝑢𝑟𝑒 =
𝑇𝑐
Where:
Vout = voltage output
Vo°C = Sensor Output Voltage at 0°C = 400mV
Tc = Temperature Coefficient = 19.5mV
Similar to the thermistor, the light dependant resistor (LDR) is a special type of resistor which
changes its resistance dependant on the amount of light that hits it. In this case the output is a
voltage between 0V (minimum detected light) and 5V (maximum detected light).
The particular LDR used was the VT90N2 manufactured by Excelitas Technologies.
Analog Multiplexer –
The myDAQ has two differential analog inputs, however this project requires three. As the
measurements that need to be taken are between 0 and 5 volts and do not need to be sampled
particularly quickly an analog multiplexer was used, giving more inputs.
The analog multiplexer has three digital select lines S0, S1 and S2. Therefore, utilising the
myDAQ’s digital output, attache the Digital pins 0-2 to these select lines.
The particular analog multiplexer used was the CD74HCT4051E manufactured by Texas
Instruments.
To get the most accurate readings from the sensors, a 5 volt regulator allows the integrated circuits
a steady 5 volt supply. Linear voltage regulators take in a higher voltage and regulate it down to a
steady voltage. In this case a 9V battery has been regulated down using an LM7805 manufactured
by Texas Instruments.
ECE | LabVIEW 2
BATANGAS STATE UNIVERSITY
EIM DEPARTMENT
The 5V line from the myDAQ can be used; however variations in the supply voltage provided by
the computers USB ports will mean that your measurements will vary slightly between computers.
Circuit Diagram –
The best way to validate your circuit before starting any LabVIEW programming is to use the
builtin test panels within the Measurement and Automation Explorer (MAX).
ECE | LabVIEW 3
BATANGAS STATE UNIVERSITY
EIM DEPARTMENT
3. Click on ‘Test Panels’ button on the top toolbar. This will bring up the test panels for your
myDAQ.
There are four types of panels, Analog Input, Analog out, Digital I/O and Counter I/O. In this test
we will only use Analog Input and Digital I/O.
ECE | LabVIEW 4
BATANGAS STATE UNIVERSITY
EIM DEPARTMENT
8. Press ‘Start’ this will output the values to the digital channels. With this running, go back
to the Analog Input panel and press ‘Start’ you should then be able to see your voltages
from your sensors.
9. Repeat steps 7 and 8 for temperature and pressure.
If you do not get any voltages, check your wiring against the circuit diagram and ensure that
digital ground (DGND) is common with your DC supply ground.
As mentioned previously, the basis of our LabVIEW program will centre on the state machine
architecture, this allows us to sequentially change our digital lines and read and process our data.
The state machine is basically a single case structure within a while loop, where a type defined
Enum and a shift register is used to change states.
ECE | LabVIEW 5
BATANGAS STATE UNIVERSITY
EIM DEPARTMENT
3. Once this project has opened, double click on ‘Main.vi’ this will open an already made
state machine architecture along with a readymade Front Panel
4. Take a moment to navigate around the state machine to make sure you understand how it
works.
5. As our analog inputs from our sensors are going through an analog multiplexer, we need
to set up the digital switching to switch between our sensors. Refer to the table on what
decimal values to write to in each state. Within each state in ‘Main.vi’, set up the digital
I/O task for each state.
Once you have done this, your VI should look similar to this:
ECE | LabVIEW 6
BATANGAS STATE UNIVERSITY
EIM DEPARTMENT
- Navigate to the ‘Light’ State in the case structure; you should see the ‘Light Level’
indicator.
- In the project explorer, click and drag the ‘Light.vi’ into the case structure.
- Wire up the SubVI as shown below.
- Navigate to the ‘Temperature’ State in the case structure; you should see the ‘Thermometer
(°C)’ and ‘Temperature Information’ indicators.
- In the project explorer, click and drag the ‘Calculate Temperature and Levels.vi’ into the
case structure.
- Wire up the SubVI as shown below
ECE | LabVIEW 7
BATANGAS STATE UNIVERSITY
EIM DEPARTMENT
- Navigate to the ‘Pressure’ State in the case structure; you should see the ‘’ and
‘Temperature Information’ indicators.
- In the project explorer, click and drag the ‘Calculate Temperature and Levels.vi’ into the
case structure.
- Wire up the SubVI as shown below
9. Add a ‘Simple Error Handler.vi’ after the ‘DAQmx Clear Task.vi’. Wire it as below.
ECE | LabVIEW 8
BATANGAS STATE UNIVERSITY
EIM DEPARTMENT
11. The VI is now ready to be run, before running the VI ensure that the myDAQ is plugged
in and the correct myDAQ is selected in the ‘Select MyDAQ’ and ‘Digital Port’ as ‘port0’.
If you do not see any measurements check the circuit diagram, ensure the myDAQ is plugged in
and working through test panels, and then check your VI.
End of Project
ECE | LabVIEW 9