I cant find a suitable microcontroller for multiple LEDS

Discussion in 'Embedded Systems and Microcontrollers' started by AnasMalas, Nov 27, 2015.

  1. AnasMalas

    Thread Starter Member

    Nov 27, 2015
    66
    10
    Hello! I am Anas Malas, first time poster that lives in the United Arab Emirates. I was born on the 8th of January of 2000 in my home country, Jordan. Currently i am completing my IGCSE with maths, physics, computer, english, chemistry and biology on year 11. I plan to be an electrical engineer.
    I love electronics, i like to work on them. recently one of my physics projects surprised my teacher so much that he didnt believe i did it with no help, he said it was the best he has seen in his career as a teacher, that is 27 years long! i like to believe that part of it is that components here are not readily available. what you could find however are knockoffs that cost multiples of 5 that of the original part, such as a 2n2222 transistor that cost 3$ but released some of the industry's most beloved blue tined smoke at 3 volts 18 mA driving an LED on collector with 6 volts feeding a 1 KOhm resistor connected to the base! also in this age salvaging electronics isnt that useful especially with SMD components

    As i mentioned, i am studying in year 11 right now, but plan on changing my school to complete my A/As levels because of my hopeless physics teacher, and i would like to give all my friends some sort of a gift just for them to remember me, because there is the possibility of never meeting them again.

    I like to do everything that is related with DIY. I know about electronics, about woodworking, about programming(C++, VBasic), about arduino, RC airplanes, and even about glass cutting! i would like to make a wooden enclosure, engrave their names in it, spray paint it, and add LEDs all over it (No more than 15 though)
    I have never tried using a microcontroller, so this will be my first project, i have until the end of may to get done with it.

    I already ordered some powerbanks in bulk from a Chinese place for 1.5 dollars each (including shipping) which i plan to use for powering the thing, where i would connect the usb output to the circuit in series with a switch, extend the micro usb input out the case for charging. and replacing the little hopeless SMD LEDs with others through transistors to the outer case to show low battery.

    one of the problems is that i have no idea about the electrical noise of the powerbank or if it gives a clean 5 volts. I am not even sure that it gives 5 volts as it shuts down each time i try probing it with my multimeter(it does work with usb devices though).... I also do not have an oscilloscope to see the wave form because i can only buy so much with all these hobbies...

    For the LEDs, most of them will be independently controlled, but some will be paralleled (for one on the top and a matching one at the bottom), they will be of different current ratings and colors but nothing more than 30 mA. I need to do dimming (possibly by pwm), i am open to multiplexing if it can accomplish what i need although i dont really understand it. but if i could use such a method to make my life easier i sure will learn it.

    with all this in mind, what microprocessor would you recommend? but please dont recommend something that is 20$ because i have a limited budget and will have to make about 15 of them.
    also i will need to ship them and some quality LEDs from somewhere in the world, i certainly am not going to find anything locally. so if you could recommend any sort of a good website or shop that i could buy from that would be much appreciated. Also about the programming could i use an aduino uno to program the thing? or should i buy a separate programmer? (again, budget)
    I know that i just wrote the longest essay you will ever read but i want you to understand exactly what i am doing. please try helping me even if you could just guide me in the correct direction for looking for the parts. the manufacturer websites are rather hard to navigate as i dont know the technicalities of microprocessors that well.

    also i am very sorry if a similar post is already present. but i didnt find any. Thank you.
     
    RRITESH KAKKAR likes this.
  2. absf

    Senior Member

    Dec 29, 2010
    1,492
    372
    You are going to make 15 name plaques each containing a max. of 15 LEDs, right?

    What are you going to display on the LEDs? Running the LED in a circle, flashing a pattern, or from low brightness to high brightness..... If the pattern is not too complicated, you can design with 555 or 4017 + some simple logic gates. But if the display is complicated, you can always use a PIC or AVR with a ICSP programmer. If you are familiar with Arduino, you can use it too to simplify the design.

    Allen
     
    Last edited: Nov 27, 2015
  3. AnasMalas

    Thread Starter Member

    Nov 27, 2015
    66
    10
    Using arduino would increase costs which I dont want. They are 15 pieces each containing 15 LEDs.
    I am not actually sure if I just want simple animations or if I would like to have an advanced setup. Here is an example I just thought about:
    A complex design where LEDs surrounding the person's name would fade on and off, but every 25 seconds they would stay on and then "decay" randomly for 1 sec before repeating the cycle . While other LEDs placed in other locations would flash fastly and randomly. Those will have say a paper or piece of acrylic on them which would make it appear as that a word or picture is lighting up.

    I just want to make it feel creative and new. I dont want it to seem like how some of the Chinese toys are. I am open to any nice ideas. And if they simplify my work and get me a better result that would be much appreciated.
     
  4. AnasMalas

    Thread Starter Member

    Nov 27, 2015
    66
    10
    My problem is that I do not know which micro controller to use. I want to get involved with them because later I want to do more advanced projects (3D printer is one!) so I think a nice microcontroller that I program will be a good training for me.

    Ive looked in microchips technology, Texas instruments and in Atmel. But due to my inexperience I couldn't find a suitable chip which I know is present .....

    Oh, and I am also open to using multiple chips as long as they can be synchronized and dont cost a total that exceeds 6$
     
  5. sirch2

    Well-Known Member

    Jan 21, 2013
    1,008
    351
    The simplest implementation, given that you want to use a microcontroller would be to drive the LEDS directly from the MCU, there are quite a few low cost options (e.g. ATmega 328, no doubt a PIC guy will be along shortly to suggest a PIC alternative) with enough pins to drive 15 LEDs. You will need to buy a programmer, OR for the ATmega 328, you can buy 1 Arduino, develop the code on that and then use the Arduino as a programmer to program bare 328 chips.
     
  6. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,388
    1,605
    Seems you want a micro controller. They are quite useful devices, and very inexpensive too. I always recommend starting with a development kit, because you have these problems to solve to get even a LED to turn on:

    - the hardware must be good.
    - the software must be good.
    - the program must be good
    - the programmer must be good

    If you buy tested good hardware with a tutorial program you will hit all the marks.

    I work with Microchip products both for myself and professionally. They sell just such an assortment (programmer and development board) for $65USD. I believe they ship direct to the UAE.

    http://www.microchipdirect.com/productsearch.aspx?keywords=DV164130

    Once you learn these devices you can toss the training wheels and just buy the micro controller itself. They sell for about $2USD each.

    Those chips are the minimum you need, going a little bigger can be an advantage for debugging.
     
  7. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,012
    Some times less is more. That is a heck of a post with mostly information that does not pertain to your issue. I got bored in the first few sentences. ;)

    I will go by your subject line, assuming all you really want to do is control LEDs.

    Almost any mcu can drive multiple LEDs. Lots if you get creative. One method is to use CharliePlexing. Another is you can use shift registers. You can control lots of LEDs with just 2 pins using shift registers.

    Most manufacturers have parametric searches that will let you select a chip based on your needs.

    http://www.microchip.com/ParamChartSearch/chart.aspx?branchID=1013

    I prefer the microchip 18f family. If you go with microchip then you will need a programmer. Be sure to get a microchip one and not a 3rd party clone or kit.
     
    Last edited: Nov 27, 2015
  8. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,012
    You want to build a 3D printer and you are worried about cost? Those two don't got together.
     
  9. sirch2

    Well-Known Member

    Jan 21, 2013
    1,008
    351
    Nothing wrong with the kid having ambition, he's not saying he wants to do that tomorrow, if that his is goal and this is the start of his journey than good for him
     
  10. AnasMalas

    Thread Starter Member

    Nov 27, 2015
    66
    10
    I am worried about the cost of this project. I know I wrote a very long post that was boring to read, but I mentioned that it is because I am makimg lots of these I am worries about cost. If was doing only one I could buy a part for 60$, which is what I want to do with the 3D printer. But that project will not be now.
     
  11. AnasMalas

    Thread Starter Member

    Nov 27, 2015
    66
    10
    Thanks for everyone for the advice. Ill look into every post you wrote for me! Have a good day ;)
     
  12. AnasMalas

    Thread Starter Member

    Nov 27, 2015
    66
    10
    I checked the ATmega328 It seemed to check all the marks ☑ but I found out it had only 6 pwm pins. So how could I use it to directly drive 15 LEDs? Also does charlieplixing work with PWM? Does it give you full independent control over each LED?
     
  13. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    You might consider a simple Charlieplexed display using something like an 8-pin PIC12F1572 ($0.83), PIC12F1501 ($0.93), PIC12F629 ($1.11), PIC12F635 ($1.31), or PIC12F683 ($1.42). You would need a programmer, too.

    Cheerful regards, Mike

     
    Last edited: Nov 27, 2015
    absf likes this.
  14. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,388
    1,605
    PWM is useful when dimming LEDs. It is not needed if you. Are just turning them on and off.

    Charlieplexing is great for controlling more LEDs than pins available. The code can get complicated rather quickly if you want more than one light on at the same time.

    For a beginners project I would stick to one pin controlling one LED. Any pin capable of being an output can do that.
     
  15. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    It may not be as difficult as you imagine, Ernie. Please check out this post; 'Knight Rider' style light chaser. Making that circuit display more than one LED at a time is just a matter of setting up a bit array of '0's and '1's, one for each LED, and scanning or refreshing the display from that array at a much higher frequency. That said, I admit implementing PWM on a Charlieplexed array will certainly test your mettle (grin)...
     
    Last edited: Nov 27, 2015
  16. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,012

    CharliePlexing does give you your PWM. It does not need special PWM pins. The idea of CharilePlexing is that you can have 3 states to an output pin. High, low and high impedance. The LEDs are not all really on at the same time much like in PWM.

    And as long as you are not worrying about power consumption, you don't need PWM anyway to drive LEDs. Unless you want them to blink of course or really require CharliePlexing because lots of LEDs and few pins.. You can just use current limiting resistors. And for lots of leds, you can make use of a shift register as I mentioned then you just need 2 pins. And the code and the wiring are all straight forward. The only issue is to turn off or on an individual LED, you will need to send out data for the state of all of your LEDs.

    And you are talking individual cost, you can get mcus far cheaper than your $6 US. Probably less than a $1 US. I use the 18f pics as supposedly they are a bit better for C programming. They are a bit more expensive. But much cheaper family of chips can me bought.

    Now for your 3D printer you will more than likely need a more powerful chip and your cost will go up.
     
  17. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    Please forgive me but could I impose on you to explain how it does that, please?
     
  18. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,012
    Each LED is only turned on one at a time so in essence it is like driving and LED with PWM.
     
  19. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,388
    1,605
    Keeping in mind I do NOT recommend this for our new friend here...

    Charlieplexing (cp from now on) lets you turn one light on in an array. Should you wish more than one light on a time you need to constantly refresh each light on in turn quickly so persistence of vision fools your eye into seeing them all on at once.

    That implies some fast routine just to update the display. If you then make the display N times faster you have the ability to PWM the display into N brightness levels.
     
  20. AnasMalas

    Thread Starter Member

    Nov 27, 2015
    66
    10
    i would want no less than 6 LEDs on at the same time. i think that crosses CP off my list? i will have a look at shift registers, but i just want to confirm one thing: if i later decide to do CP, my idea was to make the turning on each LED its separate class or code block, so that if i want to turn an LED on i would just call that block. that is how i do a similar thing in C++, is this correct practice using MCU?
     
Loading...