Society of Robots - Robot Forum
Electronics => Electronics => Topic started by: ccdjr106 on February 14, 2010, 12:49:48 PM
-
http://www.pololu.com/catalog/product/959 (http://www.pololu.com/catalog/product/959) i bought this sensor because i thought i would be able to use it for edge detection. is this possible ??
if soo can somebody give me some sample code. im using a arduino.
-
What kind of "edge" are you detecting? Edge of an object? Edge of some tape? etc etc
-
Hi,
[...] i thought i would be able to use it for edge detection. is this possible ??
Possible yes, but a little tedious to work with IMO.
if soo can somebody give me some sample code. im using a arduino.
First off, their description on how it is used with the schematic on the page is wrong.
Interfacing the QTR-1RC Output to a Digital I/O Line
Like the Parallax QTI, the QTR-1RC module has sensor outputs that require a digital I/O line capable of first charging the output capacitor (by driving the line high) and then measuring the time for the capacitor to discharge through the phototransistor. This measurement approach has several advantages, especially when multiple units are used:
It's the exact contrary.
You set the I/O port to output and set it high to discharge the capacitor and then set it to input and measure the time taken until the port reads low, by charging the capacitor through the phototransistor (with a current that will depend on amount of incoming light and hence the speed).
-
how do i measure the time it takes to discharge the capacitor
-
how do i measure the time it takes to discharge the capacitor
A software loop with a counter.
loop:
if input is high
increment counter
goto loop
else
return counter
-
can you plz give me some real code
-
can you plz give me some real code
Like this:
cblock 0x100
counter
endb
#define sensor PORTB, 1
; function to measure the sensor value
; value is stored in the variable counter
Get_sensor_value:
clrf counter
loop:
btfss sensor ; if sensor is high the increment counter
goto exit ; else have count so exit
incf counter, f
goto loop
exit:
return
Or do you want code in another language and for a different processor?
I gave you pseudo code to show the logic so you can write it for your processor.
-
ummm i dont really know what language it is but im using a arduino duemilanove