QTI Sensor Differences
Hi,
I was working on making a pair of wheel encoders from the QTI sensors, and I noticed something interresting.When I had both hooked up to the BS2 and ran the code, one would give a black value at about 300, while the other would give something at least a 3800, and both would give really big values for the holes in the wheel (empty space). It's always SenseRight that gives the smaller value. I've determined that the hardware must be the same, since I switched the leads and got the same problem. So, what's not right with my code? It's pretty much standard Parallax issue sample code.
I was working on making a pair of wheel encoders from the QTI sensors, and I noticed something interresting.When I had both hooked up to the BS2 and ran the code, one would give a black value at about 300, while the other would give something at least a 3800, and both would give really big values for the holes in the wheel (empty space). It's always SenseRight that gives the smaller value. I've determined that the hardware must be the same, since I switched the leads and got the same problem. So, what's not right with my code? It's pretty much standard Parallax issue sample code.
' {$STAMP BS2e}
' {$PBASIC 2.5}
LeftLineSnsrPwr PIN 13
LeftLineSnsrIn PIN 12
RightLineSnsrPwr PIN 11
RightLineSnsrIn PIN 10
ClrEOR CON 11
SenseLeft VAR Word
SenseRight VAR Word
DO
GOSUB Distance
DEBUG HOME
DEBUG "Encoders Test:", CR
DEBUG DEC senseLeft, CR, DEC SenseRight, CLREOL
PAUSE 100
LOOP
Distance:
HIGH LeftLineSnsrPwr
HIGH LeftLineSnsrIn
PAUSE 1
RCTIME LeftLineSnsrIn, 1, SenseLeft
LOW LeftLineSnsrPwr
LOW LeftLineSnsrIn
PAUSE 1
HIGH RightLineSnsrPwr
HIGH RightLineSnsrIn
PAUSE 1
RCTIME RightLineSnsrIn, 1, SenseRight
LOW RightLineSnsrPwr
LOW RightLineSnsrIn
RETURN

Comments
DO GOSUB Encoders GOSUB LineSensor DEBUG HOME DEBUG "Encoders Test:", CR DEBUG DEC5 SenseLeftWheel, CR, DEC5 SenseRightWheel, CR DEBUG "Line Sensor Test: ", CR DEBUG DEC5 SenseRightLine, CR, DEC5 SenseCenterLine, CR, DEC5 SenseLeftLine PAUSE 100 LOOP Encoders: HIGH LeftWheelSnsrPwr HIGH LeftWheelSnsrIn PAUSE 1 RCTIME LeftWheelSnsrIn, 1, SenseLeftWheel LOW LeftWheelSnsrPwr LOW LeftWheelSnsrIn PAUSE 10 HIGH RightWheelSnsrPwr HIGH RightWheelSnsrIn PAUSE 1 RCTIME RightWheelSnsrIn, 1, SenseRightWheel LOW RightWheelSnsrPwr LOW RightWheelSnsrIn RETURN LineSensor: HIGH LeftLineSnsrPwr HIGH LeftLineSnsrIn PAUSE 1 RCTIME LeftLineSnsrIn, 1, SenseLeftLine LOW LeftLineSnsrPwr LOW LeftLineSnsrIn HIGH RightLineSnsrPwr HIGH RightLineSnsrIn PAUSE 1 RCTIME RightLineSnsrIn, 1, SenseRightLine LOW RightLineSnsrPwr LOW RightLineSnsrIn HIGH CenterLineSnsrPwr HIGH CenterLineSnsrIn PAUSE 1 RCTIME CenterLineSnsrIn, 1, SenseCenterLine LOW CenterLineSnsrPwr LOW CenterLineSnsrIn RETURNJust for kicks, try to define LeftLineSnsrPwr, LeftLineSnsrIn, RightLineSnsrPwr, and RightLineSnsrIn with 'CON' instead of 'PIN' and see if that makes any difference.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.