Author Topic: Which micro to use for fading 15 LEDs and cutom presets?  (Read 26258 times)

0 Members and 1 Guest are viewing this topic.

Offline drojf

  • Newbie
  • Posts: 9
  • Country: au
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #50 on: December 25, 2015, 02:19:52 pm »
Quote
i want the LEDS to indevidually and randomly fade

Those same words can mean different things to different people under different context.

It is rare to have a mcu that offers that many "independent" pwm channels - typically up to 4 pwm channels on low-end chips and more on those 32-bit ARMs. So if you want to implement truly independent fading, you will need to drive your leds in groups and implement a bus protocol.

Hopefully I've understood OP correctly. Dannyf seems to have the right idea. If you want to do this "on the cheap", my advice would be to buy an Arduino Pro Mini off Ebay (< $4 USD) and a FTDI serial module to program it(<$4 USD). Even though the Pro Mini only has 4 available channels (technically 6), you can multiplex them between the 16 LEDS (4 banks of 4 PWM channels). You can use one of the following configurations to drive the LEDS (see attachment).

Try and make sure the FTDI module is legit and not the CH340 type, otherwise you may have to do some searching for the CH340 drivers (and incompatibility issues with later versions of windows). You can use the FTDI serial module to program any subsequent pro mini's that you might buy.

If the LEDs don't need to be extremely bright you can omit any external components except resistors (Config A). You can use a transistor (Config B) or sink to multiple pins (Config C) for slightly more current. This configuration is fairly simple to code, you just allocate 1/4 of the time to each bank of four LEDs (there are other ways, but I think this is the simplest which uses the PWM units). I would get a hold of the LEDs you want to use first, so that you can figure out how much current is required to make them glow nicely (you'll need a multimeter and a variety of resistors to test that).

The information for max current per pin etc. is in the datasheet, but Sparkfun has an easier to read version:
https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/ProMini16MHzv1.pdf




Technically you could buy a STM32 Nucleo board for about $10USD (excluding shipping), complete with programmer, and lots of pins, but I wouldn't recommend it for starting out (the mbed libraries are fairly easy to use though). Arduino/AVR wins for amount of tutorials/support / ease of use for simple tasks
« Last Edit: December 25, 2015, 03:06:05 pm by drojf »
 
The following users thanked this post: AnasMalas

Offline AnasMalasTopic starter

  • Regular Contributor
  • *
  • Posts: 69
  • Country: jo
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #51 on: December 25, 2015, 02:35:28 pm »
Quote
i want the LEDS to indevidually and randomly fade

Those same words can mean different things to different people under different context.

It is rare to have a mcu that offers that many "independent" pwm channels - typically up to 4 pwm channels on low-end chips and more on those 32-bit ARMs. So if you want to implement truly independent fading, you will need to drive your leds in groups and implement a bus protocol.

Hopefully I've understood OP correctly. Dannyf seems to have the right idea. If you want to do this "on the cheap", my advice would be to buy an Arduino Pro Mini off Ebay (< $4 USD) and a FTDI serial module to program it(<$4 USD). Even though the Pro Mini only has 4 available channels (technically 6), you can multiplex them between the 16 LEDS (4 banks of 4 PWM channels). You can use one of the following configurations to drive the LEDS (see attachment).

Try and make sure the FTDI module is legit and not the CH340 type, otherwise you may have to do some searching for the CH340 drivers (and incompatibility issues with later versions of windows). You can use the FTDI serial module to program any subsequent pro mini's that you might buy.

If the LEDs don't need to be extremely bright you can omit any external components except resistors (Config A). You can use a transistor (Config B) or sink to multiple pins (Config C) for slightly more current. This configuration is fairly simple to code, you just allocate 1/4 of the time to each bank of four LEDs (there are other ways, but I think this is the simplest which uses the PWM units). I would get a hold of the LEDs you want to use first, so that you can figure out how much current is required to make them glow nicely (you'll need a multimeter and a variety of resistors to test that).

The information for max current per pin etc. is in the datasheet, but Sparkfun has an easier to read version:
https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/ProMini16MHzv1.pdf



Technically you could buy a STM32 Nucleo board for about $10USD (excluding shipping), complete with programmer, and lots of pins, but I wouldn't recommend it for starting out (the mbed libraries are fairly easy to use though). Arduino/AVR wins for amount of tutorials/support / ease of use for simple tasks

