Society of Robots - Robot Forum
Electronics => Electronics => Topic started by: airman00 on October 03, 2007, 04:23:16 PM
-
When using the pot command in PIC basic ( to read the resistance) you use a .1 uF capacitor like so
(http://www.rentron.com/PicBasic/CDS.GIF)
I was wondering what would happen if I used a 1uF capacitor instead.
Also, if I had two photoresistors would I need two capacitors or could I just share one .1uF capacitor between the two?
Explanation of Pot Command
The POT command charges the capacitor through the CDS photocell, and then measures the time it takes for the capacitor to discharge. The resulting value is then used to adjust the IR LED output power to compensate for changing light levels present on the infrared detector module. Note: You can also us the RCTIME command with minor adjustments to the light-sensing circuit.
and another explanation can be found here http://www.melabs.com/resources/pbcmanual/ (http://www.melabs.com/resources/pbcmanual/)
-
because the pic will be pulsing port a0 it only lets the cap charge to a certain amount anyway, i would assume that because the discharge time varies on a 0.1uf capacitor then exchanging this for a larger capacitor would produce similar or the same results.
this is quite an interesting concept that acts as an external a/d converter, the detector charges up the cap and then the mcu detects how long it takes for the cap to discharge therefore producing a pwm type signal, that needs to be modulated in software, presumably the brighter light that falls on the detector, the more charge is in the capacitor and the longer it takes to discharge through the mcu, the darker the light, not as much charge will be stored. this requires the port pin to go high for a specified amount of time (Charging period) and then go into input mode until there is no charge left.
-
Im tempted to run a few experiments with something similar to this:
(http://www.uk-robotics.co.uk/misc/a2dpwm1.jpg)
-
So changing the cap would change the response time . . . a bigger cap would increase that time . . . but hey, caps are easy to get so try it!
But I prefer to tweak in software since it saves me soldering time . . .
-
Hey guys
How can I calculate how long it takes to charge that capacitor and how long it takes to discharge( basically how long it takes for the whole pot command to run)
Any help .
Please include the formula and answer with your reply.
I am using a .1uF capacitor with a resistance of ~50 ohms connected between the microcontroller and the capacitor.
Please help!
-
the very first link from google:
http://hyperphysics.phy-astr.gsu.edu/hbase/electric/capdis.html
(its the very bottom equation)
you might find this helpful too:
http://hyperphysics.phy-astr.gsu.edu/hbase/electric/capdis.html#c2
(use the capacitor datasheet to look up R)