0% found this document useful (0 votes)
53 views9 pages

Hands-On Lab Analog Sensors, Signal and Data Output: 1 Aims of This Exercise

This document provides instructions for a hands-on lab experiment involving collecting analog sensor data using a myRIO device and LabVIEW software. The objectives are to understand reading and writing analog signals, sensors and calibration concepts, and data acquisition skills. The lab uses a potentiometer connected to an analog input channel on the myRIO to generate a voltage that is read and plotted in LabVIEW. Students calibrate the voltage to degrees and save the data to a USB drive to analyze in other software. Optional challenges involve adding a time array and using a timed loop for data acquisition.

Uploaded by

蕾蕾
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views9 pages

Hands-On Lab Analog Sensors, Signal and Data Output: 1 Aims of This Exercise

This document provides instructions for a hands-on lab experiment involving collecting analog sensor data using a myRIO device and LabVIEW software. The objectives are to understand reading and writing analog signals, sensors and calibration concepts, and data acquisition skills. The lab uses a potentiometer connected to an analog input channel on the myRIO to generate a voltage that is read and plotted in LabVIEW. Students calibrate the voltage to degrees and save the data to a USB drive to analyze in other software. Optional challenges involve adding a time array and using a timed loop for data acquisition.

Uploaded by

蕾蕾
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

MACE6X021 – Experimental Methods

Hands-On Lab
Analog Sensors, Signal and Data Output
1 Aims of this exercise
• To improve your understanding of how to read and write analog signals using DAQ hardware and LabVIEW
software
• To improve your knowledge of sensors and the basic concept of calibration
• To develop practical data acquisition skills using a myRIO and a breadboard

2 Prior knowledge required


In order to complete this task you should be familiar with the lecture content up to this point in the course. You
might want to review the introduction to LabVIEW and myRIO lectures as they provide useful information for this
lab.

3 What equipment will I need?


For this exercise you will need:

• A PC with NI LabVIEW installed


• NI myRIO and USB cable
• A FAT32 USB drive
• NI myRIO MXP Protoboard
• A small breadboard
• A Bourns PTV09A-4020F-B103 9mm carbon potentiometer
• 3 breadboard jumper wires

4 Background
A basic but fundamental part of experimentation is the ability to store signals and save them to disk. This can be
done in two ways: by using either a digital or analog signal. In this lab we will use analog devices and the analog-
to-digital converter built into the myRIO device and export those values.

This task is highly representative of the tasks you will be asked to do in your group project later in the semester
so understanding this lab is very important. This task is also highly representative of challenges faced in industrial
experimentation, active control and feedback, robotics, process control and automated manufacturing (plus many
more).

5 Potentiometer (analog input) basics


5.1 Hardware
In order to connect the hardware to the myRIO you will need to use the NI myRIO Expansion Port (MXP)
Protoboard Accessory as shown in Figure 5.1 a) and plug it into the MXP connector A on the myRIO (Figure 5.1
b)). When connecting this to the myRIO (either to MXP connector A or B) the channel list A or B must be used
when programming high-level VIs. However, for this lab we will stick to connector A only. When connecting
subsequent sensors and wires, connect to the yellow highlighted part of the MXP board.

1
MACE6X021 – Experimental Methods

a) b)

Figure 5.1 – a) NI myRIO Expansion Port (MXP) Protoboard Accessory and b) myRIO ports

Just for clarification, when using breadboards, they are linked vertically as shown in Figure 5.2.

Figure 5.2 – How breadboards are connected

In order to connect the potentiometer, use the following steps:

1. Plug the 3-pin potentiometer into the breadboard, as illustrated in Figure 5.3

2. Connect the A-pin of the potentiometer to the AI-GND pin on the breadboard with a connector wire

3. Connect the B-pin of the potentiometer to the 5V using the breadboard with a connector wire

4. Connect the C-pin pf the potentiometer to AI-0 using the breadboard with a connector wire.

Figure 5.3 – Potentiometer with pins labelled

Your circuit should look like the schematic shown below in Figure 5.4.

2
MACE6X021 – Experimental Methods

Figure 5.4 – Circuit schematic for Lab 1

Once this has been completed, ask a demonstrator to inspect your circuit.

5.2 Software
Once the hardware set-up has been completed, plug the myRIO into the PC via the USB cable and open LabVIEW
2019 and complete the following:

1. Ensure that the myRIO environment is selected before you open LabVIEW

2. Create a myRIO project

3. Use the myRIO template and create a myRIO Project

4. Use the default personality for the myRIO. Now open the Main.vi file from the project view (Figure 5.5).

Figure 5.5 – Project Explorer

Open up the Block Diagram page and you will find a basic LabVIEW. In order to get started, delete the contents
of the main loop. Your VI should look as shown in Figure 5.6. Now follow the instructions below.

Figure 5.6 – VI with main loop contents deleted

1. Press Ctrl+H to open context help. Press Ctrl+T to tile the Block Diagram and Front Panel across the screen
3
MACE6X021 – Experimental Methods