I didnt really think that multiplexing would even work with PWM... but what if i want to fade in both LED no. 4 and 5? wouldent no. 1 also fade in then? 
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12807
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #52 on: December 25, 2015, 02:50:42 pm »
Multiplexing will work with PWM, if its synchronised to the PWM timebase, but it should be avoided for a low cost project, as you need brighter better quality LEDs + driver transistors or chips to get an acceptable brightness for daytime use as the average current in any of the LEDs is divided by the proportion of the total multiplexing sequence its enabled for.  e.g. with 4:1 multiplexing and a MCU that can source/sink 10mA per I/O pin, the maximum average current you can get per LED will be 2.5mA (and that's before you dim it with PWM).   The increased circuit complexity will rapidly eat into your budget, as will the need for a PCB or at least protoboard to mount the extra components on.

 
The following users thanked this post: AnasMalas

Offline drojf

  • Newbie
  • Posts: 9
  • Country: au
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #53 on: December 25, 2015, 03:05:02 pm »
Sorry, I missed your comment. I agree - using plain software should be fast enough.....using BCM as you mentioned before, or using a "simpler" method but 100% of the CPU. For some reason I thought there was a requirement to use the PWM units.

16 LEDs * 10mA = 160mA which is less than the 200mA limit. But you'll need some sort of driver IC if you want to make the LEDs any brighter than that.

« Last Edit: December 25, 2015, 03:20:17 pm by drojf »
 
The following users thanked this post: AnasMalas

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #54 on: December 25, 2015, 03:14:33 pm »
@AnasMalas

I'd love to see how you plan to connect up a many-pin MCU, a many-pin shift register, 15 LEDs, a power supply and control switches, without using a printed circuit board or a breadboard.

I agree that using a ProMini might be a good solution since you don't want RGB addressable LEDs (which are also available in through-hole leaded packages of course, for a bit higher cost), but you will still have to do some programming and soldering. You'll have to have one FTDI programming module in order to program the ProMinis. You'll have to learn how to multiplex the PWM outputs to be able to control all your LEDs, and you will likely have to use external transistors to drive the multiplexed LEDs to acceptable brightness. The ProMini will still require a power supply and control switches. The LEDs will still require some kind of mounting arrangement, and if your friends want to "swap them out" for some reason you'll need to provide some means for doing that. Will they be soldering them?  To what?
 
And will a <$4.00 Chinese clone ProMini actually work properly? I use ProMinis in my own projects but I've never tried one of the cheap clones, so I can't speak as to their reliability. (I do have two projects with genuine ProMinis that are running constantly in my lab (a color organ with 12 LEDs and a multicolor flasher with 1 RGB LED) and have run for several years continuously without problems. I also have that NeoPixel demonstration box, now using a single ProMini that is controlling 2 NeoPixel rings, one 24-LED unit and one 16-LED unit, for a total of 40 RGB LEDs, with color and brightness controlled by software.)

Please understand that I am trying to help you figure out the easiest, least expensive way to get to your final product as you've described it.



« Last Edit: December 25, 2015, 03:21:00 pm by alsetalokin4017 »
The easiest person to fool is yourself. -- Richard Feynman
 
The following users thanked this post: AnasMalas

Offline Aodhan145

  • Frequent Contributor
  • **
  • Posts: 403
  • Country: 00
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #55 on: December 25, 2015, 03:35:59 pm »
-- agree with the addressable LEDs, but almost all the issues of developing your own code still apply.
I wrote that bit banging PWM before WS28xx were around, and it was worth the effort.
Oddly enough, I'm currently working on a project controlled with DMX, and 100 tiles each containing 384x WS2812 LEDs !   38400 RGB pixels!

All knowledge is good, unless we waste it.
I thought my project was quite big with 80 ws2812 leds. But these were Pl9823 through hole LEDs which I hand solder wires to. It took a couple of hours.
 
The following users thanked this post: AnasMalas

Offline AnasMalasTopic starter

  • Regular Contributor
  • *
  • Posts: 69
  • Country: jo
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #56 on: December 25, 2015, 04:24:54 pm »
@AnasMalas

I'd love to see how you plan to connect up a many-pin MCU, a many-pin shift register, 15 LEDs, a power supply and control switches, without using a printed circuit board or a breadboard.

I may have confused you, but what i meant is with using the "soldered" protoboard 


for 2$ and some "dremmeling" i can make all 15 boards  :P

Quote
Please understand that I am trying to help you figure out the easiest, least expensive way to get to your final product as you've described it.

Thank you, I am really sorry if i am being a pain but i an just a newb... hopefully after i can do this one project i would help others here because i am learning so much stuff...
 

Offline Robartes_m

  • Contributor
  • Posts: 21
  • Country: be
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #57 on: December 25, 2015, 04:40:26 pm »
Quote
All that aside, here is a question for everyone: is the Ti TLC5940 a good chip for my purpose. The DIP package is discontinued but i could source it on ebay (WHICH NO ONE IS TELLING ME IF EBAY SELLERS ARE LEGIT  :-BROKE) So my question is: does ti have good programmers and libraries that wont cost me a fortune? if i will buy a programmer i prefer one that i could use for the register, the MCU, and any other future chips with the same package from the same company.....

I like the TLC5940 and have used it successfully a few times. You do not need a programmer for it as it is not a microcontroller. Basically, you provide it with a data clock and data signal to tell it the PWM levels of each of its outputs (with 12-bit resolution), as well as a faster clock signal which will drive the PWM. Additionally, there's a few enable and blanking signals. All of these signals can easily be generated with a microcontroller of any kind (I've used an Atmel ATTiny84 for this).

