2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP...
Transcript of 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP...
![Page 1: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/1.jpg)
MIT OpenCourseWare http://ocw.mit.edu 2.007 Design and Manufacturing ISpring 2009
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
![Page 2: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/2.jpg)
2.007 –Design and Manufacturing I
Microcomputers, Programming, Electronics, and Sensors
Dan Frey31 MAR 2009
Images removed due to copyright restrictions. Please see http://media.digikey.com/photos/Honeywell%20Photos/BZ-2RW82.jpghttp://media.digikey.com/photos/Parallax%20Photos/MFG_30056.jpghttp://www2.gpmd.com/imagem/f/mfutl0832.jpg
![Page 3: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/3.jpg)
The Homework Board
Each pin sources at most 20 milli Amps
![Page 4: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/4.jpg)
What happens?
BATTERY
Figure by MIT OpenCourseWare.
Figure by MIT OpenCourseWare.
![Page 5: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/5.jpg)
The Basic Stamp Editor
![Page 6: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/6.jpg)
PBASIC Programming Language
• name VAR size (BIT, NIB, BYTE, WORD)• IF … THEN• FOR … NEXT• GOTO label (define label like -- Loop:)• PULSOUT pin, period (2μsec per unit)• PAUSE period (1millisec per unit)• DEBUG OutputData (to your PC screen)
![Page 7: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/7.jpg)
Make an LED Flash
DOHIGH 14PAUSE 500LOW 14PAUSE 500LOOP
The unit of the PAUSE command is milliseconds, so this line will result in a ½ sec pause.
Just a jumper wire is needed because a 220Ω resistor is built into the pins of the Homework board
![Page 8: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/8.jpg)
What happens?
BATTERY
Figure by MIT OpenCourseWare.
Figure by MIT OpenCourseWare.
![Page 9: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/9.jpg)
What happens?
Figure by MIT OpenCourseWare.
BATTERY
Figure by MIT OpenCourseWare.
![Page 10: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/10.jpg)
What happens?
BATTERY
Figure by MIT OpenCourseWare.
Figure by MIT OpenCourseWare.
![Page 11: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/11.jpg)
Memory and Variable typesMouse VAR BIT ' Mouse is a variable that takes values 0 or 1Cat VAR NIB ' Cat is a variable that uses four bits‘NOTE: The term “NIB” is short for a “Nibble” which is a small Byte Dog VAR BYTE ' Dog is a variable that uses eight bitsHorse VAR Word ' Horse is a variable that that uses 16 bitsDog = 250 ' Assign a value to the byte sized variable DEBUG ? Dog ' Display the result to the screenDog = 260 ' Try to assign a value larger than the byte data type can holdDEBUG ? Dog ' Display the result to the screen
![Page 12: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/12.jpg)
Text removed due to copyright restrictions. Please see http://en.wikibooks.org/wiki/PBASIC_Programming/Loops#FOR_.2F_NEXT
![Page 13: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/13.jpg)
Making an LED Blink Increasingly Faster
Delay VAR NibFOR Delay= 1 TO 15HIGH 14PAUSE 20-(Delay*100)LOW 14PAUSE 20-(Delay*100)NEXT
![Page 14: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/14.jpg)
What Happens?
Delay VAR NibFOR Delay= 1 TO 15HIGH 14PAUSE 20-(Delay*100)LOW 14PAUSE 20-(Delay*100)NEXT
Figure by MIT OpenCourseWare.
![Page 15: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/15.jpg)
Text removed due to copyright restrictions. Please see http://en.wikibooks.org/wiki/PBASIC_Programming/Branches#IF_.2F_THEN_Branches
![Page 16: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/16.jpg)
Checking the State of a SwitchDOIF (IN3 = 1) THENDEBUG HOME, "YES! Switch pressed."
ELSEDEBUG HOME, "NO! Switch is open. "
ENDIFPAUSE 250LOOP
Images removed due to copyright restrictions. Please see http://media.digikey.com/photos/Honeywell%20Photos/BZ-2RW82.jpg
![Page 17: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/17.jpg)
Servo Motors• Actuators that attain and hold a
commanded position• The type you have are commonly used in
radio controlled cars and planes
Note the specifications listed on the box.
Output shaft Features for mounting
- ground (black)- power (red)- signal (yellow)
Input
![Page 18: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/18.jpg)
Pulse Width Modulation (PWM)• The duration of the pulse is interpreted as a
commanded position• PULSOUT pin, period (2μsec per unit)• PAUSE period (1millisec per unit)
time
5V
Voltage on yellow wire
920 μs = full counterclockwise1520 μs = centered2120 ms = full clockwise
duty cycle: 14 to 25?
milli seconds
![Page 19: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/19.jpg)
Electronics Within the Servo• Receive the commanded position• Sense the position of the output shaft• Supply voltage to the motor (either
polarity) depending on the error The back of a small, DC, permanent magnet electric motor
![Page 20: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/20.jpg)
Driving a Servo with the StampDOReps VAR ByteFOR Reps=1 TO 20PULSOUT 3, 750PAUSE 16
NEXTFOR Reps=1 TO 20PULSOUT 3, 1100PAUSE 16
NEXTLOOP
If I declare Reps as type Nib, what happens?1) error message generated 2) program never leaves the first FOR loop3) program leaves each FOR loop sooner4) no difference
![Page 21: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/21.jpg)
Radios
Throttle (ch3)
Rudder (ch 4)
Elevator (ch2)
Aileron (ch 1)
FM transmission
Image removed due to copyright restrictions. Please see http://www.modelimport.com/marcas/futaba/Receptores/41007902%20R168DF.jpg
Please see http://www2.gpmd.com/image/t/towj41.jpg
![Page 22: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/22.jpg)
Getting Signals into the Stamp
throttle VAR Wordrudder VAR WordDOPULSIN 15, 1,throttlePULSIN 14, 1, rudderDEBUG home, ? throttleDEBUG ? rudderPAUSE 200LOOP
Image removed due to copyright restrictions. Please see http://www.modelimport.com/marcas/futaba/Receptores/41007902%20R168DF.jpg
![Page 23: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/23.jpg)
An Issue with Arithmetic
throttle VAR Wordrudder VAR Wordresult VAR Word
DOPULSIN 15, 1,throttlePULSIN 14, 1, rudderDEBUG home, ? throttleDEBUG ? rudder
result=throttle-2*rudderDEBUG ? result
PAUSE 200LOOP
Get in the habit of using brackets to indicate desired order of operations
![Page 24: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/24.jpg)
Another Issue with Arithmetic
throttle VAR Wordrudder VAR Wordresult VAR Word
DOPULSIN 15, 1,throttlePULSIN 14, 1, rudderDEBUG home, ? throttleDEBUG ? rudder
result=(throttle/rudder)*10DEBUG ? result
PAUSE 200LOOP
Intermediate results are stored in the same kind of variable as the final result. Watch out for underflow.
![Page 25: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/25.jpg)
Expanding the Servo Rangethrottle VAR Wordresponse VAR WordDOPULSIN 15, 1,throttleDEBUG home, ? throttleIF (throttle>500)AND(throttle<1000) THENresponse=((throttle-750)*2)+750ELSEresponse=throttleENDIFPULSOUT 14, responsePAUSE 10LOOP
Image removed due to copyright restrictions. Please see http://www.modelimport.com/marcas/futaba/Receptores/41007902%20R168DF.jpg
![Page 26: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/26.jpg)
Switching On/Off a Load
C = collector
B = base
E = emitter
The symbolic representation of the transistorHow the transistor (as packaged) looks literally
Image from Wikimedia Common, http://commons.wikimedia.org
![Page 27: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/27.jpg)
Image removed due to copyright restrictions. Please see http://www.willow.co.uk/AZ822.pdf
![Page 28: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/28.jpg)
H Bridge
• Reversible control of a load such as a DC motor
Image removed due to copyright restrictions. Please see http://commons.wikimedia.org/wiki/File:H_bridge_operating.svg
![Page 29: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/29.jpg)
Running a Motor with Relays
Figure by MIT OpenCourseWare.
![Page 30: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/30.jpg)
How Would I Make a Reversible Control?
Figure by MIT OpenCourseWare.
![Page 31: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/31.jpg)
Sensors
• Contact (mechanical)
• Proximity (optical)
• Range (acoustic)
• Force (piezo)Images removed due to copyright restrictions. Please see http://media.digikey.com/photos/Honeywell%20Photos/BZ-2RW82.jpghttp://www.trossenrobotics.com/store/i/is.aspx?path=/images/Pimages/S-10-GP2D120.jpghttp://www.parallax.com/Portals/0/Images/Prod/2/280/28015-M.jpghttp://media.digikey.com/photos/Parallax%20Photos/MFG_30056.jpg
![Page 32: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/32.jpg)
Force Measurement
• “piezoresistive”– (NOT piezoelectric)
Image removed due to copyright restrictions. Please see http://media.digikey.com/photos/Parallax%20Photos/MFG_30056.jpg
http://www.tekscan.com/pdfs/DatasheetA201.pdf
![Page 33: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/33.jpg)
RCTIME
RC PIN 7result VAR WordDOHIGH RC ' charge the capPAUSE 1 ' for 1 msRCTIME RC, 1, result ' measure RC discharge time --the
arguments are PIN, state (1=diagram “a”), and variableDEBUG HOME, DEC result ' display valuePAUSE 50LOOP
![Page 34: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/34.jpg)
Acoustic Ranging/Detection
• Ultrasonic pulse • Distance-to-target is
by measuring the time required for echo
Image removed due to copyright restrictions. Please seehttp://www.parallax.com/Portals/0/Images/Prod/2/280/28015-M.jpgpp. 2 and 4 in http://www.parallax.com/Portals/0/Downloads/docs/prod/acc/28015-PING-v1.5.pdf
![Page 35: 2.007 Design and Manufacturing I Spring 2009 For ... · DO HIGH 14 PAUSE 500 LOW 14 PAUSE 500 LOOP The unit of the PAUSE command is milliseconds, so this line will result in a ½](https://reader036.fdocuments.in/reader036/viewer/2022071102/5fdc04fe700499171d0f8a27/html5/thumbnails/35.jpg)
Next Steps• Thursday 2 April
– No lecture– Lab times that day instead
• Tuesday 7 April– Lecture on sensors and batteries– HW#3 is due!