Hey,
I have a pololu qtr-1rc reflective sensor that is supposed to be capable of edge detection, but I’m somewhat confused as to how I would use it. Would anyone happen to know of any example code for it?
Thanks!
Hey,
I have a pololu qtr-1rc reflective sensor that is supposed to be capable of edge detection, but I’m somewhat confused as to how I would use it. Would anyone happen to know of any example code for it?
Thanks!
Sorry, but I am not sure what your question is. Are you asking how would I mount it? What would I try to detect with it? How to wire it up? Or how to program it with the Atom Pro 40?
I will assume you are asking how do I write a program to use it. What have you tried? If it were me, I would start out hooking one up to my processor and try to get some readings from it. I would probably start off using the RCTIME command to see if that worked well enough for me. Start off with some simple program like:
[code]dtime var word
dtprev var word
dtprev = 0
main:
high P3
pause 10 ; wait for capacitor to charge…
rctime P3,0,dtime
if dtime <> dtprev then
serout s_out, i9600, [dec dtime, 13]
dtprev = dtime
endif
goto main [/code]
This assumes that your sensor was on IO line P3, change to whatever pin you wish. Also note, I typed this in so may not compile…
Now assuming this works, I would then move the sensor over the different surfaces, like off the line, near the line and on the line to see what the differences are in the values. Then I would calculate a threshold and then write the rest of your program…
Good Luck
Kurt
P.S. - I wrote this program like I would for a Basic Pro 28 (BAP28). For a Bap40, I would probably replace the serout s_out line, with an HSEROUT command with the appropriate init code to initialize the hardware serial port.
The sensor has a TTL output be default, I would try to get it working first.
Edit: I made an incorrect assumption. It appears that the normal way to use this sensor in TTL mode is to use some goofy RC time comparison. I would run away from this sensor. There is just no reason to complicate this sort of sensor that way. Sorry…
Ok, so it seems it would just be somewhat the same as what I would do for a reflective sensor. Set some pin to be high, pause for 10us, and then use rctime to see how long it takes to get the signal to change.