Shop OBEX P1 Docs P2 Docs Learn Events
QTI Sensor Differences — Parallax Forums

QTI Sensor Differences

SRLMSRLM Posts: 5,045
edited 2009-01-20 04:09 in General Discussion
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.

' {$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

  • skylightskylight Posts: 1,915
    edited 2009-01-18 12:30
    Strange you have a difference by a factor of 10 and a bit,·perhaps there is a component value difference on your breadboard between each sensor and the BS2?
  • SRLMSRLM Posts: 5,045
    edited 2009-01-19 22:24
    Hmm. No, I've hooked each up as an identical duplicate. I've also added another three sensors that are to sense lines, so now I have a total of five. When I did that and added the additional code, I got a bunch of large, four digit numbers that didn't seem to have any relevance to the real world. However, when I changed the DEC statement to a DEC5, they work perfectly. Something's fishy...

      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
    RETURN
    
    
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2009-01-20 04:09
    SRLM,

    Just 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.
Sign In or Register to comment.