Download Lab2

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
ME-191
Computer Applications in Mechanical Engineering II
Lab #2 Analog Input/Output using the LabJack Data Acquisition System
Lab Objectives:



Use MATLAB and LabJack to acquire analog inputs
Use MATLAB and LabJack to control components using analog outputs
Use MATLAB to display and analyze acquired data
Lab Equipment Required



Laptop with MATLAB /LabJack software installed
Labjack U12 DAQ and communications interface
Actuators and Sensors in Table 1.
Table 1. Analog devices and specifications.
Analog Actuators
DC Motor, Mabuchi 6V RF-500TB, Voltage Range: 1.5V-9V, Current:
0.028Amps, RPM: 3700 max, Torque: 14.5 g-cm, shaft diameter: 0.08", shaft
length: 0.35", Size: 1.25"D x 0.76"L
Kysan Electronics #6ZK053 (or similar). Typical applications: beepers, small
toys, cellular phones. Rated RPM: 8500 @ 3VDC, direction of rotation:
dual, operating voltage: 3VDC @ 7.5mA, operating voltage range: 2.5VDC 3.8VDC.
Analog Sensors
LM34 DZ Integrated Circuit Temperature Sensor. Output voltage is linearly
proportional to the Fahrenheit temperature.
 Linear +10.0 mV/°F scale factor
 1.0°F accuracy guaranteed (at +77°F)
 Rated for full -50° to +300°F range
 Operates from 5 to 30 volts
 Less than 90 µA current drain
 Low self-heating, 0.18°F in still air
 Nonlinearity only ±0.5°F typical
 Low-impedance output, 0.4Ohm for 1 mA load
