Shop OBEX P1 Docs P2 Docs Learn Events
BS2 RC Circuit switch? — Parallax Forums

BS2 RC Circuit switch?

JohnofWaxJohnofWax Posts: 3
edited 2009-07-27 02:47 in BASIC Stamp
First off, Thanks for taking the time to look at this. I'm pretty new to electronics, but this is getting extremely fun. If someone could point me in the right direction on this, it would be very much appreciated. Below is the circuit segment I'm working on now. I have 3 different modes in the BS2.
Solid Lights, Blinking Lights, Photoresistor Controlled (Light Sensitive lights).

The problem I'm having is that I would like to turn the RC portion off within the BS2, but still have functioning LEDs. This would allow for rapid blinking lights or slowly fading while blinking, but not constantly fading because of the position of the Cap.

The question I guess I have is... How can I have multiple circuits controlling the same LEDs, yet isolated from each other? I guess I need some kind of electronic switch action to change which circuit the LEDs are in? What kind of device could be used for this? This is probably newbie as all get out, but it's actually kicking my butt. confused.gif



concentrated.jpg


Thanks in advance!

Post Edited (JohnofWax) : 7/27/2009 12:07:19 AM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-07-27 00:51
    The usual way to control LEDs is to have the LEDs in the collector lead with the 220 Ohm resistor and ground the emitter of the transistor. You wouldn't need C1 in that case and the Stamp would be controlling the LEDs directly. That way, you could have 3 separate routines in the Stamp, one to turn the LEDs on and off, one to blink them at some rate, and the third adjusting the brightness using the PWM statement (see the PWM statement in the help file or Manual).
  • PrettybirdPrettybird Posts: 269
    edited 2009-07-27 00:52
    You can go with logic gates. You should learn·TTL (logic). You can do alot and even have chips that can replace circiuts. Lots of options. Just curious, why the 2 resistors in parallel? To cut resisance in 1/2?

    Post Edited (Prettybird) : 7/27/2009 12:59:27 AM GMT
  • JohnofWaxJohnofWax Posts: 3
    edited 2009-07-27 02:00
    2 100k resistors between the pin and the transistor was used on page 265 of the "Whats a Microcontroller?" Text. As it has been proven tried and true, I used that as a basis to see how the transistor works. It seems to work fine with only 1 resistor as well. As far as I can tell, its not hindering anything. Only using 1 100k resistor now.

    So This section has been changed to :
    con2.jpg

    Thanks Mike!
    I dont remember a mention of PWM command in "What's a Microcontroller?" so it didn't cross my mind. Time to crack open the Syntax and Reference Manual!
  • Mike GreenMike Green Posts: 23,101
    edited 2009-07-27 02:17
    You may find that 100K is too large. That sets the base current for the 2N3904 to (5V - 0.3V - 0.6V)/100K = roughly 40uA. A 2N3904 may have a current gain as high as 100 at that current which would cause 4mA of collector current to flow ... not much glow in the LEDs. I'd suggest using a 10K base resistor and providing each LED with its own current limiting resistor, say 330 Ohms.
  • JohnofWaxJohnofWax Posts: 3
    edited 2009-07-27 02:47
    Here's Figure 5.31, from page 356 in the Syntax & Reference Manual
    pwm.jpg



    So by the looks of things, I would need to tie a capacitor connected to ground between the 10k resistor and the 2N3904 for the PWM command to fade my LEDs, but regular High/Low signals would not effect brightness / discharge time?


    You rock Mike! That's exactly what I needed. It moved the cap away from the LEDs (as required) and allows me to use 1 pin to fade or steady blink (and at variable speeds, too) the leds.
    I had to quit messing with the schematic stuff and rip everything off my Board of Education, but I physically made what was needed and now I can visualize it into the schematic for the big picture.

    Thanks again for the help!

    Only problem I have now is my LED is on on LOW and off on HIGH, lol.

    At any rate, the LED setup that was on the first post now looks like so:
    new.jpg

    Now using HIGH / LOW commands for on/off (close enough to instantly), and PWM for 'fading' effect. with this simple get-up I should be able to duplicate it across pins and get a Tracer effect. sweet!

    Post Edited (JohnofWax) : 7/27/2009 4:38:11 AM GMT
Sign In or Register to comment.