QTI sensor
Robot Freak
Posts: 168
Are there any QTI sensor examples/objects around here?
I can't find one...
Kind regards,
Robot Freak
I can't find one...
Kind regards,
Robot Freak
Comments
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
Thanks a lot!
Is this fine, or do I have to use 5V with a resistor on the white pin?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.