2. Right click on the Block Diagram and click the pin icon in the top left of the functions palette to keep it
open throughout this exercise

3. Create a stop button by right clicking the input of the condition terminal on the block diagram and select
create control. This controls when the loop stops. If the condition terminal receives a value of true the
loop will stop executing.

4. Insert a basic Wait function in the timing loop with a 5ms delay to control the execution speed. Create a
numeric constant with the value of 5 and wire it to the wait function.

5. Right-click on the Block Diagram and insert an Analog input (1 sample) from the myRIO menu on the
functions palette into the loop

6. Configure the high-level VI by double left clicking on it. Configure it to record the voltage from channel
AI0 and name the channel Potentiometer

7. Wire the error cluster through the VI to the output of the loop. It is important to make sure the error
cluster is wired because it helps debugging and also ensures the order of execution is easily controllable

Error cluster in Error cluster out

8. On the front panel create a Waveform Chart. On the Block Diagram wire it to the analog input signal

9. Ensure that auto scale are enabled for both the x and y axes on the Waveform Chart by right clicking each
axis and ensuring AutoScale X/Y is ticked

10. Save the VI


4
MACE6X021 – Experimental Methods

11. Run the VI by clicking the arrow in the top left corner

12. Turn the potentiometer and see the output on the screen

As you turn the potentiometer you should see the voltage reading on the chart change. Ask a demonstrator for
assistance if you need it.

Figure 5.7 – Waveform chart showing potentiometer output vs. sample number

5.3 Apply a basic calibration


Find the datasheet for the potentiometer that you are using online and find the maximum angle range (the part
number is on page 1 of the handout). We know that the output of the potentiometer will be between 0 and 5
volts (as this is our supply voltage). Using basic multiplication functions, calculate the conversion from volts to
degrees and output this value to the waveform chart.

Figure 5.8 – Waveform chart showing angle in degrees vs. sample number

5.4 Save the data


Now we will save the data to a pen drive so it can be analysed in other software.

1. Insert a FAT32 format USB pen drive into the port on the myRIO

2. On the Block Diagram, wire the angular output value to the edge of the loop

3. Right-click on the loop tunnel and select indexing as the tunnel mode
5
MACE6X021 – Experimental Methods

4. On the Block Diagram, outside the loop, place a Write Delimited Spreadsheet VI from the File I/O menu

5. Using context help, investigate the terminals on this VI

6. Wire the error cluster through this VI using the error in and error out terminals

7. Wire the loop tunnel exit to the 1D data input terminal

8. Right-click on “delimiter” terminal on the Write Delimited Spreadsheet VI and select create constant, then
input a comma ,

9. Right-click on the “transpose ?” terminal and create a true constant

10. Right-click on the file path terminal and create a control

11. On the Front Panel, in the control for the file path1, type “/u/data.csv”

12. Run the VI and turn the potentiometer a few times before pressing stop

13. Save the VI you will need it for the next part of the lab

The data should now be saved in an easily readable format on the pen drive and can be read into other software
such as Excel or Matlab. In order to read the data off the USB drive you must plug it into the PC directly.

1
The address of a pen drive to a myRIO is /u/ . This should always be used when connecting to external memory
6
MACE6X021 – Experimental Methods

Figure 5.9 – Potentiometer output in Excel

6 Extra challenge 1
Can you create a time array using the Wait value and the loop counter ( ) and then save this in another column
in the spreadsheet output? You will need to build a two-dimensional array from the two one-dimensional ones
using the Build Array function from the Array palette

Ask the demonstrators for assistance if you need it!

Figure 6.1 – Potentiometer output vs. time

7 Extra challenge 2
The acquisition rate used during this lab was set by using a wait function; however, there are more accurate ways
to set acquisition rate, such as using a timed loop. A timed loop will execute at the specified rate (or as fast as it
can) and operates in the same manner as a while loop. The timed loop has the added advantage that it can tell
you when the loop has not executed on time and this can be displayed on the Front Panel using a Boolean
indicator. Give it a try and see what the fastest consistent loop you can set is by monitoring the finished late signal,
as shown in Figure 7.1.

7
MACE6X021 – Experimental Methods

Figure 7.1 –Timed loop structure

8 Conclusion
Congratulations! You have now used DAQ hardware to save an analog signal to disk. Make sure you save the
project that you have completed here as they could be very useful in future projects…

Tell the demonstrators if you have completed the project here as there are extension activities to do if you have
the time.

9 Notes

_______________________________________________________________________________________

___________________________________________________________________________________________

___________________________________________________________________________________________

___________________________________________________________________________________________

___________________________________________________________________________________________

___________________________________________________________________________________________

___________________________________________________________________________________________

________________________________________________________________________________________

8
MACE6X021 – Experimental Methods

10 What did you find difficult?

________________________________________________________________________________________

___________________________________________________________________________________________

________________________________________________________________________________________

11 How are you going to improve this?

________________________________________________________________________________________

________________________________________________________________________________________

You might also like