Microcontroller questions

Discussion in 'Embedded Systems and Microcontrollers' started by FightingDrag, Apr 8, 2012.

  1. FightingDrag

    Thread Starter New Member

    Jan 30, 2011
    3
    0
    Hi there!
    So, i have only gone through a semester of a robotic class (using a microcontroller) was a BAD student (and i REALLY regret it since the class is no longer being held) Well, i currently have a invention on the lab table, and a microcontroller would wrap up everything nicely. the ISSUE is that my original plan will not work since a Arduino lillypad can only handle 5 volts, and there is a requirement of 3-4 RGB LED's for the full capabilitys to be released.

    So, my questions:

    1. (this is to clarify, im pretty sure this is a yes) a Microcontroller can be used to vary the "flow" of voltage. (changing the intensity of a LED light)
    Is it posible to CODE a color, changing to a different color? to go more advanced, is it able to code down a "Timeline" to change back and fourth between colors (like coreography) and change between a fade, a strobe, and a flash. I BELIEVE this is all a yes, but, i would LOVE some in-depth explanation.

    The IDEA is to use a microcontroller to change the flow of power (i believe its voltage) to change a RGB led to any color, and any intensity.
    2. RGB LED's as i am aware, have all RED, GREEN, and BLUE in 1 LED. and can change the voltage as wanted between all 3, individually to create different colors. so my question is, do you measure each R,G,and B, as a seperate LED? or does it allways take the same voltage?

    3. Since the idea of using a lillypad probably will not work, i need to find out how hard it is to build your own circuitboard. granted, the maximum size that i can have everything is a diameter of about 4 inches.

    4. do you need resistors and other things in work with a microcontroller?

    5. whats the highest electrical output for a microcontroller? (yes, i am aware you can go as high as you want with computing, but i need to find something that can do everything i need in the most compact capability)

    gona go look on wikipedia more in a bit, but i find human correspondance is allways nice to throw ideas back and fourth, thus i ask these questions here.

    Thanks for reading!!
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,415
    3,354
    1. You can control the power into a device by varying the current or voltage.
    What you need to do is to control the intensity of each colour independently.

    2. The easiest way to accomplish this with a microcontroller (MCU) is to vary the length of time the LED is turn on using pulse width modulation (PWM).

    3. With SMD, MCU and support circuitry can be very compact, less than 1 sq cm.

    4. You can add all sorts of components including resistors, capacitors, diodes, transistors, etc to add functionality to a MCU and that do not require a lot of additional space.

    5. A MCU can control any high voltage as needed. Again the additional space required does not have to be large.
     
  3. BillO

    Well-Known Member

    Nov 24, 2008
    985
    136
    Do a google search for "OMS Mini-328".

    It might be just what you are after.

    They are less than .75" x 1.25".
     
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Microchip has an application note entitled "Software PWM Generation for LED Dimming and RGB Color Applications." I suspect you may want to give it a hard look.

    Find it here. Download and install it, and inside you will find the actual app note as a pdf.
     
  5. vpoko

    Member

    Jan 5, 2012
    258
    47
    The output pins of the MCU are always at the same voltage relative to ground (or to the supply voltage, depending on whether the pin is low or high), but you don't need to vary the voltage to vary the intensity of the LED. Varying the current (by changing the resistance while the voltage stays the same) would work, and so does pulsing the signal, which is the easiest method to implement. The duty cycle (% of the time that the pin is "on" - whether high relative to ground or low relative to the supply voltage, more on that below) will affect the brightness of the LED.

    By connecting the leads of an LED to 3 pins, with the last lead either going to ground or +5V, you can mix red, green, and blue to make any color. Note that there are two kinds of RGB LED's, common anode and common cathode. With common anode LED's, you connect the anode to the +5V pin, and then set the individual pins low to activate that color. The duty cycle in this case represents the % of time the pin is low. With common cathode LED's, you connect the cathode to ground and set the individual pins high to turn on the appropriate color. In this case, duty cycle represents the % of time the pin is high.

    Don't forget resistors between each output pin and the LED (a single resistor connected to the common anode/cathode is *not* sufficient, and that leg actually doesn't need a resistor). You should calculate how much total current you're going to draw at maximum (from all pins combined) and check it against the MCU's ability to source or sink that much current. You can use resistors with more resistance to reduce the current drawn, but more resistance will dim your LED's. If you do want more current than the MCU can apply, you will need to add transistors to the mix in order to power the LED's from a source other than the MCU. Also, if you need more pins than the MCU can provide, you can use a multiplexer.

    An Arduino Lilypad should work fine for what you're looking to do.
     
    Last edited: Apr 8, 2012
  6. FightingDrag

    Thread Starter New Member

    Jan 30, 2011
    3
    0
    I am SO still learning.

    So, i can use a lillypad, and change the colors using a current change, and not voltage?

    If i end up doing this from scratch, i will be using SMD

    Why do i need resistors on all LED's?

    I guess i should just kinda throw out everything im doing on this, and get ideas and tips. last night after i posted this i happened to run into a computer science major who is a friend of mine, and we had a nice long chat.
     
  7. MrChips

    Moderator

    Oct 2, 2009
    12,415
    3,354
    Even if you use PWM you should use a current limiting resistor.
    If you don't and for some reason your PWM goes to 100% your LEDs will be toast.
     
  8. vpoko

    Member

    Jan 5, 2012
    258
    47
    You're actually using PWM (pulse width modulation). The voltage doesn't vary - it's always 5V, the current doesn't vary - it's determined by the resistors you use, but the duty cycle (% of the time the LED is on) determines brightness. You're basically blinking the LED very quickly, much quicker than is perceptible, but the effect is to dim/brighten it depending on how much time it spends on vs off.

    Edit: I realized my explanation here is wrong and PWM does technically impact the current since current is joules-per-second, but what I mean to say is that you're not varying the resistance to vary the current, you're pulsing a full power signal on and off very quickly.

    I'm not sure what your soldering skills are like, but SMD components are very hard to work with unless you have access to pick-and-place equipment. It's not impossible and skilled people can solder SMD components by hand, but it's definitely outside my abilities.

    MrChips already answered this but I will reiterate, it's so you don't blow out your LED's and, even worse, the pins on your MCU. LED's don't limit current, so only using an LED is like creating a short circuit to the ground. The LED might not burn out right away, but it will have a very short life otherwise.
     
    Last edited: Apr 9, 2012
  9. BillO

    Well-Known Member

    Nov 24, 2008
    985
    136
  10. FightingDrag

    Thread Starter New Member

    Jan 30, 2011
    3
    0
    thats actually exactly what i am doing, just with 4 LED's instead of one.

    I just had a friend over, and we did some work, but he isent a "electrical engineer" (his words) so he doesent know how to do the number crunching, but this is the schematic we came up with:

    http://s48.photobucket.com/albums/f212/FightingDrag/?action=view&current=schematic.jpg


    The LED i decided to run with, since this is a performance tool, and doesent need to cast light, just generate a point of visible light, is this:
    http://www.superbrightleds.com/moreinfo/component-leds/5mm-rgb-clear-tricolor-led-wide-angle/977/

    How would i do the reverse number crunching to figure out what resistors and transistors i need to use?

    The other thing, is i want to be able to use the best power, while still keeping the LED's with a good life length.
    and second, is this schematic posible?
    TY for all the help guys
     
Loading...