I.R. tracking problems/code and frequency scanning
Cline
Posts: 36
'Hey everyone,
I am having trouble adding a line in. When both irs are recieved the servo jumps one way and then next. I have it mounted on a tripod with one continous servo turning the board. I cant figure out· how to stop the servo when both irs are recieving. i would like it to to be timed so that it will go back to a Type of scanning routine.
Also i am in need of advice, i bought two led flashlights with 5 leds in each, after gutting the assembly for the aluminum head with 5 leds in it. i replaced the leds with IRs that i ordered with a set of detectors[noparse][[/noparse]matched]
so, now i have a pair of ir emittors, five in each. i like the frequency scan but dont really now a good way to control 2 "eyes" with power issues as well as controlling 5 irs in a series..how should i wire it?
thanks so much.
·{$STAMP BS2}
' {$PBASIC 2.5}
· 'variables
irdetectleft· VAR Bit
irdetectright· VAR Bit
·'initialize
·DEBUG "testing speaker"
·FREQOUT 4, 2000, 3000
·DEBUG CLS,
····· "ir detectors",CR,
····· "left···· right",CR,
····· "_____· ______"
····· 'main routine
·DO
····· FREQOUT 8,1, 38500
····· irdetectleft = IN9
····· FREQOUT 2,1,38500
····· irdetectright = IN0
······· IF (irdetectleft = 0) AND (irdetectright=0) THEN
······· HIGH 7
·············· ELSE
·············· LOW 7
·············· ENDIF
····· IF (irdetectleft = 0) THEN
·········· HIGH 10
···········PULSOUT 15,1000
····· ELSE
········ ·LOW 10
····· ·ENDIF
········· IF (irdetectright = 0)THEN
········ ·HIGH 1
··········· PULSOUT 15,500
····· ELSE
··········· LOW 1
····· ENDIF
·········· DEBUG CRSRXY, 2, 3, BIN1 irdetectleft,
··········· CRSRXY, 9, 3, BIN1 irdetectright
······· PAUSE 100
······· LOOP
I am having trouble adding a line in. When both irs are recieved the servo jumps one way and then next. I have it mounted on a tripod with one continous servo turning the board. I cant figure out· how to stop the servo when both irs are recieving. i would like it to to be timed so that it will go back to a Type of scanning routine.
Also i am in need of advice, i bought two led flashlights with 5 leds in each, after gutting the assembly for the aluminum head with 5 leds in it. i replaced the leds with IRs that i ordered with a set of detectors[noparse][[/noparse]matched]
so, now i have a pair of ir emittors, five in each. i like the frequency scan but dont really now a good way to control 2 "eyes" with power issues as well as controlling 5 irs in a series..how should i wire it?
thanks so much.
·{$STAMP BS2}
' {$PBASIC 2.5}
· 'variables
irdetectleft· VAR Bit
irdetectright· VAR Bit
·'initialize
·DEBUG "testing speaker"
·FREQOUT 4, 2000, 3000
·DEBUG CLS,
····· "ir detectors",CR,
····· "left···· right",CR,
····· "_____· ______"
····· 'main routine
·DO
····· FREQOUT 8,1, 38500
····· irdetectleft = IN9
····· FREQOUT 2,1,38500
····· irdetectright = IN0
······· IF (irdetectleft = 0) AND (irdetectright=0) THEN
······· HIGH 7
·············· ELSE
·············· LOW 7
·············· ENDIF
····· IF (irdetectleft = 0) THEN
·········· HIGH 10
···········PULSOUT 15,1000
····· ELSE
········ ·LOW 10
····· ·ENDIF
········· IF (irdetectright = 0)THEN
········ ·HIGH 1
··········· PULSOUT 15,500
····· ELSE
··········· LOW 1
····· ENDIF
·········· DEBUG CRSRXY, 2, 3, BIN1 irdetectleft,
··········· CRSRXY, 9, 3, BIN1 irdetectright
······· PAUSE 100
······· LOOP
Comments
Follow the logic through the code:
-Play a tone (starting the program)
-initialize debug (start of program as well)
-check both detectors (left and right)
-see if both are = 0 (if they are, make pin 7 high, if BOTH are not =0, then make pin 7 low)
-check if left side = 0 (you already checked this above, in the compound AND statement)
-check if right side = 0 (already checked this above, in the compound AND statement)
If both inputs are = 0, then you will meet the conditions in all three checks (the check for both, the check left, and the check right) -
If you want to check for both = 0, then the individual checks only if both are not = 0, then you could structure your code with IF, else IF statements.
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
RClarke@Parallax.com
····HIGH·7
··ELSE
····LOW·7
··ENDIF
··IF·(irdetectleft·=·0)·THEN
····HIGH·10
····PULSOUT·15,1000
··ELSE
····LOW·10
··ENDIF
··IF·(irdetectright·=·0)THEN
····HIGH·1
····PULSOUT·15,500
··ELSE
····LOW·1
··ENDIF
so, would i change,
if (irdetectleft=0) and (irdetect=0) then
high7
pause 200
low 7
elseif
(irdetectleft)=0 then
high 1
pulsout 15,500
im not sure how to implement elseif..
·
thanks