Beruflich Dokumente
Kultur Dokumente
Stamp
B O X
i-Stamp Microcontroller
Robotic Controller Board
Stamp-BOX2P
i-Stamp2P24 Microcontroller
Robotic Controller Board
1. Stamp-BOX features
l
8-ch. Analog connector with a 10-bit A/D converter that can accept up to +5V.
Piezo Speaker
RS-232 Serial port for downloading and communication (UCON-232S the USB to
Serial converter required if using with USB port)
l
l
l
16x2, ZX-17 Serial Real time clock, ZX-19 Sound smart board, ZX-44 the 4x4 Matrix switch
board, ZX-Tilt 2-outputs Tilt sensor, ZX-SOUND the Sound detector board, ZX-SERVO16 Serial
servo controller board, ESD200 Embeded Bluetooth module, GP2D120/GP2D12 distance
sensor and many types of analog sensor modules.
2. Stamp-BOX Anatomy
Battery Terminal
RS-232 Serial port
Modular Jack
Piezo Speaker
Motor indicator
Direct motor A output
POWER
switch
Analog input
(ANALOG0 to
ANALOG7)
connect with any
analog sensor boards.
Accept 0+5V input
pass through 10-bit
Analog to Digital
Converter circuit to
convert digital data 0
to 1024
BASIC Stamp2P
microcontroller board
3 of RC Servo motor
output P7, P8 and P9
GND
SIGNAL
+V
GND
+5V
7 of Digital
input/output
ports : P0 to
P6
i-Stamp2P24
SERVO
RESET
switch
+5V
SIGNAL
GND
RxD
TxD
DTR
GND
2
3
4
J1
DOWNLOAD
RJ-11 6P4C
SW2
RESET
RxD
+Vm
SW1
ON
TxD
DTR
K1
BATT.
4.5-6V
IC2
L1
10uH
R1
D1
0.47 1N4001
C1
100PF
10V
ZD1
5.1V
C2
100PF
10V
i-Stamp2P24
D2
1N5819
+5V
K9
ANALOG6
+5V
5 AN2
6
K8
ANALOG5
+5V
K7
ANALOG4
+5V
AN3
GP3
GP5
4
2
7 AN0
R14
10k
15
K3
ANALOG1
K2
ANALOG0
+5V
+5V
6
+5V
+5V
AN1
P11
16
K16A-K16B
MOTOR-A
+Vm
SP1
PIEZO
IC4
QP410
GP5 2
GP3
P12
P13
7 AN0
P14
P15
22
23
12
13
11
K11
P5
+5V
K10
P4
+5V
K9
P3
10
9
8
+5V
K8
P2
+5V
K7
P1
+5V
K6
P0
+5V
6
5
MOTOR-A #1
MOTOR-A #2
7 2A
11
IC7/4
MOTOR-B #1
24
10
IC7/1
IC7/3
10
1
2
5
4
16
IC7/2
P6
IC7/1-IC7/4 :
74HC32
P5
1Y 3
1A
2Y
C4
0.01PF
50V
3A
4Y
IC6
L293DNE
3Y
13 12 5
+
+
R28
2k2
DIRECT
14
LED2
DIR. #A
LED3
DIR. #B
11
R29
2k2
Vcc1
C7
0.1/63V
34EN
4
INVERT
12EN
15 4A
MOTOR-B #2
25
+5V
C6
0.1/63V
8
R16
150
K12
P6
LED1
ON
IC3
QP410
AN3
5 AN2
C3
ZD2
1000PF 5.6V
6.3V
P10
K4
ANALOG2
NC
+5V
+5V
3
GND
R15
150
AN1
K5
ANALOG3
CE
OUT
1
3
K10
ANALOG7
POWER-DRIVER BOARD
C5
0.1/63V
R2
1k
IC1
NCP1450-5.0
Q1
FDS6680A
+5V
+5V
K17A-K17B
MOTOR-B
INVERT
+
+
DIRECT
P4
P3
P2
P9
P8
14
+Vm
K15
P9 : SERVO
+Vm
K14
P8 : SERVO
+Vm
K14
P8 : SERVO
13
P1
P0
P7
12
3. Tesing Stamp-BOX2P
3.1 Connect the Stamp-BOX2P with serial port. If computer has only USB port, the USB to
Serial port converter isrequired. UCON-232S is recommended. Turn on the power switch.
ON
P11-PIEZO
P0
P9
P8
P7
RESET
P3
P5
P2
i-Stamp2P24
P4
P1
Stamp-BOX
P6
POWER
MOTOR
RS-232
+V
Serial port at
computer
SERVO
3.2 Open the BASIC Stamp editor software (Version 2.3.9 or higher is recommended. Free
download at www.parallax.com). Press the Ctrl + I button on keyboard for identification
testing. The identification window will show the status below. It means the Stamp-BOX 2P
ready to work.
3.3.3 At Directive menu, select download port by Port Com1 (or any com port)
It shows {$PORT COM1} on second line. Press the Enter key.
3.3.4 Write PBASIC command debug welcome Press the Enter key.
3.3.5 Click Run button on the screen.
This program will run and the debug terminal will appear and show
welcome message on the screen.
FOR i = 0 TO 28
' Play the 29 notes of the LOOKUP table.
LOOKUP i,[E,D,C,D,E,E,E,R,D,D,D,R,E,G,G,R,E,D,C,D,E,E,E,E,D,D,E,D,C],f
FREQOUT 11,563,f,(f-8) MAX 32768
NEXT
STOP
'{$STAMP BS2P}
'{$PBASIC 2.5}
i
f
C
D
E
G
R
VAR
VAR
CON
CON
CON
CON
CON
Byte
Word
839
939
1054
1254
3
DO UNTIL IN0=0
LOOP
FOR i = 0 TO 28
' Play the 29 notes of the LOOKUP table.
LOOKUP i,[E,D,C,D,E,E,E,R,D,D,D,R,E,G,G,R,E,D,C,D,E,E,E,E,D,D,E,D,C],f
FREQOUT 11,563,f,(f-8) MAX 32768
NEXT
STOP
BATTERY
BATTERY
HIGH 12
P12
LOW 12
P12
LOW 13
P13
HIGH 13
P13
Motor driver
Motor driver
DIRECT
INVERT
Motor driver
DIRECT
INVERT
2 SECOND ++++++++++++++
15
15
15
PAUSE 2000
LOW 12 : HIGH 13 : HIGH 14 : LOW 15
'
'
'
'
'
'
Motor
Delay
Motor
Delay
Motor
Motor
Forward
2 Sec
Backward
2 Sec
A Backward ,
B Forward
PAUSE 2000
LOOP
5.3.2 Connect both DC motors at DIRECT outputs
5.3.3 Remove the download cable (CX-4). Turn on the power switch and observe
the motor.
The motor will turn clockwise for 2 seconds and then turn counter-clockwise
for another 2 seconds. Motor A and Motor B will then spin in the opposite direction for
another 2 seconds. It will repeat these steps continuously.
6.1.4 The Debug Terminal window will appear with no data on the display screen
yet. With the download cable still connected, press the switch connected to P1 of the
Stamp-BOX. Observe the changes that occur on the Debug Terminal window.
This test program shows how data sent from the Stamp-BOX2P will be
displayed on the Debug Terminal window. When the switch connected to P1 is
pressed, the robot will send the text Stamp-BOX to be displayed on the Debug
Terminal window.
1
K10
ANALOG7
3
+5V
K9
ANALOG6
+5V
K8
ANALOG5
+5V
K7
ANALOG4
+5V
AN3
5 AN2
6
GP3
GP5
4
2
+5V
R14
10k
P10
R15
150
AN1
7 AN0
IC4
QP410
8
+5V
1
3
K5
ANALOG3
+5V
K4
ANALOG2
+5V
5 AN2
6
K3
ANALOG1
+5V
K2
ANALOG0
+5V
IC5
QP410
AN3
AN1
GP5 2
GP3
R16
150
7 AN0
8
'{$STAMP BS2P}
'{$PBASIC 2.5}
'*********************************
' Read Data From Analog Input (CH1)
'*********************************
ADC VAR
Word
PAUSE 1000
Init:
HIGH 10
DO
LOW 10:PAUSE 1:HIGH 10
SEROUT 10,240,[1]
SERIN 10,240,[ADC.BYTE0,ADC.BYTE1]
DEBUG DEC STREAM,CR
PAUSE 1000
LOOP
Listing 3
Send acknowledge
Select channel 1
Read ADC
Show data on Debug Teminal
(1) Pauses or delays for 1 second so that the IC QP410 is ready to operate.
(2) Sends a pulse signal so that the IC QP410 can acknowledge and get
ready to communicate with the Stamp-BOX2P
(3) The i-Stamp2P24 sends the value of the channel to be read to the IC
QP410. From Listing 3 the value is 1 which means that it will be communicate with ANALOG1
(4) The i-Stamp2P24 reads the value from channel ANALOG1 of the IC QP410
and stores it in the variable ADC. The variable is defined as type word, which can store up
to 16 bits of data, therefore easily storing the 10 bit data from the IC QP410.
(5) i-stamp sends the value that it reads to be displayed on the Debug Terminal.
7.1.1 Connect GP2D120 Infrared distance sensor at ANALOG1 connector.
7.1.2 Download the Listing 3 program to the Stamp-BOX2P and do not remove the
download cable yet. The Debug Terminal window will appear automatically.
7.1.3 Observe the values displayed on the Debug Terminal .
7.1.4 Use your hand or a piece of paper to block in front of the GP2D120 module.
Observe the number that appears on the Debug Terminal
The numbers that appear on the Debug Terminal window will increase.
7.1.5 Move your hand or the paper back and forth to change the distance between
the GP2D120 module. Observe the changes that occur.
The numbers that appear on the Debug Terminal window will change
according to the distance. But the data that the QP410 IC reads from the GP2D120
module is raw data, and not the final distance value.
7.1.6 To make it more convenient to write programs that can call upon the A/D
converter QP410 when needed, asubroutine called RD_ADC is created as shown in Listing 4.
RD_ADC: LOW 10:PAUSE 1:HIGH 10
SEROUT 10,240,[1]
' Select channel 1
SERIN 10,240,[STREAM.BYTE0,STREAM.BYTE1] ' Read ADC
RETURN
Listing 4
Infrared receiver
GP2D120
Vout GND
Vcc
The output from Module GP2D120 is voltage. When connected to the Stamp-BOX,
it must be connected to ports ANALOG0 to ANALOG7 so that the values can be read
through IC QP410. In the previous activity, the GP2D120 module was connected to
ANALOG1, so we can proceed on with this activity.
The value received from GP2D120 must be displayed in the form of range. This
can be done by converting the voltage value using a comparison graph between voltage
and range. For convenience, a line equation with the following formula has been created.
4
'"
8 #
for GP2D120
8.1 Procedure
8.1.1 Type in Listing 5 and download it to the Stamp-BOX2P. After finished, turn off
the switch. Do not remove the download cable yet.
8.1.2 Connect GP2D120 to ANALOG1
8.1.3 Turn on the power switch of the robot. Hold the robot near the wall, with the
side that has the GP2D120 module installed facing the wall. Observe the range value
that appears on the Debug Terminal window.
8.1.4 Use a ruler to measure the distance from the robot to the wall and compare
it to the value shown on the Debug Terminal window.
Listing 5
'{$STAMP BS2P}
'{$PBASIC 2.5}
ADC VAR
Word
R
VAR
Word
PAUSE 1000
HIGH 10
DO
GOSUB RD_ADC
R = (2914 /(ADC+5))-1
8.2 Modifications:
From Listing 5, it is seen that the value read often changes or shifts from the actual
value. Therefore, modifications to the Listing 5 are made to find the average after reading
the value several times, as seen in Listing 6.
8.2.1 Type in Listing 6 and download it to the Stamp-BOX2P. After finished, turn off
the switch. Do not remove the download cable yet.
8.2.2 Repeat the test again from steps 8.1.3 and 8.1.4 . Compare the results.
'{$STAMP BS2P}
'{$PBASIC 2.5}
ADC VAR
Word
R
VAR
Word
I
VAR
Byte
X
VAR
Word
PAUSE 1000
HIGH 10
DO
X = 0
FOR I = 1 TO 5
GOSUB RD_ADC
X = (ADC+X)
NEXT
X = X/5
R = (2914 /(X+5))-1
Listing 6
CM" ,CR
' Read Again
Figure 7 The Debug Terminal window displays the value read from Module
GP2D120 from Listing 6
2mm. pitch
GND
S
+5V
GND
2mm. pitch
S/Data
+5V
5
4
2 RxD
conductor side
3
TxD
4 DTR
5 GND
4
2
LOW
HIGH
10k
510
R
G
LOW
HIGH
Bi-color LED
ZX-LIGHT
+
10k
LDR
Light
ZX-SWITCH2
LDR
+
LOW
HIGH
ZX-PHOTO TRANSISTOR
Bi-color
LED
150
Infrared LED
10k
+
S
Photo
transistor
LOW
HIGH
ZX-Magnetic
UGN3503
ZX-IR LED
0.1/50V
+V
GND
OUT
LED
220
ZX-LED2C
ZX-RESISTANCE
LM334
constant
current source
2
0.1/63V
68R
1mA set
5
OUT
8
7
R Measured
4
TLC2272
Output
1mV./:
ZX-SLIDE
+
S
+
10kB
Voltage increase in
Right direction slide
Voltage increase in
Left direction slide
Vertical
POTENTIOMETER
ZX-POTENTIOMETER
S
+
10kB
Horizontal
Potentiometer
Voltage increase in CW
direction turning.
Voltage increase in CCW
direction turning.
Voltage increase in CW
direction turning.
ZX-THERMISTOR
S
+
10k
+
LDR
Temperature
+
+
ZX-REFLECT
ZX-REFLECT
+
S
MIC1
3
R2 2
100k
+
-
IC1/1
R5
68k
6
R7
12R
C3
22uF
S
R4
R3 100k
1k
IC1 : TLC272
38kHz OUT
IRM
GND
+
+V
38kHz Infrared
Receiver module
ZX-SOUND
IC1/2
4
Super bright
Red LED
0.1/50V
C2
0.1uF/50V
R6
1k
10k
220
R1
22k
C1
470uF/16V
LD
R
18 22 26 30 34 38 42 46 50 54 58
Frequency (kHz)
www.inex.co.th
www.inexglobal.com
(connect to P0-P7)