PDA

View Full Version : Noob RC Timer question



Robert Konigsberg
01-03-2006, 02:42 PM
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

Franklin
01-03-2006, 03:16 PM
Try some of this. http://www.play-hookey.com/dc_theory/ (this was just a quick search but there is more out there. Get the basics first then go for it.

Robert Konigsberg
01-03-2006, 03:18 PM
Thanks for the info... by "get the basics first then go for it" are you saying what I think is true, that is, I haven't got the basics? Yeah, I thought so too.

Jon Williams
01-03-2006, 11:16 PM
1) In the older version of the RCTIME circuits one side of the capacitor was tied to Vdd. By connecting the other side of the capacitor to Vdd (with HIGH X) the difference between the "plates" is eliminated, hence the capacitor is discharged.

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

Robert Konigsberg
01-04-2006, 12:01 AM
Jon and Franklin, both your responses have been very helpful! I've also been reading the O'Reilly book "Hardware Hacking for Geeks", and it points out how to measure circuits with a multimeter. Clearly measuring everything is probably a good way reinforce what's going on.

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! :)

Jon Williams
01-04-2006, 12:03 AM
1. A bigger resistor will provide more protection (more resistance = less current) but will have an impact on your RCTIME value because it's in the charge/discharge path of the capacitor when RCTIME is in play.

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

Ryan Clarke
01-04-2006, 12:07 AM
Robert,

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 (mailto:RClarke@Parallax.com)

Robert Konigsberg
01-04-2006, 12:11 AM
Ryan,

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. :)

Ryan Clarke
01-04-2006, 12:19 AM
What I was getting at (and you can see from Jon's post) is that you could determine if the scaling was due to timing (radically different) vs. +/- variance in parts - I was trying to help you deduce the anwswer yourself-

Ryan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support

RClarke@Parallax.com (mailto:RClarke@Parallax.com)

Robert Konigsberg
01-04-2006, 12:22 AM
Ah, I see! Still all thumbs, I see too.