+ Post New Thread
Results 1 to 14 of 14
  1. #1
    Member level 2
    Points: 410, Level: 4

    Join Date
    Nov 2011
    Location
    Denmark
    Posts
    45
    Helped
    2 / 2
    Points
    410
    Level
    4

    One PIC, a lot of LEDs to Pulse Width Modulate...

    Hi.

    I would like to use one PIC to control the PWM for let's say around 200 LEDs.
    The PIC should be able to adjust the brightness/PWM of each LED alltough time is not critical. All I want to do is to "dim led no. 63 5% somewhere around 5:00pm. If it gets 5:10pm thats fine too" No hurry.

    I dont think that I can find a PIC with that many PWM outputs so I need something else. I am looking for some kind of external IC that will provide the PWM to the connected LED. I would like the PIC to send a command (or set a voltage) on this external IC and have this IC deliver the correct PWM to the LED until it is told to otherwise.

    Any ideas ?

  2. #2
    Super Moderator
    Points: 50,045, Level: 54
    Achievements:
    7 years registered
    keith1200rs's Avatar
    Join Date
    Oct 2009
    Location
    Yorkshire, UK
    Posts
    10,877
    Helped
    2075 / 2075
    Points
    50,045
    Level
    54

    Re: One PIC, a lot of LEDs to Pulse Width Modulate...

    Have a look on Maxim's site for PWM LED drivers. They have quite a few, one of which can drive 24 LEDs.

    Http://www.maxim-ic.com/products/display/

    Keith
    I started life with nothing and I've still got most of it left. (Seasick Steve)



    •   AltAdvertisement

        
       

  3. #3
    Member level 2
    Points: 491, Level: 4

    Join Date
    May 2011
    Posts
    50
    Helped
    3 / 3
    Points
    491
    Level
    4

    Re: One PIC, a lot of LEDs to Pulse Width Modulate...

    Well, my idea is to use DEMUX's and you "refresh" the brightness of each LED one by one fast enough to pass unnoted by human eye. Got it?

    Iuri~



  4. #4
    Member level 2
    Points: 410, Level: 4

    Join Date
    Nov 2011
    Location
    Denmark
    Posts
    45
    Helped
    2 / 2
    Points
    410
    Level
    4

    Re: One PIC, a lot of LEDs to Pulse Width Modulate...

    Quote Originally Posted by Iuri View Post
    Well, my idea is to use DEMUX's and you "refresh" the brightness of each LED one by one fast enough to pass unnoted by human eye. Got it
    I don't think that would work with 200 LEDs. It would have to be a very very fast microcontroller...

    ---------- Post added at 11:14 ---------- Previous post was at 10:50 ----------

    @Keith

    I'm looking at maxim's site, but I am not sure what I am looking for...
    The driver should be able to maintain the correct PWM on its own and it should be controllable from the microcontroller so it needs some kind of interface/control pins.
    Does such a driver have a special name ? Are there any keywords I can google to learn more about such a driver ?



    •   AltAdvertisement

        
       

  5. #5
    Super Moderator
    Points: 50,045, Level: 54
    Achievements:
    7 years registered
    keith1200rs's Avatar
    Join Date
    Oct 2009
    Location
    Yorkshire, UK
    Posts
    10,877
    Helped
    2075 / 2075
    Points
    50,045
    Level
    54

    Re: One PIC, a lot of LEDs to Pulse Width Modulate...

    There a quite a lot to choose from. Have a look at the MAX6946 and similar devices. You need to be searching for LED PWM Driver, I think.

    Keith
    I started life with nothing and I've still got most of it left. (Seasick Steve)


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  6. #6
    Member level 2
    Points: 410, Level: 4

    Join Date
    Nov 2011
    Location
    Denmark
    Posts
    45
    Helped
    2 / 2
    Points
    410
    Level
    4

    Re: One PIC, a lot of LEDs to Pulse Width Modulate...

    Thank you.



  7. #7
    Full Member level 2
    Points: 2,010, Level: 10

    Join Date
    Apr 2006
    Location
    Santa Rosa, Ca.
    Posts
    120
    Helped
    2 / 2
    Points
    2,010
    Level
    10

    Re: One PIC, a lot of LEDs to Pulse Width Modulate...

    How about dasy-chaining some shift-registers, such as 74HC595 and use PWM on OE ( Output Enable ) PIN?



  8. #8
    Member level 2
    Points: 410, Level: 4

    Join Date
    Nov 2011
    Location
    Denmark
    Posts
    45
    Helped
    2 / 2
    Points
    410
    Level
    4

    Re: One PIC, a lot of LEDs to Pulse Width Modulate...

    Quote Originally Posted by chevymn1964 View Post
    How about dasy-chaining some shift-registers, such as 74HC595 and use PWM on OE ( Output Enable ) PIN?
    Well I am no expert, but that would give the same PWM on all outputs ?

    UPDATE:
    Hi, see klug's post bellow. This was properly what you was aiming at ?
    Last edited by henninggs; 12th December 2011 at 21:01.



  9. #9
    Advanced Member level 1
    Points: 8,577, Level: 22
    klug's Avatar
    Join Date
    Jul 2002
    Posts
    476
    Helped
    13 / 13
    Points
    8,577
    Level
    22

    Re: One PIC, a lot of LEDs to Pulse Width Modulate...

    Try BAM (Binary Angle Modulation) instead of PWM.
    Batsocks - LED dimming using Binary Code Modulation - Binary Code Modulation

    It is most effective way to control brightness of LED's.

    You can use it with shiftPWM.

    There is a shiftPWM examlple for controlling of 768 LED’s at 32 brightness levels by Arduino:
    http://www.elcojacobs.com/shiftpwm/

    You can use this circuit to drive LEDs:
    Arduino - ShiftOut


    1 members found this post helpful.

  10. #10
    Member level 2
    Points: 410, Level: 4

    Join Date
    Nov 2011
    Location
    Denmark
    Posts
    45
    Helped
    2 / 2
    Points
    410
    Level
    4

    Re: One PIC, a lot of LEDs to Pulse Width Modulate...

    Thanks klug, this was very interesting.
    I'll need to google Binary Code Modulation a bit more and find some schematics, I don't quite get the theory/concept yet.



  11. #11
    Advanced Member level 1
    Points: 8,577, Level: 22
    klug's Avatar
    Join Date
    Jul 2002
    Posts
    476
    Helped
    13 / 13
    Points
    8,577
    Level
    22

    Re: One PIC, a lot of LEDs to Pulse Width Modulate...

    You can compare BAM & PWM on this picture:


    Principle of BAM is very simple:

    Bit - Weight
    0 - 1
    1 - 2
    2 - 4
    3 - 8
    4 - 16
    5 - 32
    6 - 64
    7 - 128

    Weight is a time to light the LED.

    For example, if you need to get brightness 0x2F (0b00101111), then you will switch off the LED on period of 128 and 64 of tacts, switch on for period of 32 tacts, switch off for period of 16 tacts, on for periods of 8, 4, 2, 1.



    If you will try to make 8 bits shiftPWM, then you will need 256 interrupts for 1 period of PWM. But BAM will need only 8 interrupts of controller.

    Next advantage, that the frequency of blinking will be higher on BAM (except brightness 0x80 - where they will be equal)


    1 members found this post helpful.

  12. #12
    Member level 2
    Points: 410, Level: 4

    Join Date
    Nov 2011
    Location
    Denmark
    Posts
    45
    Helped
    2 / 2
    Points
    410
    Level
    4

    Re: One PIC, a lot of LEDs to Pulse Width Modulate...

    Yes, that make sense, that's clever. Very clever. I got it.
    In the links you provided there was also a discussion on controlling A LOT of leds using shift registers and BAM.
    I'm a bit confused about the shift registers....

    The shift registers has nothing to do with the BAM-concept, right ?
    Controlling that many channels with BAM and a 8mhz microcontroller (Think it was 700+ channels) is doable because the BAM method is that much faster Right ? (Not spending so much time in interrupts I guess...)



  13. #13
    Advanced Member level 1
    Points: 8,577, Level: 22
    klug's Avatar
    Join Date
    Jul 2002
    Posts
    476
    Helped
    13 / 13
    Points
    8,577
    Level
    22

    Re: One PIC, a lot of LEDs to Pulse Width Modulate...

    Shift registers are the output stage of BAM there. You are loading the state of every LED in interrupt by these shift registers. So, you can independently controll brightness of every LED.

    For example, you have 8 LEDs, you need to load brigtness 0x80 for first 4 LEDs and brightness 0x0 for last 4 LEDs. So, in the first interrupt you are loading 0x0F to shift registers. On the next interrupts (2-8) you will load 0x0 to shift registers.


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  14. #14
    Member level 2
    Points: 410, Level: 4

    Join Date
    Nov 2011
    Location
    Denmark
    Posts
    45
    Helped
    2 / 2
    Points
    410
    Level
    4

    Re: One PIC, a lot of LEDs to Pulse Width Modulate...

    Quote Originally Posted by klug View Post
    For example, you have 8 LEDs, you need to load brigtness 0x80 for first 4 LEDs and brightness 0x0 for last 4 LEDs. So, in the first interrupt you are loading 0x0F to shift registers. On the next interrupts (2-8) you will load 0x0 to shift registers.
    Arigh... That I don't get.
    I'll read up on "shift register" so I fully understand what a shift register does. I'll get back.

    ---------- Post added at 23:32 ---------- Previous post was at 22:55 ----------

    Well I do get it (I think)
    The clue was (taken from the 74HC595 datasheet):
    Data in the storage register
    appears at the output whenever the output enable input (!OE) is LOW
    - And the data pins will remain in their high/low state as long as the !OE is low.

    - So:
    1. The microcontroller shifts in 11110000 and just holds !OE low for one half cycle (4 leds is on, 4 leds is off)
    2. Now it shifts in 00000000 and holds the !OE low for one half of a half cycle (all leds is off)
    3. and so on... Result: Led 1-4 have been lit for half a cycle = 50% = 0x80 (If a 8bit resolution is used)

    If I want to dim led 8 to 25%, led 7 to 12.5%, I'll shift in:
    00000000
    10000000
    01000000
    and 5 times 00000000
    Last edited by henninggs; 12th December 2011 at 23:00.



--[[ ]]--