If you want to use the TLC5940, no additional programming hardware on top of that needed for your microcontroller will be needed.

 
The following users thanked this post: AnasMalas

Offline AnasMalasTopic starter

  • Regular Contributor
  • *
  • Posts: 69
  • Country: jo
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #58 on: December 25, 2015, 05:06:15 pm »
Quote
All that aside, here is a question for everyone: is the Ti TLC5940 a good chip for my purpose. The DIP package is discontinued but i could source it on ebay (WHICH NO ONE IS TELLING ME IF EBAY SELLERS ARE LEGIT  :-BROKE) So my question is: does ti have good programmers and libraries that wont cost me a fortune? if i will buy a programmer i prefer one that i could use for the register, the MCU, and any other future chips with the same package from the same company.....

I like the TLC5940 and have used it successfully a few times. You do not need a programmer for it as it is not a microcontroller. Basically, you provide it with a data clock and data signal to tell it the PWM levels of each of its outputs (with 12-bit resolution), as well as a faster clock signal which will drive the PWM. Additionally, there's a few enable and blanking signals. All of these signals can easily be generated with a microcontroller of any kind (I've used an Atmel ATTiny84 for this).

If you want to use the TLC5940, no additional programming hardware on top of that needed for your microcontroller will be needed.

THAT is so, so, so good to know! i am starting to think this is the best way to go!!
i was reviewing the data sheet for it and noticed that they shorted the "XERR,SCLK,XLAT,GSCLK,DCPRG,BLANK"
have a look: http://www.ti.com/product/TLC5940/datasheet/application_and_implementation#SLVS5159149

is that how you did it? including that component mess down there?
 

Offline Robartes_m

  • Contributor
  • Posts: 21
  • Country: be
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #59 on: December 25, 2015, 06:54:56 pm »
Quote
is that how you did it? including that component mess down there?

Here's the schematic of my Tiny84 / TLC5940 board. You can disregard the MAX641 part, that was just used because this particular circuit was running off a LiPo battery and I wanted VCC boosted to 5V.

For the TLC5940 I connected the SCLK (data clock), SI (data in), GSCLOCK (Grayscale clock, the PWM clock signal), XLAT (latch in new PWM data) and BLANK (what it says on the box :) ) to the microcontroller. The only additional pins (except for the output and power supply) connected on the TLC5940 were VPRG which needs to be low, and the resistor on IREF to set the LED current.

The transistor on the GND pin of the TLC5940 is only there to shut it off when the MCU goes to sleep to conserve battery power.

 
The following users thanked this post: AnasMalas

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #60 on: December 26, 2015, 01:50:52 am »
and noticed that they shorted the "XERR,SCLK,XLAT,GSCLK,DCPRG,BLANK"

Those pins aren't shorted - they are bussed together to simplify the schematic.
Where each separate signal 'pops out' from the buss, it will be identified.

Robartes diagram is close to the minimum you need to do with separate components (any brand)...

Keeping in mind your preference to use through-hole discrete RGB LEDs - you create all this work for yourself, as well as taking space on the board.  Using any integrated RGB (WS28xx) LED will elimonate about 60% of the wiring - through hole or SMT.   