Force Sensor (Phidget: CUI IESP-12) maximum load: 4.0 kgf,
recommended load: 1.5 kgf, resistance @ no load: >500 kΩ, resistance @
full load: 500 Ω, supply voltage: 3-6 VDC, current: 5 mA, life: >100,000
cycles @1.5 kgf (1 second ON/3 seconds off), humidity: 85% RH, no
condensation, operating temperature: +10° to +40° C
Sharp GP2D120 Infrared Ranger, less influence on the color of reflected
objects, reflectivity, analog voltage corresponding to distance, detecting
distance of 4 to 30 cm, external control circuit unnecessary. This sensor takes
a continuous distance reading and reports the distance as an analog voltage
with a distance range of 4 cm (~1.5") to 30cm (~12"). The interface is 3-wire
ME-191
Computer Applications in Mechanical Engineering II
with power, ground and the output voltage. Absolute Maximum Ratings:
Supply Voltage VCC -0.3 to +7 V, Output Terminal Voltage VO -0.3 to
VCC+0.3 V, Operating Temperature -10 to +60 °C, Calibration depends
slightly on the reflectivity of the surface.
Solar Cell, 0.5V/800mA (Jameco #200205), Mfg Ref # SOL2, VELLEMAN
Solar Cells, Size: 2.6"L x 3.7"W x 0.2" Thick
470k resistor (yellow, purple, orange)
Photocell (Jameco #136063), Mfg Ref # WINDSORCDST18 , CDS
Photocell, Operating temperature: -30°C to +70°C, Cadmium Sulfide (CDS),
Soldering: 230°C for 3 seconds, Generate variable signal based on detection
of light levels.
Applications include: auto-focus lenses, exposure meters, contrast controls
for TVs, dimmer or light switches, flame detectors, electronic toys, street
lamp switches, optocouplers. Rating: 40mW, 20Vp, Resistance: ~1k (light),
~10k (dark).
Reading and writing Analog Inputs and Outputs (I/O)
1. Writing an Analog Output
1.a Hardware Set-up
The LabJack includes two analog output ports, each capable of supplying up to 30mW.
Although this is very limiting for large actuators, it will drive some small, simple,
actuators for demonstration. There are many amplifiers available that will increase the
signal from the analog output to control much larger devices.
There are two actuators available, both utilizing a DC motor. Connect the standard DC
motor to GND and AO0 on the LabJack, and the vibrating DC motor to GND and AO1.
Operation of the motors should first be verified using the LJLogger application.
Since the laptop USB port is the power source, it is wise to only operate one motor at
a time.
1.b Software
Write a while-loop in MATLAB that allows the user to control the speed on either
motor. Before the loop begins, ask the operator to choose which motor, and then once
inside the loop, ask the operator to input a value (0-5V, 0-100%, or similar) for the output
motor speed. If the user enters an invalid number (i.e. –1), use this as an indication to exit
the while-loop. Note that the EAnalogOut command needs only to be used once, as
ME-191
Computer Applications in Mechanical Engineering II
the last two arguments set both AO0 and AO1. In general, one of the two arguments
should be zero if the other motor is non-zero. Also, it would also be possible to exit the
loop based on the state of a Digital I/O port. A mechanical switch, as in the week 1 lab,
could be used to provide a HIGH signal and thus end the loop (optional method).
2. Reading an Analog Input
2.a Hardware Set-up
The LabJack includes eight analog input ports, each capable of 12 bits1 of resolution (i.e.,
212 = 4096 discrete magnitude values). By using differential inputs and selectable
programmable gains, effective resolution greater than 16 bits (65,536 levels) can be
achieved. The measurement range is +/-10V, with an absolute maximum of +/-40V
applied to the inputs.
Five sensors will be used to provide inputs to the LabJack. The computer will be used to
measure temperature, force, distance, and light intensity. These sensors are only
representative of a very wide range of types, and were chosen because they can be
connected directly to the LabJack and they conform to power and signal limitations.
Each sensor will be wired directly, and in general, the red wire is for the supply power
(+5), the black wire is GND, and the yellow (or white) wire is the signal. In the case of
the solar cell, connect the red lead directly to an analog input.
The photocell requires the construction of a voltage divider (Figure 1) and the
photocell effects a change in resistance when the incident light intensity changes.





1
Wire the LM34 temperature sensor using +5, GND, and AI0.
Wire the force sensor using +5, GND, and AI1.
Wire the IR distance sensor using +5, GND, and AI2.
Wire the solar cell using GND and AI3.
Wire the photocell and the resistor using +5, GND, and AI4 (Figure 1).
A bit is a discrete piece of information. In digital systems, it is represented either a one or a zero (true/false,
on/off). A 3-bit device has 3 place holders in which either a one or a zero may be present. The eight (23) possible
combinations are consequently: 000, 001, 010, 011, 100, 101, 110, and 111.
ME-191
Computer Applications in Mechanical Engineering II
+5V
Photocell
(variable resistor)
Analog
Input
R
GND
Figure 1 Voltage divider circuit for a photocell.
Verify that analog input signals can be read from each of the five sensors using
LJLogger.
Remember to exit LJLogger before running MATLAB programs.
2.b Software
Write an m-file to read and store input data for approximately ten seconds from an
analog input (longer examination times are required for the temperature sensor), and
when finished, to plot the data. Use a FOR-loop to collect the data, incorporating the
pause command to control how often the data is sampled. Store the data in a vector
(also create an elapsed time vector using the etime() or clock, or tic, toc
functions) so that it can be plotted with the correct time values after the loop is finished.
Vary the inputs by covering or uncovering, moving, cooling, blowing upon, etc., each
sensor so that the plots show a change in the values versus time.
Produce five plots, one for each sensor. Each plot should include the correct labels,
units, and title for each sensor. Hint: once an m-file is working properly, it may be used
as the starting point for the remaining sensors.
ME-191
Computer Applications in Mechanical Engineering II
Required Deliverables
1. Lab Report: Provide a one page (approximately) summary of what you designed and
programmed for this experiment. A group report is optional. Attach all plots and all mfiles for all parts of the experiment. Use comments liberally within each m-file to
describe the function of all primary statements. Due the beginning of the next lab.
2. Homework: Due at first meeting of week 5.

Describe the operation of a photovoltaic cell. List a few power generation
performance characteristics, e.g., W/m2, etc. List all references used in this research.
One reference must be from the MSOE Library (a book, not an e-book from the
library).

Describe the differences between digital I/O devices and analog I/O devices. What is
the resolution of an 8-bit digital device? If the total range is 10 volts, what is the
difference in voltage between levels?

Explore the course website for information describing how to construct a technical
report. List the typical major sections found in most engineering reports. Describe
what is included in a well-crafted abstract.