Noob RC Timer question
Robert Konigsberg
Posts: 5
Hello,
I'm just getting started with the Basic Stamp by following the experiments in the StampWorks manual. My knowledge of electronics, in and of itself, is fairly limited. Experiment #5, the LED graph, uses an RC Timer circuit. I've been reading a fair bit and remembering bits from high school physics, but am stuck understanding how it works.
I understand how a capacitor works, sort of, and understand that it gets discharged with HIGH15, and then gets recharged, and RCTIME is used to identify how long it takes to recharge the capacitor. I understand that the potentiometer is a variable resistor.
Here are my questions:
1. How does 'HIGH PotPin' discharge the capacitor?
2. Why is the additional 220 ohm resistor required?
3. How is it possible that pin 15 can be used to both discharge the capacitor, AND calculate the charging time?
4. How does the potentiometer change the charging time?
I realize some of this may be fundamental -- any help would be appreciated, even other documents.
I will also admit that I have little understanding of the relationship between current and voltage, if that sort of fundamental material is available in the Basic Stamp documents, I have not seen it yet.
Thanks, I know this is alot.
Robert
I'm just getting started with the Basic Stamp by following the experiments in the StampWorks manual. My knowledge of electronics, in and of itself, is fairly limited. Experiment #5, the LED graph, uses an RC Timer circuit. I've been reading a fair bit and remembering bits from high school physics, but am stuck understanding how it works.
I understand how a capacitor works, sort of, and understand that it gets discharged with HIGH15, and then gets recharged, and RCTIME is used to identify how long it takes to recharge the capacitor. I understand that the potentiometer is a variable resistor.
Here are my questions:
1. How does 'HIGH PotPin' discharge the capacitor?
2. Why is the additional 220 ohm resistor required?
3. How is it possible that pin 15 can be used to both discharge the capacitor, AND calculate the charging time?
4. How does the potentiometer change the charging time?
I realize some of this may be fundamental -- any help would be appreciated, even other documents.
I will also admit that I have little understanding of the relationship between current and voltage, if that sort of fundamental material is available in the Basic Stamp documents, I have not seen it yet.
Thanks, I know this is alot.
Robert
Comments
2) The 220 protects the pin in the event you turn the pot wiper all the way to ground.· When the control pin goes high this would be a direct short without the 220.
3) As with nearly any microcontroller, the BASIC Stamp I/O pins can change state (from output to input or the other way).· After the cap is discharged the RCTIME instruction makes the pin an input and starts the timer.
4) That's electronics 101: TC (time constant) = R x C.· It takes about five time constants to completely charge or discharge a capacitor.
You might want to pick up a copy of "Getting Started in Electronics" by Forrest M Mims, as well as our own "What's A Microcontroller?" by Andy Lindsey.· Both will give you a lot of background that will make your StampWorks experience more rewarding.
Good luck, and have fun!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Three more questions, if I may, and then I'll be done:
1. I'm all for protecting the pin, yay! I'd like to use a different resistor and see how it impacts the circuit. Just to make sure I don't burn something out: larger resistor = definitely won't burn anything out?
2. The code in the book used */ $005F as the way to convert the RCTIME value to a range of 0-255. I, however, needed to use $0042. Is this merely because, say, I'm using a B2SE, or because my potentiometer has an unexpected range, or perhaps because I used the wrong resistor (unlikely, I think).
3. Is this an appropriate forum for my Electroncis 101 questions? If not, can you point me to another? I can easily segment my questions between the two.
Thanks very much and Happy New Year! [noparse]:)[/noparse]
2. This is due to component variances -- completely normal and nothing to worry about.
3. General electronics questions should be posted in the Sandbox forum.
Happy New Year to you too.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Changing that value simply changes the effective 'scaling' of your value returned by the instruction. If you look at the help file for RCTIME, you'll see the following information:
BS2, BS2e, BS2pe : 2 µs
BS2sx: 0.8 µs
BS2p: 0.75 µs
BS2px: 0.75 µs
Consider this when you think about why scale would change ....
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
RClarke@Parallax.com
Yeah, I read that. My assumption was that the code was written for another controller that timed the charge differently. Thanks for pointing it out, tho, it's good to see that I'm not all thumbs. [noparse]:)[/noparse]
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
RClarke@Parallax.com