(If you are determined to use through-hole separate driver chip and LEDs - look at the WS2801... the drivers and examples are all over the place - and still 50% less point-to-point wiring.  https://www.adafruit.com/datasheets/WS2801.pdf
Don't ask a question if you aren't willing to listen to the answer.
 
The following users thanked this post: AnasMalas

Offline AnasMalasTopic starter

  • Regular Contributor
  • *
  • Posts: 69
  • Country: jo
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #61 on: December 26, 2015, 10:25:46 am »
Quote
is that how you did it? including that component mess down there?

Here's the schematic of my Tiny84 / TLC5940 board. You can disregard the MAX641 part, that was just used because this particular circuit was running off a LiPo battery and I wanted VCC boosted to 5V.

For the TLC5940 I connected the SCLK (data clock), SI (data in), GSCLOCK (Grayscale clock, the PWM clock signal), XLAT (latch in new PWM data) and BLANK (what it says on the box :) ) to the microcontroller. The only additional pins (except for the output and power supply) connected on the TLC5940 were VPRG which needs to be low, and the resistor on IREF to set the LED current.

The transistor on the GND pin of the TLC5940 is only there to shut it off when the MCU goes to sleep to conserve battery power.
Alright, thanks soo much for the valuable schematic! One last question: any reason for choosing the attiny 84?

Quote
Those pins aren't shorted - they are bussed together to simplify the schematic.
Where each separate signal 'pops out' from the buss, it will be identified.
It sure seemed odd, i just didnt want to assume anything so i asked...

Quote
... through-hole discrete RGB LEDs ...
actually i am using through hole discrete mono LEDs, 15 of them....
 

Offline Robartes_m

  • Contributor
  • Posts: 21
  • Country: be
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #62 on: December 26, 2015, 10:29:23 am »
Quote
Alright, thanks soo much for the valuable schematic! One last question: any reason for choosing the attiny 84?

I'm familiar with AVR's, and it's the smallest one with enough I/O pins to drive all the signals I needed. My 'go to' MCU for this sort of thing (LED blinky stuff) is an ATTiny85, but that only has 5 I/O pins available, which was not enough in this case.

 
The following users thanked this post: AnasMalas

Offline AnasMalasTopic starter

  • Regular Contributor
  • *
  • Posts: 69
  • Country: jo
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #63 on: December 26, 2015, 05:50:01 pm »
Quote
  ATTiny85, but that only has 5 I/O pins available, which was not enough in this case.


how many IO pins do i need for the  TLC5940? are the XERR,SCLK,XLAT,GSCLK,DCPRG,BLANK all on IO pins or are there specific pins on the micro? also did you use the Ti library? how hard was it to code considering that ive never coded for a micro?
« Last Edit: December 27, 2015, 08:03:22 am by AnasMalas »
 

Offline Robartes_m

  • Contributor
  • Posts: 21
  • Country: be
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #64 on: December 26, 2015, 07:34:59 pm »
Quote
  ATTiny85, but that only has 5 I/O pins available, which was not enough in this case.
how many IO pins do i need for the  TLC5940? are the XERR,SCLK,XLAT,GSCLK,DCPRG,BLANK all on IO pins or are there specific pins on the micro? also did you use the Ti library? how hard was it to code considering that ive never coded for a micro?

All of the signals connected to the MCU were connected to normal I/O pins. I did not use the TI library but wrote my own code to drive the TLC5940. You will need a solid understanding of timers and interrupts on the microcontroller if you want to go this route yourself.

As this is your first microcontroller experience, I would actually recommend going the Arduino route - there's an Arduino library specifically for the TLC5940 IIRC. You can always transfer the microcontroller to a separate board after programming it in an Arduino Uno if you want.
 
The following users thanked this post: AnasMalas

Online oPossum

  • Super Contributor
  • ***
  • Posts: 1415
  • Country: us
  • Very dangerous - may attack at any time
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #65 on: December 27, 2015, 03:32:18 am »
16 channel PWM using a single timer in the MSP430.  The ISR is very simple, so MCU overhead is low.

http://forum.43oh.com/topic/1723-16-channel-software-pwm-using-a-single-timer/


« Last Edit: December 27, 2015, 03:33:54 am by oPossum »
 
The following users thanked this post: AnasMalas

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #66 on: December 27, 2015, 03:06:32 pm »
your isr:

