You are on page 1of 6

HSI255 – Lab 1 – Introduction to HSI255

Lab Instructions
These are instructions for completing the lab. You do not need to print these pages, but you may do so if you’d
like a hard copy to refer to. The “answer sheet” will be printed for you and you will answer the questions on
the page during the lab. Answer sheets must be submitted by the end of each lab period. In addition to
submitting the answer sheets, you will also be submitting your code on BB.
Lab 1 Overview
In this lab, you will learn simple interfacing techniques for the LabJack U3-HV device. In Part 1, the hardware
setup will explore the connector terminals on the unit, and you will measure and observe the IO’s
(input/outputs) under different conditions. In Part 2, the software setup will write a program to interface
between the LabJack and its specialized library, where you will call functions to display its firmware and
hardware information.
What you will need (for this lab and every lab):

• Safety glasses
• Jumper wire
• Wire cutters/strippers
• Small flat-head screwdriver

1
Part 1 – Hardware
1. Datasheet – A datasheet provides important information about a product. You will be finding and using
datasheets throughout the semester for nearly every component you will be using in the labs. The
LabJack datasheet is located here: https://labjack.com/support/datasheets/u3/hardware-description
2. At your workstation, pull out the LabJack U3-HV drawer. Inspect the unit to familiarize yourself with
the location of its IO terminals and power.
o Is the green LED on the left side ON? (If yes, the unit is ready to work.)
o Where is the USB interface cable that connects to the computer?
o How many screw terminal ports are there on both sides of the device?
o Observe the extra IO channels available through the DB-15 connector.
3. Look at the available terminals and use your datasheet to answer the questions for Q1 on the answer
sheet.

Each terminal on the LabJack is a different port or “IO” and can be connected to a jumper wire. Each
terminal has a little pocket to put the stripped wire end into and then gets tightened using a flathead
screwdriver. An easy way to remember which way to turn your screwdriver is “righty tighty, lefty loosey”.
You should be tightening the screw by turning clockwise and loosening the screw by turning
counterclockwise. Be very gentle with the screws! Do not overtighten them!

4. Next, you will be connecting the power terminals of the LabJack:


o Create two long jumper wires, each 10cm long. Make sure to strip the insulation off the ends,
no more than 1cm.
o Open a GND terminal with a screwdriver and insert one end of a jumper wire. Use your
screwdriver to lock the jumper wire in place. For now, leave the other end disconnected (but be
sure not to let it touch anything).
o Open a VS terminal with a screwdriver and insert one end of a jumper wire. Use your
screwdriver to lock the jumper wire in place. Leave the other end disconnected.
5. Use the DMM on your workbench to measure the voltage between VS and GND and answer Q2 on the
answer sheet.
6. On your workstation PC, open MyApps and launch “LabJack 2018”. Wait for it to load and then open
the program called “LJControlPanel”.

You will be using LJControlPanel throughout the semester to test and troubleshoot your circuits. After
building your circuits, you will want to verify the behaviour using this software before making/running
your code. Hint: LJControlPanel must be launched first on school PCs before writing your code because it
installs the necessary libraries and header files.

2
7. In LJControlPanel, click “Find Devices”. Wait until your U3 is found, then select it. Look for the
Firmware and Hardware versions of the unit and answer Q3 on the answer sheet.
8. Click the button in the bottom right called “Test” to open the IO interface. You should see the following
screen:

In the following steps, you will learn:


o How to READ an Analog Input (AIN)
o How to READ a Flexible channel (FIO)
o How to SET an Analog Output (DAC)
9. Take the free end of the GND jumper wire and touch it inside the AIN0 port. We can say that GND is
now connected to AIN0. Observe what happens in the LJControlPanel.
10. Disconnect GND from AIN0.
11. Touch the GND wire to each of the other analog inputs (AIN1, AIN2, AIN3) one at a time and observe
what happens in LJControlPanel.
12. Disconnect GND from the analog inputs. Summarize your observations on Q4 on the answer sheet.
13. Take the free end of the VS jumper wire and touch it inside the port called AIN0. We can say that VS is
now connected to AIN0. Observe what happens in LJControlPanel.
14. Disconnect VS from AIN0.

