Help problem with my program
fisheater
Posts: 6
Hello,
Im having trouble sending and reciving messages using IR communication.
It sends the message but the reciving boe-bot only recives the message
when i wave my hand over the IR. I tried puting in a pause after the Freqout command but didnt seem to help. Here is my reciving program:
[noparse][[/noparse]qoute]
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] Variables ]
counter·········· VAR Word
x················ VAR Word
y················ VAR Word
irdetect········· VAR Word
remoteCode······· VAR Byte
irpulse·········· VAR Word
'
[noparse][[/noparse] Program Code ]
PAUSE 500
GOSUB beep
GOSUB recieve_from_two······················· 'monitor reciever
'GOSUB send_two_away
END
'
[noparse][[/noparse] Sub Routines ]
beep:
· FREQOUT 0, 100, 2000
· PAUSE 20
· RETURN
recieve_from_two:
'FOR counter = 1 TO 100
· DO
··· 'DO
····· remoteCode = 0············· 'clear all bits in remoteCode
···· DO
····· PULSIN 1, 0, irpulse
······· DEBUG "looking for transmition", CR
····· LOOP UNTIL irpulse > 1200
··· PULSIN 1, 0, irPulse··················· 'measure pulse
··· IF irPulse > 750 THEN remoteCode.BIT0=1···· 'set(or leave clear) bit-1
··· PULSIN 1, 0, irPulse··················· 'measure next pulse
··· IF irPulse > 750 THEN remoteCode.BIT1=1···· 'set(or leave clear) bit-1
··· DEBUG "code read",· CR
··· LOOP UNTIL (remoteCode.BIT0=0 AND remoteCode.BIT1=0)
······· DEBUG "00 recieved", CR
'NEXT
··· RETURN
send_two_away:
DO
· 'FOR counter = 1 TO 200
·· DEBUG "sending 00", CR
··· FREQOUT 6, 3, 38500···················· 'Start Pulse 3ms
··· PAUSE 1································· 'Pause 1ms
··· FREQOUT 6, 1, 38500···················· 'Pause 2ms = 1
··· PAUSE 1
··· FREQOUT 6, 1, 38500···················· 'Pause 2ms = 1
··· PAUSE 1
··· 'NEXT
LOOP
··· RETURN
END
[noparse][[/noparse]quote]
·
Im having trouble sending and reciving messages using IR communication.
It sends the message but the reciving boe-bot only recives the message
when i wave my hand over the IR. I tried puting in a pause after the Freqout command but didnt seem to help. Here is my reciving program:
[noparse][[/noparse]qoute]
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] Variables ]
counter·········· VAR Word
x················ VAR Word
y················ VAR Word
irdetect········· VAR Word
remoteCode······· VAR Byte
irpulse·········· VAR Word
'
[noparse][[/noparse] Program Code ]
PAUSE 500
GOSUB beep
GOSUB recieve_from_two······················· 'monitor reciever
'GOSUB send_two_away
END
'
[noparse][[/noparse] Sub Routines ]
beep:
· FREQOUT 0, 100, 2000
· PAUSE 20
· RETURN
recieve_from_two:
'FOR counter = 1 TO 100
· DO
··· 'DO
····· remoteCode = 0············· 'clear all bits in remoteCode
···· DO
····· PULSIN 1, 0, irpulse
······· DEBUG "looking for transmition", CR
····· LOOP UNTIL irpulse > 1200
··· PULSIN 1, 0, irPulse··················· 'measure pulse
··· IF irPulse > 750 THEN remoteCode.BIT0=1···· 'set(or leave clear) bit-1
··· PULSIN 1, 0, irPulse··················· 'measure next pulse
··· IF irPulse > 750 THEN remoteCode.BIT1=1···· 'set(or leave clear) bit-1
··· DEBUG "code read",· CR
··· LOOP UNTIL (remoteCode.BIT0=0 AND remoteCode.BIT1=0)
······· DEBUG "00 recieved", CR
'NEXT
··· RETURN
send_two_away:
DO
· 'FOR counter = 1 TO 200
·· DEBUG "sending 00", CR
··· FREQOUT 6, 3, 38500···················· 'Start Pulse 3ms
··· PAUSE 1································· 'Pause 1ms
··· FREQOUT 6, 1, 38500···················· 'Pause 2ms = 1
··· PAUSE 1
··· FREQOUT 6, 1, 38500···················· 'Pause 2ms = 1
··· PAUSE 1
··· 'NEXT
LOOP
··· RETURN
END
[noparse][[/noparse]quote]
·