IR problem
hi everybody
i bluid robort that work by wrieless, there are two mircontroll one is the rmote (TX) the the other in the robort, this robort can go right, left forward and backward... i put two IR detector in the back, they work when u press the backward sw the robort when he come close it an object it should go leftside "left" until the object is passed then it will conutine to go backward... the problem is the is statment doesn't work i don't know actually!!!! could anyone help????????
this is the RX coding ::
'{$STAMP BS2}
'{$PBASIC 2.5}
'
variables
x············· VAR···· Word····· ' Variable for output signal
y············· VAR···· Word····· ' Variable for input signal
eye··········· VAR···· Bit······ ' Variable for IR left
eye1·········· VAR···· Bit······ ' Variable for IR left
'
constants
FwdLtFast····· CON···· 850······ ' Left servo forward full speed
BwdLtFast····· CON···· 650······ ' Left servo backward full speed
FwdRtFast····· CON···· 650······ ' Right servo forward full speed
BwdRtFast····· CON···· 850······ ' Right servo backward full speed
BAUD·········· CON···· 84······· ' Baud set at 9600
'
servo definitions
ltServo······· PIN···· 10······· ' Left Servo Pin
rtServo······· PIN···· 8········ ' Right Servo Pin
'=======================================================================================================
'
main routine
'=======================================================================================================
·LOW 1
·LOW 0
·eye·· = IN4····························································· ' Input for IR reciver left (1)
·eye1· = IN5····························································· ' Input for IR reciver right(2)
·· DO
········································································· 'Sync pulse for the tranimeter
SERIN 3,16780, [noparse][[/noparse]WAIT("!"), x]
·PAUSE 50
·FREQOUT 1, 1, 38500····················································· 'Output from IR LEDs frequecy 40Hz
·FREQOUT 0, 1, 38500
HIGH 11
LOW 13··································································· ' All LEDs turn off, only Green LED will be on
LOW 8···································································· ' tell you that the system on standby mode
LOW 10
LOW 14
LOW 12
IF x=154 THEN
········································································· 'The robot will go ahead
· PULSOUT ltServo, BwdLtFast
· PULSOUT rtServo, BwdRtFast
· PAUSE 15
· HIGH 14
· HIGH 13
· LOW 12
· LOW 11
ELSEIF x=54 THEN························································ 'The robot will turn left
· PULSOUT ltServo, FwdRtFast
· PULSOUT rtServo, FwdRtFast
· PAUSE 15
· HIGH 13
· LOW 12
· LOW 14
· LOW 11
ELSEIF x=210 THEN························································· 'The robot will turn right
· PULSOUT ltServo, FwdLtFast
· PULSOUT rtServo, FwdLtFast
· PAUSE 15
· HIGH 13
· LOW 12
· LOW 14
· LOW 11
ELSEIF x=110 AND (eye = 0) AND (eye1 = 0) THEN······························· 'The robot will turn left
· PULSOUT ltServo, FwdRtFast
· PULSOUT rtServo, FwdRtFast
· PAUSE 15
· HIGH 13
· LOW 12
· LOW 14
· LOW 11
ELSEIF x=110 THEN························································ 'The robot will go backward
· PULSOUT ltServo, FwdLtFast
· PULSOUT rtServo, FwdRtFast
· PAUSE 15
· HIGH 12
· HIGH 13
· LOW 11
· LOW 14
· ELSE····································································· 'Both servo will stop moves
HIGH 11
LOW 13··································································· ' All LEDs turn off, only Green LED will be on
LOW 8···································································· ' tell you that the system on standby mode
LOW 10
LOW 14
LOW 12
ENDIF
LOOP
'======================================== End routine ==================================================
this is the TX coding:
'{$STAMP BS2}
'{$PBASIC 2.5}
'
variables
x······················ VAR Word··· ' Variable for input signal
z······················ VAR Word··· ' Variable for output signal
'============================================================================
'
main routine
'============================================================================
DO
PULSOUT 15, 1200···························· 'Sync pulse for the receiver
SEROUT· 15, 16780, [noparse][[/noparse] "!", x]
IF IN5 = 1 THEN
x = 210
ELSEIF IN0 = 1 THEN
x = 110
ELSEIF IN1 = 1 THEN
x = 54
ELSEIF IN10 = 1 THEN
x = 154
ELSE
x = 232
ENDIF
LOOP
'==================== End routine ==================================
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
i bluid robort that work by wrieless, there are two mircontroll one is the rmote (TX) the the other in the robort, this robort can go right, left forward and backward... i put two IR detector in the back, they work when u press the backward sw the robort when he come close it an object it should go leftside "left" until the object is passed then it will conutine to go backward... the problem is the is statment doesn't work i don't know actually!!!! could anyone help????????
this is the RX coding ::
'{$STAMP BS2}
'{$PBASIC 2.5}
'
variables
x············· VAR···· Word····· ' Variable for output signal
y············· VAR···· Word····· ' Variable for input signal
eye··········· VAR···· Bit······ ' Variable for IR left
eye1·········· VAR···· Bit······ ' Variable for IR left
'
constants
FwdLtFast····· CON···· 850······ ' Left servo forward full speed
BwdLtFast····· CON···· 650······ ' Left servo backward full speed
FwdRtFast····· CON···· 650······ ' Right servo forward full speed
BwdRtFast····· CON···· 850······ ' Right servo backward full speed
BAUD·········· CON···· 84······· ' Baud set at 9600
'
servo definitions
ltServo······· PIN···· 10······· ' Left Servo Pin
rtServo······· PIN···· 8········ ' Right Servo Pin
'=======================================================================================================
'
main routine
'=======================================================================================================
·LOW 1
·LOW 0
·eye·· = IN4····························································· ' Input for IR reciver left (1)
·eye1· = IN5····························································· ' Input for IR reciver right(2)
·· DO
········································································· 'Sync pulse for the tranimeter
SERIN 3,16780, [noparse][[/noparse]WAIT("!"), x]
·PAUSE 50
·FREQOUT 1, 1, 38500····················································· 'Output from IR LEDs frequecy 40Hz
·FREQOUT 0, 1, 38500
HIGH 11
LOW 13··································································· ' All LEDs turn off, only Green LED will be on
LOW 8···································································· ' tell you that the system on standby mode
LOW 10
LOW 14
LOW 12
IF x=154 THEN
········································································· 'The robot will go ahead
· PULSOUT ltServo, BwdLtFast
· PULSOUT rtServo, BwdRtFast
· PAUSE 15
· HIGH 14
· HIGH 13
· LOW 12
· LOW 11
ELSEIF x=54 THEN························································ 'The robot will turn left
· PULSOUT ltServo, FwdRtFast
· PULSOUT rtServo, FwdRtFast
· PAUSE 15
· HIGH 13
· LOW 12
· LOW 14
· LOW 11
ELSEIF x=210 THEN························································· 'The robot will turn right
· PULSOUT ltServo, FwdLtFast
· PULSOUT rtServo, FwdLtFast
· PAUSE 15
· HIGH 13
· LOW 12
· LOW 14
· LOW 11
ELSEIF x=110 AND (eye = 0) AND (eye1 = 0) THEN······························· 'The robot will turn left
· PULSOUT ltServo, FwdRtFast
· PULSOUT rtServo, FwdRtFast
· PAUSE 15
· HIGH 13
· LOW 12
· LOW 14
· LOW 11
ELSEIF x=110 THEN························································ 'The robot will go backward
· PULSOUT ltServo, FwdLtFast
· PULSOUT rtServo, FwdRtFast
· PAUSE 15
· HIGH 12
· HIGH 13
· LOW 11
· LOW 14
· ELSE····································································· 'Both servo will stop moves
HIGH 11
LOW 13··································································· ' All LEDs turn off, only Green LED will be on
LOW 8···································································· ' tell you that the system on standby mode
LOW 10
LOW 14
LOW 12
ENDIF
LOOP
'======================================== End routine ==================================================
this is the TX coding:
'{$STAMP BS2}
'{$PBASIC 2.5}
'
variables
x······················ VAR Word··· ' Variable for input signal
z······················ VAR Word··· ' Variable for output signal
'============================================================================
'
main routine
'============================================================================
DO
PULSOUT 15, 1200···························· 'Sync pulse for the receiver
SEROUT· 15, 16780, [noparse][[/noparse] "!", x]
IF IN5 = 1 THEN
x = 210
ELSEIF IN0 = 1 THEN
x = 110
ELSEIF IN1 = 1 THEN
x = 54
ELSEIF IN10 = 1 THEN
x = 154
ELSE
x = 232
ENDIF
LOOP
'==================== End routine ==================================
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Comments
If you intended for the LOOP to start all the IF-ELSEIF checks over again, then it needs to be a goto....... or precede all that stuff with a "DO WHILE"
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"puff"...... Smile, there went another one.
"ELSEIF x=110 AND (eye = 0) AND (eye1 = 0) THEN 'The robot will turn left
PULSOUT ltServo, FwdRtFast
PULSOUT rtServo, FwdRtFast
PAUSE 15
HIGH 13
LOW 12
LOW 14
LOW 11
this status not working !!! but why????
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