Hi,
I’m using the qtr-rc sensor with a pic micro so I have to write my own code. I just need some clarification from the application note.
the procedure is listed as
Set the I/O line to an output and drive it high
Allow at least 10 us for the 10 nF capacitor to charge
Make the I/O line an input (high impedance)
Measure the time for the capacitor to discharge by waiting for the
I/O line to go low
In 1. is this referring to the vin on the sensor from a pin on the micro? I have seen in another post that this can be tied to the 5v. Which is how I wish to connect it. So step 1 becomes redundant does it?
And could you explain how the capacitor discharges in the circuit. Is it triggered by setting the io pin connected to out on the sensor to high Z input?
The QTR-RC sensors use a single I/O line connected to out to charge the capacitor then monitor it as it discharges. Vin can be at 5V. Step 1 is about setting that I/O line to an output and driving it high, so it is not redundant, and step 3 is about setting to an input, so the answer to your second question is yes.
-Paul
Thanks Paul for your quick reply.
That is easy enough to implement but I was a little puzzled at how this would work by the circuit.
I wouldn’t mind understanding how the circuit works as I’m sure it would help at some later point.
Okay, did you look over circuit for the sensor? I do not really know what more to say than this: you charge up the capacitor with current from your I/O line, then (with the I/O line acting as an high-Z input) the charge flows through the phototransistor to ground. The more light there is, the faster the capacitor can discharge.
Does the cap charge in 2 directions?
I thought it would charge through vin to ground. And then I guess that allows a high on io to charge it the other way and then discharge finally when the io is taken to high z input. Sorry for my ignorance. Is this the way it works?
I guess I should say that technically you are discharging the capacitor by presenting the high output, than letting it charge up across the potentiometer. But that really does not matter - a capacitor to ground acts almost exactly the same as a capacitor to Vin from the point of view of your microcontroller, since all it knows is the voltage on the out pin. (The only differences are the voltage you will get when initially powering up and potential for breaking if too much voltage is applied.) Sorry if that confused you! Does it make more sense now?
I’m still lost with the circuit workings but at least I can get it working now I confirmed the 4 steps are the same whether you supply constant 5v to vin or it is supplied on demand from a second io pin.
That is all that is important for now. Maybe as I play with the electronics a bit more it will come to me.
Thanks for your help.
Hello,
If it is still not making sense to you, and can not ask a specific question, you probably just need to go review (?) some basic electronics: Kirchhoff’s laws, V=IR, Q=CV and so on. Anyway, good luck getting it to work!
I have understood that correctly. Vin is a constant voltage, i.e. the LED lights up constantly. Now you set the pin at OUT to a higher potential than Vin, so that the capacitor has a higher potential at Out than at Vin, i.e. it is charged. If you now set the Out pin back to LOW or extremely high impedance, the capacitor can only discharge via the phototransistor until the potential of the capacitor is equalised on both sides. Logically, the resistance of the phototransistor determines the discharge speed depending on how much light is reflected.
It is important to note that the high pulse at the output must have a higher potential than Vin. Low must have an extremely high impedance so that the discharge current across it is negligible and the discharge current across the phototransistor is dominant.
I would be the happiest man on earth if you could confirm or improve this again. I’m currently writing a paper for my dissertation and I wanted to describe the principle of operation.
If you wish I can also open a new discussion for this Topic.
No, this is incorrect. The logic high voltage to charge the capacitor can be at the same voltage as VIN which is how our robots with reflectance sensors, like the 3pi+ and Zumo, operate. Even a lower voltage could be okay as long as it is consistent.
Ideally yes. You want as much of the charge to have to pass through the phototransistor as possible since that should make it easier to see when the sensor is receiving a lot of IR light versus just a little.