Shop OBEX P1 Docs P2 Docs Learn Events
Urgent help with transistor use — Parallax Forums

Urgent help with transistor use

NB_NesquikNB_Nesquik Posts: 35
edited 2012-03-19 20:39 in BASIC Stamp
Hello,

I am new to usung microcontrollers and i have a project i need help with. I am using a BASIC Stamp Homework Board that came in my Whats a Microcontroller Activity Kit. I am also using a piezo speaker and 5mm 3-3.2V 12000 to 15000 MCD LEDS. I have access to all of the electronics that come with the Whats a Microcontroller Kit as well as the Boe-Bot refresher kit. The reason why I am writting is because I do not know how exactally to wire the LEDs on my board. I want to beable to controll 17 of the 5mm LEDs with one I/O pin as well as have 5 other sets of three LEDs, each controlled with an I/O pin. I do not know how to wire up the set so that the LEDs shine at their maximum brightness, while not destroying my board. I have done some research and found that some sources say to use transistors to increase the amount of power to the LEDs with only a small amount of power coming from the I/O pin and the board's Vdd. If you could help with what types of resistors as well as the transistors or other electronics, that would help a lot. Also, i have a time crunch for this project, so the faster we can get this working, the better.

Sincearlly,
NB_Nesquik

PS: When the project is fully assembled, the LEDs will be attached to the board with jumper wires so they can reach farther.

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-04 16:18
    First things first. What kind of voltage is available on Vin? Is it regulated? What is the current rating of your LEDs?

    -Phil
  • NB_NesquikNB_Nesquik Posts: 35
    edited 2012-03-04 20:31
    board 1.JPG
    board 2.JPG
    Honestly, I dont know what Vin means, if its regulated, or its voltage. The board is a standard BASIC Stamp Homework Board, Rev E. The current rating for the LEDs is 20mA. I have attached a picture of my simple set up of the prototype circuit. The final design will be like the one in the picture, except the the center clear LED will be the group of 17 LEDs and the colored LEDs will be the groups of 3 LEDs. The program is designed to play a song and flash the LEDs to the music. The program is very similar to the Christmas Caroling Device made in the Stamps in Class Forum.
    960 x 720 - 287K
    960 x 720 - 282K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-04 22:07
    Since you're using a 9V battery, Vin is nominally 9V; but it will decrease as the battery discharges, so it's unregulated. What other DC voltage sources do you have available, if any?

    Also, you mentioned that the LEDs have a forward voltage of 3.0 - 3.2V. Is that just for the 17 center ones, which I presume to be blue or white? What colors are the other LEDs? If they're not blue or white, they will have lower forward voltages.

    -Phil
  • NB_NesquikNB_Nesquik Posts: 35
    edited 2012-03-05 09:39
    The only other DC voltage i would have would be any other type of standard battery.

    All of the LEDs im using are white 3.0 - 3.2V. the outside ones will be the same as the center 17.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-05 11:19
    Do you have access to additional components, such as diodes, transistors, and a variety of resistor values?

    -Phil
  • NB_NesquikNB_Nesquik Posts: 35
    edited 2012-03-05 12:04
    I have access to electronics that are available at Radio Shack or other big name stores. Like i said before, I have all of the electronics from the Whats a Microcontroller Kit and Boe-Bot refresher pack. The lower the costs, the better. And since i have a time crunch, the extra electronics should be readily available at stores.
  • Scott4Scott4 Posts: 45
    edited 2012-03-05 12:54
    I think most of the more experienced people on this forum will agree that it is all about learning and helping not solving your issues for you. I suggest you start your study with these resources (available on the Stamp website):

    N&V column "Silicon Steroids for the Stamp" #6 (.pdf)
    StampWorks Manual starting at page 130
    Data sheet for ULN2803A (you may need some of these depending on the current required for your LEDs)

    These will give you some ideas about how to expand the the outputs for the 17 LEDs and a way to drive them.

    As mentioned earlier you will have to:
    1. Determine the current required for each LED.
    2. Decide what voltage will power the LEDs in order to size the current limiting resistors.

    -Scott
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-05 13:20
    Scott, given the OP's available hardware resources, it's probably going require a more creative solution. Here's a circuit I came up with for driving the three-LED clusters:

    attachment.php?attachmentid=90303&d=1330982343

    NB_Nesquik, driving three or more 3V LEDs is going to be a little awkward with just a 9V supply. You should go to RadioShack and get either a 12V wall transformer or a battery holder that holds eight AA cells. You will use this to power your LEDs, leaving the 9V battery to power the BASIC Stamp. The transistors can be any general-purpose NPN, such as 2N3904, PN2222, 2N4401, etc. If you don't have access to a 33-ohm resistor, put three 100-ohm resistors in parallel, or three 10-ohm resistors in series.

    Here's how the circuit works:
    1. When the Stamp pin is high it drives current into the base of Q1, which turns on the LED.
    2. The current that flows though the LED will be nearly equal to the current in the 33-ohm emitter resistor.
    3. As the voltage across this resistor approaches 0.6V, Q2 begins to turn on, which starts to pull down the base of Q1, in an attempt to turn it off.
    4. This process continues until the voltage across the 33-ohm resistor is just slightly above 0.6V, at which point equilibrium is reached.
    5. 0.6V / 33 ohms = 18 mA.

    IOW, the two transistors not only drive the LEDs, but form a current regulator that limits the current through them.

    Now, that handles the case of three LEDs. I'll let you try to figure out how to handle the 17. I'm here to help if you get stuck.

    -Phil
    487 x 360 - 4K
  • NB_NesquikNB_Nesquik Posts: 35
    edited 2012-03-05 16:52
    will I need two transistors for each of the groups of 3 LEDs as well as the two for the 17?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-05 17:19
    Yes. You may need an extra pair for the 17. But try it with one group first to make sure you understand, and are comfortable with, the circuit.

    -Phil
  • NB_NesquikNB_Nesquik Posts: 35
    edited 2012-03-05 18:10
    Ok, I dont have the parts yet, but for the group of 17, will the set up be like the 3 LED? Will I just need to add more LEDs? Or should I connect sets of 3 LEDs and one set of 2 LEDs in parallel? Or will the set of 2 LEDs need their own group of transistors? I assume that I would only need on 12V power supply and connect all of the groups to it in parallel
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-05 19:04
    With a 12V supply, you can't put more than three LEDs in series. But you can run them in series-parallel, e.g. three groups of three (plus extra resistors) on one pair of transistors, plus three groups of three (one hidden or replaced by a resistor) on another pair.

    -Phil
  • NB_NesquikNB_Nesquik Posts: 35
    edited 2012-03-06 19:51
    Is there any way to amplify the piezo speaker without using an op-amp? Could i use a similar circuit to the one that drives the LEDs and still get the piezo speaker to be louder?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-06 20:35
    Is there any way to amplify the piezo speaker ... ?

    Not really. I tried driving it with 10V, single-ended and with 5V push-pull, without any discernible difference in volume, compared to the normal BASIC Stamp setup. It's easier with a magnetic speaker.

    -Phil
  • NB_NesquikNB_Nesquik Posts: 35
    edited 2012-03-19 20:27
    Phil,
    Thank you for all of your help. The project worked great. I was wondering, could you explain how you made your calculations, or if there are any really good websites explaining how to use transistor in simple language for beginners. Im thinking of using similar circuits to this one but with different types of LEDs and transistors. If you could help me to understand how to calculate which transistors to use and other calculations, that would be great.
    Thanks so much,
    NB_Nesquik
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-19 20:39
    If you're interested in learning more about electronics and, in particular, transistor circuits, there is no better combination introduction/desk reference in the world than The Art of Electronics. It's a tad expensive, but worth every penny.

    -Phil
Sign In or Register to comment.