Code: [Select]
__interrupt void Timer0_A1 (void)
{
volatile unsigned x = TAIV; // Clear interrupt flag
P1OUT &= ~pa->port_off; // Port pins off
P2OUT &= ~pa->port_off >> 8; //
P1OUT |= pa->port_on; // Port pins on
P2OUT |= pa->port_on >> 8; //
pa = pa->next; // Next entry in list
TACCR1 = pa->time; // Update timer compare time
}

It has the advantage a short pwm period. However, it has a few issues:

1) the pwm list must be time-monotonic, in that the compare time for the next entry on the list must be bigger than the compare time for the previous entry on the list. This is OK with a static list but if your pwm channels allow dynamic / changing compare time / duty cycle for each channel independently, maintaining that list can be prabamatic;
2) The difference between successive compare time has to be sufficiently large (larger than isr latency + isr execution time), or your pwm duty cycle may not be accurate -> more specifically, it may be longer than expected / specified by the list.

Also, from coding perspective, you want to update the compare time TACCR1 first, and then process the pins later, so you don't miss short compare time intervals: under the current code, your timer / counter could have advanced beyond the next compare time, because of executing the isr code first so that the compare isn't triggered until the timer has finished a full cycle.

The approach I took is to use each timer overflow as 1 tick for the (software pwm) time base. It avoids the problems above, but does slow down the CPU and cannot provide short pwm period.

The practical approach is to use pcm.
================================
https://dannyelectronics.wordpress.com/
 
The following users thanked this post: AnasMalas

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2145
  • Country: fi
  • Embedded SW/HW.
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #67 on: December 27, 2015, 03:53:46 pm »
How about using a precomputed lookup-table containing the bits of wanted PWM-signal pattern. Let's assume that you want to have 32 different levels for each LED, so your lookup-table needs to be 32 entries long. Then you will have a timer running at 32kHz generating interrupts giving 1kHz update rate, thus there shouldn't be any flicker. At each interrupt you just read the lookup-entry and write it to the output port and increment the table index using modulo arithmetic (index = (index + 1) & (32-1)). Pretty simple and light on ISR. When you need to adjust the brightness for one or more LEDs, just compute and update the table.

If you need more that 32 levels, say 64 or 128 levels, you need to increase the table size and adjust the timer interrupt rate.
« Last Edit: December 27, 2015, 04:24:41 pm by Kalvin »
 
The following users thanked this post: AnasMalas

Offline AnasMalasTopic starter

  • Regular Contributor
  • *
  • Posts: 69
  • Country: jo
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #68 on: December 27, 2015, 07:17:57 pm »
All those bits of code hit me like a truck...... I aint ready for all of this... Me programming code that wont bug out isnt looking too positive...
just a small question before i venture into this world (ill start taking some online classes), do diffrent MCUs REQUIRE different code to operate? or is there some sort of compatibility between say 8 bit and 8 bit, or 8051 based and 8051 based?
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #69 on: December 27, 2015, 09:09:04 pm »
Quote
At each interrupt you just read the lookup-entry and write it to the output port and increment the table index using modulo arithmetic (index = (index + 1) & (32-1)).

That's basically what I do:

Code: [Select]
void spwm_act(void) {
static uint8_t mask = PWM_MASK; //initialize pwm duty cycle
mask = mask - 1; //decrement mask
if (mask == 0) {
mask = PWM_MASK; //initialize mask
IO_CLR(PWM0_PORT, PWM0); //clear pwm pins
IO_CLR(PWM1_PORT, PWM1);
}
//process pwm0
if (mask == spwm_dc[0]) IO_SET(PWM0_PORT, 1<<0);
if (mask == spwm_dc[1]) IO_SET(PWM0_PORT, 1<<1);
if (mask == spwm_dc[2]) IO_SET(PWM0_PORT, 1<<2);
if (mask == spwm_dc[3]) IO_SET(PWM0_PORT, 1<<3);
if (mask == spwm_dc[4]) IO_SET(PWM0_PORT, 1<<4);
if (mask == spwm_dc[5]) IO_SET(PWM0_PORT, 1<<5);
if (mask == spwm_dc[6]) IO_SET(PWM0_PORT, 1<<6);
if (mask == spwm_dc[7]) IO_SET(PWM0_PORT, 1<<7);

//process pwm1
if (mask == spwm_dc[8]) IO_SET(PWM1_PORT, 1<<0);
if (mask == spwm_dc[9]) IO_SET(PWM1_PORT, 1<<1);
if (mask == spwm_dc[10]) IO_SET(PWM1_PORT, 1<<2);
if (mask == spwm_dc[11]) IO_SET(PWM1_PORT, 1<<3);
if (mask == spwm_dc[12]) IO_SET(PWM1_PORT, 1<<4);
if (mask == spwm_dc[13]) IO_SET(PWM1_PORT, 1<<5);
if (mask == spwm_dc[14]) IO_SET(PWM1_PORT, 1<<6);
if (mask == spwm_dc[15]) IO_SET(PWM1_PORT, 1<<7);

}

