Upload
james1chapin
View
222
Download
0
Embed Size (px)
Citation preview
8/3/2019 Ece102 Ice l1 Guide
1/12
ECE 102 Engineering Computation Version 1.0
1
ECE 102 In-Class Exercise L1 Guide
In-Class Exercise Objectives
Part 1. Understanding the LabJack hardware Take a LabJack, USB cable, screwdriver, and parts kit out of the box Connect the LabJack to a computer Understand the channels on the Labjack Learn how to connect wires to the LabJack
Part 2. Controlling the LabJack with the LJ Control Panel
Set up Labjack with the LJ Control Panel Build an LED circuit on a protoboard Measure a voltage with the Labjack (Analog Input) Generate a voltage with the LabJack (Analog output)
Part 3. Controlling the LabJack using MATLAB
Download and install the LabJack MATLAB driver package Load and run sample MATLAB programs Modify a MATLAB program to display a plot of measured data
Parts 2 and 3 require you to answer some questions or write MATLAB code. Record your answers on the
worksheet and submit it to the instructor at the end of the lab session.
What you will use to complete this lab exercise
Hardware
LabJack unit LabJack U3 (either LV or HV ), USB cable, and screwdriver Protoboard (Qty 1) Red LED (Light Emitting Diode) Short lead is cathode (negative) (Qty 1) 220 (or 330 ) resistor
Color bands: 220 = RED, RED, BROWN, 330 = ORANGE, ORANGE, BROWN
Jumper wiresSoftware & Documentation
MATLAB 2009b (or later) software on computer with LabJack driver LabJack-MATLAB Support Package LabJack-MATLAB Programming Guide and sample scripts
NOTE: The worksheet, support package, guide, and scripts can be downloaded from the course website.
8/3/2019 Ece102 Ice l1 Guide
2/12
ECE 102 Engineering Computation Version 1.0
2
Part 1. Understanding the LabJack hardware
1. Take the LabJack U3-LV or HV unit, USB cable, and screwdriver from the box. Connect the USB cable to the LabJack and computer. One end connects to the LabJack and
the other end goes to the computer as shown in the pictures below.
LabJack and USB cable from the box
LabJack and one end of the USB cable
Insert one end of the USB cable into the LabJack
Insert the other end of the USB cable into an
available USB port on the lab computer
2. The LabJack has Flexible I/O channels that: read analog input voltage (AIN) read digital input voltage (DI) generate digital output voltage (DO) generate analog output voltage (DAC) (0 V to approximately + 5 V)
USB Cable
LabJackScrewdriver
8/3/2019 Ece102 Ice l1 Guide
3/12
ECE 102 Engineering Computation Version 1.0
3
The following picture shows the basic channel configuration of the LabJack U3-LV.
LabJack also has External I/Os (located at the bottom of the LabJack). It uses the DB15 connector. If
the number of the channels is not enough for your project, these additional I/O channels are useful.
Digital-to-Analog Converter
(DAC)
DAC0 = channel 0
DAC1 = channel 1
Flexible I/O channels
- can read analog in, digital inand write digital out
FIO4 = channel 4FIO5 = channel 5
FIO6 = channel 6
FIO7 = channel 7
Flexible I/O channels
FIO0 = channel 0
FIO1 = channel 1
FIO2 = channel 2
FIO3 = channel 3
VS = supply voltage (always +5V)
GND = common ground
SPC = Reset Pin
SGND = Self-Reset GND with Fuse
(Use this pin for power supply GND)
8 7 6 5 4 3 2 1
15 14 13 12 11 10 9
8/3/2019 Ece102 Ice l1 Guide
4/12
ECE 102 Engineering Computation Version 1.0
4
3. Connecting wires to the LabJack Loosen the terminal screw (turn counterclockwise) as shown in the picture below. This
lowers the metal contact plate beneath the terminal and exposes a slot into which a wire
can be inserted.
Insert a wire into the opened slot just above the contact plate.
Unscrewing VS terminal to
move the contact plate down.
Insert a wire into the slot
just above the contact plate.
8/3/2019 Ece102 Ice l1 Guide
5/12
ECE 102 Engineering Computation Version 1.0
5
Tighten the terminal screw (turn clockwise) to form a solid connection between the wireand the contact plate. Do not overtighten the screw!
Example of connecting an analog circuit (LEDs and resistors) to the LabJacks terminals.
End of Part 1
8/3/2019 Ece102 Ice l1 Guide
6/12
ECE 102 Engineering Computation Version 1.0
6
Part 2. Controlling the LabJack with the LJ Control Panel
The LabJack company supplies utility software for configuring the LabJack hardware. It is mostly used for
verifying that the LabJack is functioning correctly, but it can also be used to make simple measurements.
1. Make sure that your LabJack is connected to the lab computer through the USB cable.2. Open the Labjack Control Panel Software.
Go to: Start All Programs
a. Find and click Labjack folder.
b. Find LJControlPanel as shown below and double-click LJControlPanel.
8/3/2019 Ece102 Ice l1 Guide
7/12
ECE 102 Engineering Computation Version 1.0
7
3. The LJ Control Panel window pops up. Click Find Devices (F3) in the LJ Control Panel window.
4. The U3 device is now recognized. Highlight USB-1 by clicking it.
5. The right side of the window will now show LabJack information. Click the Test button.Note: Ignore any message that tells you a new firmware version is available.
Click Here
Click Here
8/3/2019 Ece102 Ice l1 Guide
8/12
ECE 102 Engineering Computation Version 1.0
8
6. The U3 Test Panel pops up. It allows you to control LabJack channel assignments and generate andread voltages.
External I/Os
(Input and Outputs)
Internal I/Os on Labjack
(Input and Outputs)
DAC
(Generate voltages)
8/3/2019 Ece102 Ice l1 Guide
9/12
ECE 102 Engineering Computation Version 1.0
9
Part 2 - Exercise 1: Construct an LED circuit and use LabJack to measure a node voltage
Construct the LED circuit (see schematic below) on a protoboard.Use the Protoboard Guide on the course website for hints on circuit construction.
Circuit 1: LED using VS
The resistor R shown in the schematic can be either 220 or 330, depending on what you have inyour parts kit.
The cathode (negative) side of the LED has the shorter lead. Connect wires between the circuit and the VS, FIO4, and GND terminals on the LabJack. On the U3 Test Panel, select AIN for FIO4. The label will change from FIO4 to AIN4. The LabJack
will then start reading the voltage at node A.
Answer the Part 2 Exercise 1 questions in the Exercise Worksheet.
Red LED
VS
R = 220 or
330
GND
FIO4A
+
Example
The LED Circuit
before connecting
node A to FIO4.
Since the circuit is
supplied by VS at
+5V, the LED is on.
8/3/2019 Ece102 Ice l1 Guide
10/12
ECE 102 Engineering Computation Version 1.0
10
Part 2 - Exercise 2: Use a DAC instead of VS
Disconnect the circuit from the fixed supply source VS and connect it to DAC0 instead. The DAC(Digital-to-Analog Converter) can generate a variable supply voltage.
Circuit 2: Modified to use DAC0
Under Analog Outputs on the U3 Test Panel, assign a voltage value (from 0 V to 5 V) to DAC0.
Notice how the LED becomes dimmer or brighter, depending on the value of DAC0.
Answer the Part 2 Exercise 2 questions in the Exercise Worksheet.
End of Part 2
Red LED
DAC0
R
GND
FIO4A
+
Change DAC0 here
8/3/2019 Ece102 Ice l1 Guide
11/12
ECE 102 Engineering Computation Version 1.0
11
Part 3. Controlling the LabJack using MATLAB
IMPORTANT: Do this first!
Before proceeding with Part 3, download and install the LabJacks MATLAB support package to your
MCECS Windows account. The procedure for doing this is outlined in the following document:
LJ-MATLAB_Support_Package_Guide_ v1.1.pdf
Once you have installed the package, you can continue with the exercise.
Part 3 - Exercise 1: Run some sample MATLAB programs to see how they control the LabJack
Disconnect all of the wires between the LED circuit and the LabJack. Do not disassemble the circuititself you will use it again in Part 3 Exercise 2.
Download the following MATLAB scripts to your MATLAB user directory:Example_Digital.m
Example_Analog.m
For each script:o Load the script into the MATLAB editor.o Examine the code. You do not need to know all of the details, but you should at least
familiarize yourself with the LabJack statements.
o Follow the set up instructions in the scripts title block to correctly wire up the LabJack.o Run the script and observe the results.
8/3/2019 Ece102 Ice l1 Guide
12/12
ECE 102 Engineering Computation Version 1.0
12
Part 3 - Exercise 2: Modify a MATLAB program to plot measured data from the LED circuit
Disconnect any wires to the LabJack that are left over from Part 3 Exercise 1. Reconnect the LED circuit from Part 2 Exercise 2 (DAC version) to the LabJack. Download the following MATLAB script to your MATLAB user directory:
Measure_LED.m
This script performs an automated measurement of the LED circuit. The DAC0 voltage is defined by a
vector with specific voltage values. The script performs a loop in which FIO4 is measured for each
DAC0 voltage. The measured data is stored in a vector variable and displayed in the MATLAB
command window.
Examine the code. In particular, see which variables it uses to store the voltage values for DAC0 andthe measured values from FIO4.
Run the script and observe the results. Next, you will be asked to modify the MATLAB code. Follow the procedure in Part 3 of the Exercise Worksheet.
End of Part 3
Submit the worksheet with your name, answers, and MATLAB code to the instructor by the
end of the lab session. The only way to receive credit for participating in the In-Class Exercise
is to submit your worksheet!