I am trying to write some code to read a QTR-HD-01RC Reflectance Sensor (https://www.pololu.com/product/4101).
The faq says to:
Set the I/O line to an output and drive it high.
Allow at least 10 μs for the sensor output to rise.
Make the I/O line an input (high impedance).
Measure the time for the voltage to decay by waiting for the I/O line to go low.
So something like this.
I then tried various flavors of Timers or Loopers and doing a digitalread of the QTR pin with no results.
The fact says:
With a strong reflectance, the decay time can be as low as a few microseconds; with no reflectance, the decay time can be up to a few milliseconds. The exact time of the decay depends on your microcontroller’s I/O line characteristics.
The LOOPER seemed to be capable of a couple hundred loops per millisecond. Is the DigitalRead fast enough to catch a decay of 120us ? They mentioned that was about the average decay for a black background as opposed to a white background that could take up to 2.5 ms.
Any suggestions ?
Thanks !
The faq says to:
Set the I/O line to an output and drive it high.
Allow at least 10 μs for the sensor output to rise.
Make the I/O line an input (high impedance).
Measure the time for the voltage to decay by waiting for the I/O line to go low.
So something like this.
B4X:
Sub Init_QTR
QTR.Initialize(dp.D1,QTR.MODE_OUTPUT)
QTR.DigitalWrite(True)
Init_Time = Micros
QTR_Flag = False
' DelayMicroseconds(10) <<< Didn't think I needed this tried with and without it.
QTR.Initialize(dp.D1,QTR.MODE_INPUT_PULLUP) <<< Will this even work ?
End Sub
I then tried various flavors of Timers or Loopers and doing a digitalread of the QTR pin with no results.
The fact says:
With a strong reflectance, the decay time can be as low as a few microseconds; with no reflectance, the decay time can be up to a few milliseconds. The exact time of the decay depends on your microcontroller’s I/O line characteristics.
The LOOPER seemed to be capable of a couple hundred loops per millisecond. Is the DigitalRead fast enough to catch a decay of 120us ? They mentioned that was about the average decay for a black background as opposed to a white background that could take up to 2.5 ms.
Any suggestions ?
Thanks !