spwm_act() is called in the timer overflow isr.

Implementing pcm is quite easy as well: rather than "mask = mask - 1;", you do "mask = mask >> 1;" and make corresponding adjustments to the counter (or prescaler, depending on your implementation / hardware).

Fundamentally, with software pwm, you process 256 interrupts / 16x port operations per pwm period; and with software pcm, you process 8 interrupts / 16x port operations.
================================
https://dannyelectronics.wordpress.com/
 
The following users thanked this post: AnasMalas

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6189
  • Country: us
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #70 on: December 27, 2015, 09:22:59 pm »
You don't need to use PWM. You can use a pulse code modulation. It requires only one timer and you can dim as many LEDs as you have GPIOs. The scheme works by setting the timer in consequently longer pulses and flipping the GPIO pin if necessary. Pulse 1 is T. Pulse 2 is 2*T. Pulse 3 is 4*T. This way you can code the LED intensity in binary and you only need one timer. You can find the details in: "Extended parallel pulse code modulation of LEDs", I. Ashdown - SPIE Optics & Photonics, 2006. PM me if you cannot find the article.

That's a neat idea.
 

Offline josh38

  • Newbie
  • Posts: 1
  • Country: us
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #71 on: March 08, 2016, 03:12:47 am »
I have a problem with flickering WS2812B leds. I'm using a setup of 5 strips 8xWS2812 5050 leds. I've connected these to a 5v power supply (USB charger) and an Arduino Uno. I've noticed that the leds also flicker when the leds are on and the datapin is disconnected. The flickering is subtle, but annoying. I've also tried an alternative power supply. For this I used a adjustable lab power supply. But the same problem persists.Any thoughts?
 

Offline Aodhan145

  • Frequent Contributor
  • **
  • Posts: 403
  • Country: 00
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #72 on: March 08, 2016, 09:37:49 pm »
I have a problem with flickering WS2812B leds. I'm using a setup of 5 strips 8xWS2812 5050 leds. I've connected these to a 5v power supply (USB charger) and an Arduino Uno. I've noticed that the leds also flicker when the leds are on and the datapin is disconnected. The flickering is subtle, but annoying. I've also tried an alternative power supply. For this I used a adjustable lab power supply. But the same problem persists.Any thoughts?
DECOUPLING CAPACITORS. i had this problem with a 64 long through hole ws2812 string i turned it on and they were all flickering so i put 64 0.1uf caps on and now it works.
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: Which micro to use for fading 15 LEDs and cutom presets?
« Reply #73 on: March 11, 2016, 01:46:33 am »
Quote
The approach I took is to use each timer overflow as 1 tick for the (software pwm) time base. It avoids the problems above, but does slow down the CPU and cannot provide short pwm period.
+1. This is how my PCM has also evolved. A single timer interrupt with a fixed (and relatively short) period can do almost anything you could ever need to do using multiple timers. It just takes a little bit of code in the ISR. This is a very flexible way to use a timer interrupt, IMO. It's rather like sharing time with a second CPU, for things which are timing sensitive (or rather must remain timing-consistent) but which can be executed very quickly.

Even pre/post scaling is simply a luxury. You can post-post scale to your heart's content in your ISR with cost of a few extra instruction executions and a few spaces of memory. And the bonus is that the extra instructions that pile up on every overflow and/or when ISR's collide, they don't matter, so much. Each period is the same length, so long as you keep the max length of your ISR (if there were to all fire at once) shorter than the period. A particular ISR might execute with a slight delay every blue moon if it's down on the priority list, but only as long a delay as the total max length of higher priority interrupt routines. There's no cumulative effect to account for.
« Last Edit: March 11, 2016, 02:06:42 am by KL27x »
 
The following users thanked this post: AnasMalas


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf