Beruflich Dokumente
Kultur Dokumente
Slide 2
Slide 3
Slide 4
Parallax CD:
BASIC Stamp Editor
Software BASIC Stamps Windows
Parallax Website:www.parallax.com
BASIC Stamp Editor
Downloads BASIC Stamp Software
Whats a Microcontroller
Documentation Educational Curriculum
Whats a Microcontroller
Downloads Educational Curriculum
Introduction
How many microcontrollers did you use today? Whats a BASIC Stamp?
Introduction
Amazing inventions with the BASIC Stamp
Slide 7
10101001
Powercell
10
Alkaline Battery
or
4
6-9VDC
15 14 Vdd 13 12
Red Black
9 Vdc Battery
X4
Pwr
X5
Vdd X3
P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0
Vin
Vss
1
Sout Sin ATN Vss P0 P1 P2 P3 P4 P5 P6 P7 Vin Vss Rst Vdd P15 P14 P13 P12 P11 P10 P9 P8
X1
U1
Reset
X2 0 1 2
Board of Education
2000-2003
www.stampsinclass.com
10
Powercell
Alkaline Battery
0
101
11
1 100
000
01 010
10
00
11
100
1 0 00 01 0 0
01
10
00
10
Plug BASIC Stamp into Board of Education (if it is not already plugged in), then connect serial cable and battery or power supply.
6-9VDC
9 Vdc Battery
Pwr
in C
STAM PS LASS
TM
1
Sout Sin ATN Vss P0 P1 P2 P3 P4 P5 P6 P7 Vin Vss Rst Vdd P15 P14 P13 P12 P11 P10 P9 P8
X1
U1
Reset
www.stampsinclass.com
Slide 8
Slide 9
The Debug Terminal appears with a message sent by the BASIC Stamp
10101001
Powercell
10
Alkaline Battery
0
101
11
0 001
000
01
10 001
00
11
100
1 0 00 01 0 0
01
10
00
10
6-9VDC
15 14 Vdd 13 12
Red Black
9 Vdc Battery
X4
Pwr
X5
Vdd X3
P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0
Vin
Vss
STAM in C PS LASS
TM
1
Sout Sin ATN Vss P0 P1 P2 P3 P4 P5 P6 P7 Vin Vss Rst Vdd P15 P14 P13 P12 P11 P10 P9 P8
X1
10
U1
Reset
X2 0 1 2
Board of Education
2000-2003
www.stampsinclass.com
Slide 10
' What's a Microcontroller - FirstProgram.bs2 ' BASIC Stamp sends message to Debug Terminal. ' {$STAMP BS2} ' {$PBASIC 2.5} DEBUG "Hello, it's me, your BASIC Stamp!" END
Slide 11
Vin
Vss
LedOnOff.bs2
' {$STAMP BS2} ' {$PBASIC 2.5}
P14 470
Vss
LED
Vss
DO
HIGH 14 PAUSE 250 LOW 14 PAUSE 250 LOOP
Next Step
Write a PBASIC Program to make the BASIC Stamp Switch the LED circuit input between Vdd (5 V) and Vss (0 V).
SOUT SIN ATN VSS P0 P1 P2 P3 P4 P5 P6 P7
1 24
VIN VSS RES VDD (+5V) P15 P14 P13 P12 P11 P10 P9 P8
24
VIN VSS RES VDD (+5V) P15 P14 P13 P12 P11 P10 P9 P8
2
3 4 5 6 7
BS2
Vdd Vss
23
22 21 20 19 18
2
3 4 5 6 7
BS2
Vdd Vss
23
22 21 20 19 18
8
9
17
16
8
9
17
16
10
11
15
14
10
11
15
14
12
13
12
13
BS2-IC
BS2-IC
Slide 13
LedOnOffTenTimes.bs2
' {$STAMP BS2} ' {$PBASIC 2.5} counter VAR Byte FOR counter = 1 TO 10 DEBUG ? counter HIGH 14 PAUSE 500 LOW 14 PAUSE 500 NEXT DEBUG "All done!"
Use the same circuit Replace DO and LOOP with the segments of code shown here. Run your modified program. Remember to save your modified program.
Excerpts from page 54
END
Slide 14
Open FlashLed.bs2 Add two lines of code Run your modified program. Remember to save your modified program under a different name! Use FlashBothLeds.bs2
FlashBothLeds.bs2
Vin Vss
' {$STAMP BS2} ' {$PBASIC 2.5} DO HIGH 14 HIGH 15 PAUSE 250 LOW 14 LOW 15 PAUSE 250 LOOP
Slide 15
470 470 470 470 LED LED Vss Vss Vss Vss LED LED
(1) Resistor 220 (red-red-brown) (1) Resistor 10 k (brown-black-orange) (1) Pushbutton - normally open
1, 4 2, 3 1 2 4 3
1, 4 2, 3
1, 4 2, 3
Pushbutton Circuit
Vdd Vin Vss
P3
P3 220 220 10 k 10 k
Vss Vss
Slide 16
Follow instructions with checkmarks on page 78 How the Circuit and Program Work
Vdd
SOUT SIN ATN VSS P0 P1 P2 P3 P4 P5 P6 P7
1 24
VIN VSS RES VDD (+5V) P15 P14 P13 P12 P11 P10 P9 P8
Vdd
2
3 4 5 6 7
BS2
23
22 21 20 19
1 0
18
8
9
17
16
10
11
15
14
10 k
220
LOOP
Vss
12
13
BS2-IC
Vss
Vdd
24
VIN VSS RES VDD (+5V) P15 P14 P13 P12 P11 P10 P9 P8
Vdd
24
VIN VSS RES VDD (+5V) P15 P14 P13 P12 P11 P10 P9 P8
2
3 4 5 6 7
BS2
23
22 21 20 19
2
3 4 5 6 7
BS2
23
22 21 20 19
1 0
18
1 0
18
8
9
17
16
8
9
17
16
10 k
220
10
11
15
14
10 k
220
P5 10
11
15
14
12
13
P7 12
13
BS2-IC
BS2-IC
Vss
Vss
Slide 17
Pushbutton/LED Circuit
P14 P14 470 470 Vss Vss Vdd Vdd LED LED
Vdd X3
P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0 X2
Vin
Vss
P3 P3 220 220 10 k 10 k
Vss Vss
Slide 18
(2) Pushbuttons normally open (2) Resistors - 10 k (brown-black-orange) (2) Resistors 470 (yellow-violet-brown) (2) Resistors 220 (red-red-brown) (2) LEDs any color
P15 470 P14
Vdd X3
P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0 X2
Vin
Vss
++
PAUSE 50
Vss Vss
LOOP
Slide 19
Servo Circuit
P14 470 LED
(1) Resistor 470 (yellow-violet-brown) (1) LED any color (1) Servo (STD)
15 14 Vdd 13 12
Vin
Vss
P14
Servo
Red Black
Vdd X3
P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0 X2
Vin
Vss
Vss
Slide 20
1.0 ms
2.0 ms
1.5 ms
Example:
P14
White Red
Servo
Vss (0 V)
Black
Vss
Slide 21
2.0 ms Vdd (5 V)
2.0 ms
standard servo www.parallax.com
3 seconds
Vss (0 V)
20 ms
1.0 ms Vdd (5 V)
standard servo www.parallax.com
1.0 ms
3 seconds Vss (0 V)
20 ms
1.5 ms Vdd (5 V)
standard servo www.parallax.com
1.5 ms
Vss (0 V)
3 seconds
20 ms
Slide 22
Transmit windowpane
Receive windowpane
Excerpts from pages 119 - 124 Slide 23
FOR counter = 500 TO 1000 STEP 4 PULSOUT 14, counter PAUSE 20 DEBUG DEC5 counter, CR, CRSRUP NEXT
As counter changes, so does the pulse width. As the pulse width changes, the servos position updates. Position changing over time gives an apparent velocity.
FOR counter = 1000 TO 500 STEP 10 PULSOUT 14, counter PAUSE 20 DEBUG DEC5 counter, CR, CRSRUP NEXT
Count down instead of up at a faster step rate. Excerpts from pages 125-128 Slide 24
Vin
Vss
P14
15 14 Vdd 13 12
Servo
Red Black
Vdd X3
P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0 X2
Vin
Vss
Vss
Vdd
Vdd
P4 220 P3 220
standard servo www.parallax.com
10 k
10 k
Vss
Vss
Dial Circuit
Vin X3 Vss
0.1 F 0.1 F
P7 220
nc
Pot 10 k
0.1 F
+ +
+
W B A
10 k k 10 Pot Pot W W
Vss
B B
Slide 27
ControlServoWithPot.bs2
' {$STAMP BS2} ' {$PBASIC 2.5} time DO HIGH 7 PAUSE 10 RCTIME 7, 1, time VAR Word
HIGH 7
PAUSE 100 RCTIME 7, 1, time
LOOP
Excerpt from page 151-156 Slide 28
ControlServoWithPot.bs2
' {$STAMP BS2} ' {$PBASIC 2.5} time DO HIGH 7 PAUSE 10 RCTIME 7, 1, time VAR Word
HIGH 7
PAUSE 100 RCTIME 7, 1, time
LOOP
Excerpt from page 147 - 148 Slide 29
Display Parts
(8) Resistors 1 k (brown-black-red) (5) Jumper wires (1) 7-segment LED
10 9 8 7 6
G F A B
1 E
4 C
6 B
7 A
9 F
10 G
5 DP
A F G E D C B
LEDs
3
E D C DP
1 2 3 4 5
Common Cathode
DP EDC GFAB
1 k P15 P14
common Vss
Slide 30
SegmentTestWithHighLow.bs2
'{$STAMP BS2} '{$PBASIC 2.5} pinCounter VAR Nib
DP EDC GFAB
DEBUG "I/O Pin", CR, "-------", CR FOR pinCounter = 8 TO 15 DEBUG DEC2 pinCounter, CR HIGH pinCounter PAUSE 1000 LOW pinCounter NEXT
Excerpts from pages 173-174
Common Cathode
10 9 8 7 6
G F A B
X3 Vdd
A F G E D
E D C DP
B
Vin
C
Vss
1 2 3 4 5
Run the example program shown on this slide and compare to your predictions. Slide 31
Common Cathode
Vdd X3 X3
Vin
Vss
' 4
Excerpts from pages 174-178
10 9 8 7 6
G F
Common Cathode
A B
' 3
Vdd
' 2
Vin
Vss
' 1
C
1 2 3 4 5
E D
C DP
Slide 32
Slide 33
TestPiezoWithFreqout.bs2
'{$STAMP BS2} '{$PBASIC 2.5}
f = 2000 Hz T = 12000 s
Piezospeaker Circuit
Vdd X3
P9
P9
Vss
Vss
T
+
P9
Vss
Slide 34
DEBUG "Alarm...", CR PAUSE 100 FREQOUT 9, 500, 1500 PAUSE 500 FREQOUT 9, 500, 1500 PAUSE 500
DEBUG "Robot reply...", CR PAUSE 100 FREQOUT 9, 100, 2800 FREQOUT 9, 200, 2400 FREQOUT 9, 140, 4200 FREQOUT 9, 30, 2000 PAUSE 500
DEBUG "Hyperspace...", CR PAUSE 100 FOR duration = 15 TO 1 STEP 1 FOR frequency = 2000 TO 2500 STEP 20 FREQOUT 9, duration, frequency NEXT NEXT
Excerpts from pages 222-223 Slide 35
1244.5
1480.0
1661.2
1864.7
1217.5
2489.0
2960.0
Run DoReMiFaSolLaTiDo.bs2
1046.5
1318.5
1396.9
1568.0
1760.0
1975.5
2093.0
2349.3
2637.0
2793.0
3729.3 3951.1
A 7 #
or
1108.7
Frequencies in Music
C 6 #
or
D 6 #
or
F 6 #
or
G 6 #
or
A 6 #
or
C 7 #
or
D 7 #
or
F 7 #
or
G 7 #
or
D 6 b
E 6 b
G 6 b
A 6 b
B 6 b
D 7 b
E 7 b
G 7 b
A 7 b
B 7 b
C6 D6 E6 F6 G6 A6 B6 C7 D7 E7 F7 G7 A7 B7 C8
4186.0
1174.7
Slide 37