2 stamp Need help??
Tomvn
Posts: 103
can anyone help to explain this code or add the comment to it, i want to make some adjustment in this code·use ir sensor to make· Bs2 Stamp to control my Boebot move,
but i still not get thought all this code, two sample code below one for transmitting( Bs2 Stamp)·and one for reciver (Boebot)
'
'File Name: Program Listing 1.6 - Stamp-2-Stamp IR_tx.BS2
'
IR_LED_pin CON 7
IR_freq CON 37500
start_bit CON 1
stop_bit CON 4
bin_0 CON 2
bin_1 CON 3
between_pulses CON 2
counter VAR Nib
IR_message VAR Byte
duration VAR Nib
IR_message = 25
FREQOUT IR_LED_pin,start_bit,IR_freq
PAUSE between_pulses
FOR counter = 0 TO 7
duration = 2 + IR_message.LOWBIT(counter)
FREQOUT IR_LED_pin,duration,IR_freq
PAUSE between_pulses
NEXT
FREQOUT IR_LED_pin,stop_bit,IR_freq
' ****** Reset Stamp to run again *******
STOP
'
'File Name: Program Listing 7 - Stamp-2-Stamp IR_rx.BS2
'
IR_detect_pin CON 8
IR_signal VAR IN8
start_bit CON 500
bin_0 CON 1100
bin_1 CON 1600
stop_bit CON 1900
active_low CON 0
counter VAR Nib
IR_pulse VAR Word
duration VAR Nib
IR_message VAR Byte
LOOP:
IF IR_signal = 1 THEN LOOP
process_message:
PULSIN IR_detect_pin,active_low,IR_pulse
IF IR_pulse > stop_bit THEN display_message
LOOKDOWN IR_pulse, < [noparse][[/noparse]bin_0,bin_1],
IR_message.LOWBIT(counter)
counter = counter + 1
GOTO process_message
display_message:
DEBUG "Message received,", CR
DEBUG "it's ", DEC3 IR_message, CR
IR_message = 0
counter = 0
GOTO LOOP
Thanks.
Post Edited (Tomvn) : 7/25/2008 5:25:30 PM GMT
but i still not get thought all this code, two sample code below one for transmitting( Bs2 Stamp)·and one for reciver (Boebot)
'
'File Name: Program Listing 1.6 - Stamp-2-Stamp IR_tx.BS2
'
IR_LED_pin CON 7
IR_freq CON 37500
start_bit CON 1
stop_bit CON 4
bin_0 CON 2
bin_1 CON 3
between_pulses CON 2
counter VAR Nib
IR_message VAR Byte
duration VAR Nib
IR_message = 25
FREQOUT IR_LED_pin,start_bit,IR_freq
PAUSE between_pulses
FOR counter = 0 TO 7
duration = 2 + IR_message.LOWBIT(counter)
FREQOUT IR_LED_pin,duration,IR_freq
PAUSE between_pulses
NEXT
FREQOUT IR_LED_pin,stop_bit,IR_freq
' ****** Reset Stamp to run again *******
STOP
'
'File Name: Program Listing 7 - Stamp-2-Stamp IR_rx.BS2
'
IR_detect_pin CON 8
IR_signal VAR IN8
start_bit CON 500
bin_0 CON 1100
bin_1 CON 1600
stop_bit CON 1900
active_low CON 0
counter VAR Nib
IR_pulse VAR Word
duration VAR Nib
IR_message VAR Byte
LOOP:
IF IR_signal = 1 THEN LOOP
process_message:
PULSIN IR_detect_pin,active_low,IR_pulse
IF IR_pulse > stop_bit THEN display_message
LOOKDOWN IR_pulse, < [noparse][[/noparse]bin_0,bin_1],
IR_message.LOWBIT(counter)
counter = counter + 1
GOTO process_message
display_message:
DEBUG "Message received,", CR
DEBUG "it's ", DEC3 IR_message, CR
IR_message = 0
counter = 0
GOTO LOOP
Thanks.
Post Edited (Tomvn) : 7/25/2008 5:25:30 PM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
i just tested and it work well , but i try to modifiel the RX file to make it 3 seperated detector to see 1 IR LEd, 3 Ir detector on boebot but on different direction , each irdetector if see the for samlpe if left see the bot will turn let 30 degree
so center see the boebot forward to the ir led . but cant make it work , here the sample...
' {$STAMP BS2}
' {$PBASIC 2.5}
'
'File Name: Program Listing 7 - Stamp-2-Stamp IR_rx.BS2
'
IR_detect_left CON 3
IR_detect_right CON 4
IR_detect_center CON 5
IR_signal_5 VAR IN5
IR_signal_4 VAR IN4
IR_signal_3 VAR IN3
start_bit CON 500
bin_0 CON 1100
bin_1 CON 1600
stop_bit CON 1900
active_low CON 0
counter VAR Nib
IR_pulse VAR Word
duration VAR Nib
IR_message VAR Byte
loopi:
IF IR_signal_3 = 1 THEN loopi
process_message:
PULSIN IR_detect_left,active_low,IR_pulse
IF IR_pulse > stop_bit THEN vacuum ' see vacuum sub start running
LOOKDOWN IR_pulse, < [noparse][[/noparse]bin_0,bin_1],
IR_message.LOWBIT(counter)
counter = counter + 1
GOTO process_message
display_message:
DEBUG "Message received,", CR
DEBUG "it's ", DEC3 IR_message, CR
IR_message = 0
counter = 0
vacuum:
FOR ir_message = 1 TO 250
PULSOUT 14, 650
NEXT
RETURN
stepi:
IF IR_signal_5 = 1 THEN stepi
process_message:
PULSIN IR_detect_center,active_low,IR_pulse
IF IR_pulse > stop_bit THEN forward ' see forward pulse run forward
LOOKDOWN IR_pulse, < [noparse][[/noparse]bin_0,bin_1],
IR_message.LOWBIT(counter)
counter = counter + 1
GOTO process_message
display_message:
DEBUG "Message received,", CR
DEBUG "it's ", DEC3 IR_message, CR
IR_message = 0
counter = 0
forward:
FOR ir_message = 1 TO 200
PULSOUT 13, 650
PULSOUT 12, 850
NEXT
RETURN