Shop OBEX P1 Docs P2 Docs Learn Events
QTI sensor — Parallax Forums

QTI sensor

Robot FreakRobot Freak Posts: 168
edited 2008-04-18 21:56 in Propeller 1
Are there any QTI sensor examples/objects around here?
I can't find one...

Kind regards,
Robot Freak

Comments

  • PerryPerry Posts: 253
    edited 2008-04-14 17:51
    There is a complete propeller sumobot somewhere on Parallax's site, can't find it now though.
    here is the qti code

    ' main line code
    
    VAR
     
      long qti                                   ' Stores Qtis object results
    
    OBJ
    
     qtis      : "Qtis" 
    
    PUB main
    
     qtis.start(16, 17,@qti ) 
    
        case qti
          %00, %01, %10: bot.go(bot#BACKWARD)
                         waitcnt(clkfreq/2 + cnt)
        case qti
          %00, %01:      bot.go(bot#ROTATE_RIGHT)
          %10:           bot.go(bot#ROTATE_LEFT)
        case qti
          %00, %01, %10: waitcnt(clkfreq*2/3 + cnt)    
    
    ' and the qti module
    
    {{File: Qtis.spin
    
    Demonstrates a way of reading QTI sensors repeatedly in a separate cog and
    updating a variable in the parent cog during each update.
    
    }}
    
    var
    
      ' Order matters for declarations of sPin, ePin, and address
      ' because of longmove in start method.
      long sPin, ePin, address, qtiBits  
      long stack[noparse][[/noparse]30], cog
    
    pub start(_sPin, _ePin, _address) : okay
    
      {{ Starts the servos cog.
         _sPin and _ePin are the endpoints of the contiguous group of QTI signal pins.
         _address is the address of the variable that receives the QTI bit values.
         Returns t/f for success.
      }}
      
      longmove(@sPin, @_sPin, 3)
      okay := cog := cognew(qtis, @stack) + 1
      if okay
        okay := @qtiBits
    
    pub stop
    
      '' Stop servos object and free the cog
    
      if cog
        cogstop(cog~ - 1)
    
    pri qtis
    
    {{This method repeatedly measures the surface monitored by one or more QTI sensors
    and stores the result in the parent object's variable (determined by _address in
    the start method).}} 
    
      outa[noparse][[/noparse]ePin..sPin]~~
    
      repeat
    
        dira[noparse][[/noparse]sPin..ePin]~~
        waitcnt(clkfreq/2000 + cnt)
        dira[noparse][[/noparse]sPin..ePin]~
        waitcnt(clkfreq/2000 + cnt)
        qtiBits := ina[noparse][[/noparse]sPin..ePin]
        long[noparse][[/noparse]address] := qtiBits
        
    
    



    Perry
  • Robot FreakRobot Freak Posts: 168
    edited 2008-04-14 18:02
    I'll give it a try and post the results.

    Thanks a lot!
  • Robot FreakRobot Freak Posts: 168
    edited 2008-04-14 18:15
    Eh... until now, I used 3.3V to power the QTI sensor.
    Is this fine, or do I have to use 5V with a resistor on the white pin?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-04-18 21:56
    The 470Ω bias resistor is for a 5V design, so you should be supplying it with 5V to ensure proper operation. You may also want to put an additional 470Ω resistor on the red line to protect the Propeller pin.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
Sign In or Register to comment.