0% found this document useful (0 votes)
2 views

LabVIEW

This document outlines a project to build a weather station using the National Instruments myDAQ and LabVIEW, focusing on data acquisition and the State Machine Architecture. It details the required hardware and software, setup instructions, and the components used, including sensors for temperature, pressure, and light. The document also provides guidance on programming the LabVIEW interface to read and process data from the sensors.

Uploaded by

yuji
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

LabVIEW

This document outlines a project to build a weather station using the National Instruments myDAQ and LabVIEW, focusing on data acquisition and the State Machine Architecture. It details the required hardware and software, setup instructions, and the components used, including sensors for temperature, pressure, and light. The document also provides guidance on programming the LabVIEW interface to read and process data from the sensors.

Uploaded by

yuji
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

BATANGAS STATE UNIVERSITY

EIM DEPARTMENT

Output Project using NI myDAQ


Weather Station

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.

Required Hardware and Software –


- LabVIEW development environment with the latest DAQmx driver (download the driver
at www.ni.com/drivers)
- National Instruments myDAQ and USB cable
- Breadboard
- 9 Volt battery (or suitable DC power source)
- Wire Strippers and cutters
- Single core wire for prototyping
- Electronic components (listed in Appendix A)

Setting up the myDAQ –


The myDAQ communicates to your computer via USB. To make sure that we have a good
connection and that the myDAQ device is recognised correctly we can use the Measurement and
Automation Explorer (MAX) to find and configure our myDAQ.

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.

Components used in the Weather Station Project –

Absolute pressure sensor –

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

Light Dependant Resistor –

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.

5 Volt Linear Regulator –

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 –

Using Test Panels –

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).

1. Locate to Start » All Programs » National Instruments » Measurement and Automation


Explorer.
2. When opened, under My System » Devices and Interfaces find your MyDAQ (usually
called NI myDAQ ‘myDAQ1’).

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.

4. Setup the Analog Input as shown in the picture above.


5. Once this is set up, go to the Digital I/O panel. The myDAQ has 8 digital I/O channels,
mapped onto one 8 bit ‘port’. You could think of the port as a byte, outputting ones and
zeros in a pattern. In this project we are only using digital I/O 0-2 (3 channels).
6.

ECE | LabVIEW 4
BATANGAS STATE UNIVERSITY
EIM DEPARTMENT

The pattern of Digital I/O for this project is as follows.


Channel Channel Channel Decimal
Sensor 0 1 2 Binary
Light 0 0 0 00000000 0
Temperature 0 0 1 00000001 1
Pressure 0 1 0 00000010 10

7. Starting with Light, set up the Digital I/O Ports as follows:

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.

Weather Station LabVIEW VI –

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.

1. Go to ‘Start’ » ‘All Programs’ » National Instruments » LabVIEW (<version>) »


LabVIEW.
2. On the ‘Getting Started’ page, go to ‘File’ » ‘Open’ and navigate to the ‘Weather Station
with myDAQ’ folder and double click on ‘MyWeatherStation_howto.lvproj’.

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

6. Let’s go ahead and complete the ‘Light’ state.

- 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.

7. Let’s do the same for the ‘Temperature’ State.

- 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

8. Again, lets wire up the ‘Pressure’ State

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.

10. Arrange your front panel as in the picture 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

You might also like