3
15. Touch the VS wire to each of the other analog inputs (AIN1, AIN2, AIN3) one at a time and observe
what happens in LJControlPanel.
16. Disconnect VS from the analog inputs. Summarize your observations on Q5 on the answer sheet.
17. In LJControlPanel, look at the Flexible IO section and note the headings: “AIN”, “DI”, and “DO”. What
do each of these acronyms mean?

DI and DO are either on or off, high or low, 0V or 3.3V, there is no in between. When an FIO terminal is set to
DI, the checkmark will be present if the channel is reading high and the checkmark will be missing if the
channel is reading low. When the terminal is set to DO, you can set the output high by adding a checkmark
and set it low by removing the checkmark.

18. While FIO4 is on DI mode, place the free end of the GND wire inside the FIO4 port. We can say that
GND is now connected to FIO4. Observe what happens in the LJControlPanel.
19. Change FIO4 to AIN mode. Observe what happens in the LJControlPanel. Summarize your observations
on Q6 on the answer sheet.
20. Disconnect GND from FIO4. Remove the wire from the GND terminal.
21. Using a new jumper wire, connect DAC1 to AIN2.
22. In LJControlPanel, look at the Analog Outputs section and note the two boxes with numbers that can
be set. Play with the values (using the arrow keys or you can type numbers) until you find the upper
and lower limits of the voltage output of the two channels. Answer Q7 on the answer sheet.
23. Observe what happens to AIN2 in LJControlPanel as DAC1 changes its value. Demonstrate this change
to your lab professor and obtain a signature on your answer sheet (Q8).
24. Use your screwdriver to fully remove all jumper wires from the LabJack.
25. Exit LJControlPanel.
LabJacks can only communicate with one application at a time. Make sure you are running EITHER
LJControlPanel OR your program. If both are running at the same time, unexpected behaviour will be
observed.

4
Part 2 – Software

Instructions on how to create and set up your Visual Studio projects are also available on BB. Look for the file
called “LabJackU3 – GettingStarted.pdf” under the “Labs” heading.

1. Using MyApps, launch Visual Studio 2017. Choose the version labeled “NH”.
2. Create a new, empty C project. Save your project somewhere accessible, like your desktop. Call your
project “HSI255 Lab 1”.
3. In the Solution Explorer, right-click on “Source Files”, then “Add” > “New Item…”. Create a new .c file
(remove the “pp”) and put your name in the file. For example, “AggieStopkaLab1.c”.
4. Every program you create for the LabJack must have a specific library associated with the project:
o Right-click your project’s name in the Solution Explorer window, then “Add” > “Existing Item…”.
o Navigate to “C:\Program Files (x86)\LabJack\Drivers”.
o Select LabJackUD.lib (be sure not to select the .h file!)
o Click “Add”.
5. Every program you create for the LabJack requires several header files to be associated with your
projects. Here are the four preprocessor directives you will be adding to each program you write in
HSI255 (go ahead and type them in now):

6. Open the “Lab1Code.txt” file on BB and paste the rest of the code in after the preprocessor directives.
7. Run the program. Take note of the output. Does it match what you observed earlier in LJControlPanel?
If it does, demonstrate your code running to your lab professor for a signature on your answer sheet
(Q9).
8. Once your program has run successfully, copy the output from the console window and add a
comment block at the end of the code with the pasted output.
9. Go back to look at the code. You will see that the code has been broken down into six sections. Add a
comment after each //Section # describing what you think the following line(s) of code do. It’s ok
if you are not sure, we will cover it all later, but you should try based on what you have observed and
what you know from PRG155. It must be in your own words.

5
10. Add a programmer’s block at the top of your code that includes the program name, your name, the
date, and the purpose of your code. A programmer’s block looks something like this (do not copy this
one):

Submitting your work

o Submit the filled-out answer sheet by the end of the lab period.
o Submit your completed .c file on BB under the “Lab 1” folder.

You might also like