Upload
brandon-tucker
View
213
Download
0
Embed Size (px)
Citation preview
ME456: Mechatronics Systems Design
Lecture 3Chapter 2:
Lights On –Lights Off
Prof. Clark J. Radcliffe
Mechanical Engineering
Michigan State University
http://www.egr.msu.edu/classes/me456/radcliff
Indicator Lights
• First external device
• An Output to human operator– Indicates binary condition
• On/Off, True/False, OK/Fault, etc.
• Your Indicator Light – the LED– “Light Emitting Diode”
• Makes other outputs possible
LED
• Electrical Properties– Constant “diode drop” of 0.7-1.4 volts
• Depends on color (semiconductor) used
– Current: Max about 15 ma, Min about 5 ma• Get light anywhere in that range
– Too much of either…• SMOKE!!!
Current Limiting Resistor
• Assume 5 volt supply– Resistance, Ohm = Potential/current
• But there is no 500 Ohm Resistor …– Use 470 Ohm (Closest to 500)
310*105105 milliampvoltIVR
OhmIVR 500
Wrong Current Limit?
• With 5 volt supply and 1 volt diode drop– R = 220: I = V/R = (5-1)/220 = 18.2 mA– R = 470: I = V/R = (5-1)/470 = 8.5 mA– R = 690: I = V/R = (5-1)/690 = 5.8 mA
• Either 220 or 470 are commonly used
The Board of Education
• Has connections directly to BS2 pins
• No current protection for I/O pins– Too much current (over 20-25 mA)
burns out I/O pin
• Be Careful… – The BS2 you save may be yours…
The Homework Board
• Built-in 220 Ohm current limiters– Why???
• To limit max current (short) on any pin
• I = V/R = 5 volt/220 Ohm = 23 mA
– This protects the BS2 components from an inadvertent short
• When can this happen?– Let’s talk I/O pins
The Homework Board
220 Ohm resistors protect I/O pins
220 Ohm Resistors
(16)
Breadboard
Serial Connector
9 volt Battery Connector
Reset Switch
I/O pin current limited to 5 volt/220 Ohm = 23 mA
Basic Stamp I/O Pins
• Two Operating Conditions– “Input” or “High Impedance”
• Used to sense level– Near 5 volts (above 3.5 volts) = “True”, “1”– Near 0 volts (below 1.5 volts) = “False”, “0”
• Input impedance is about 10M Ohm (very high)– I = 5 volts/10x106 Ohm = 5 10x10-7 Amp (very small)
– “Output” or “Low Impedance”• Used to set level… “1” = 5 volts, “0” = 0 volts• No change in potential with current
– UNTIL you overload pin
BS2 I/O pin Overload
• Set I/O pin to “output”, then– Pin = 0 connected to 5 volts => OVERLOAD– Pin = 1 connected to 0 volts => OVERLOAD
• In either case, I/O pin is competing with power supply and one will lose– Usually the I/O pin
• Power supply = 2 A, pin = 25 mA max
Turning LEDs On/Off
• Two Methods…
• Active High (what the book does)
LED goes onwhen P14 is High
Turning LED’s On/Off
• Active Low (Often Recommended)
LED goes onwhen P14 is Low
Many microcontroller pins work best as sinks
470
Vdd (5v)
P14 (0v)
+
-
Current 470
Bi-Color LED
• A Red and Green LED packaged as onePin 1 = “+”, Pin 2 = “-” yields Red
Pin 1 = “-”, Pin 2 = “+” yields Green
Look for the clear LED… in your package
Basic Stamp Commands
• HIGH pin – sets a pin to output and 5v
• LOW pin – sets a pin to output and 0v
• PAUSE count – pauses count milliseconds
• FOR … NEXT– Allows for a fixed number of repeats
• DO … LOOP (new in PBASIC 2.5)– Allows for an infinite number of repeats
Solid State Relays
• Your ticket to real POWER– 3.5volt @ 2 mA “ON” gives 0-30 volts @40 A
I/O pin
+5v Vdd LoadAC or DC
Power