Creating an Multiple LED Stepping pattern

Thread Starter

iONic

Joined Nov 16, 2007
1,662
I have nearly ZERO programming skills but am curious as to what it might take to create the effect I am looking for.
The project is for some art that I have yet to produce but will simulate the hours of a clock or, in this case, the direction of the sun. An example would be:
with a string of 60 LEDs, (possible even 120 LEDs, but we'll stick to 60 for the example) I would like to have10-15 of them Lit at any one time. As time steps forward, the trailing edge LED turns off as the leading Edge LED adds another lit LED. This should pretty closely follow a 12hr rotation so that the process repeats every 12 hours. Given this, there will be a time where there will be some LEDs lit at the beginning of the String and some lit at the end of the same string of LEDs. Given that the art may be 2ft x 2ft. many more LEDs may be required....depends on the LED spacing I would guess.

I would be willing to pay for programmed chips that could accomplish this.

Thanks
Brian
 
Last edited:

John P

Joined Oct 14, 2008
2,025
This is pretty easy with WS2812 serially-controlled LEDs. Can you use them if they're all mounted to a flexible tape? Bonus: you could see them light up in any color you want.
 

Thread Starter

iONic

Joined Nov 16, 2007
1,662
This is pretty easy with WS2812 serially-controlled LEDs. Can you use them if they're all mounted to a flexible tape? Bonus: you could see them light up in any color you want.
Yes. My thoughts were to use an LED Strip/Strips. The LED's will not be facing the viewer, but rather offset 90deg towards the center of the artwork.
 
Last edited:

ElectricSpidey

Joined Dec 2, 2017
2,757
If you decide to use addressable LED strips I would recommend the 2 wire control over the single wire type.

The 2 wire type can be controlled using SPI where the single wire version uses a very picky protocol that not every programmer can manage.

There are also other advantages, such as speed...but I doubt that will mean much in this application.
 

BobTPH

Joined Jun 5, 2013
8,804
I have been using WS2812B for years. They are not difficult at all. I basically wrote two functions, one to output a one and one for a zero, then build on top of that to a function that outputs a single LED taking R G and B as params.

And finally, in some apps, I keep an array for the entire string and have a function to rewrite the entire string. That is not needed in this app

The one and zero functions need to be customized to the processor and clock speed, all the rest is generic C.

I have found that you pretty much need an 8MHz or faster instruction speed.

Bob
 

Ian0

Joined Aug 7, 2020
9,667
I've used it before. First attempt I bit-banged the GPIO, and padded with NOPs to get the timing. Second attempt was more subtle. I split the 8 bit word into two four bit sections, each bit was then translated into 3 bits in a 16-entry lookup table, so 110 for a 1 and 100 for a zero, and then output via the SPI set to 12 bit word.
However, I'd much rather have LEDs that work directly with the SPI!
 

BobTPH

Joined Jun 5, 2013
8,804
Do the SPI ones allow you to change one LED in the center of the string, as oppsed to writing the whole thing? If so, this would be an advantage.

Bob
 

Ian0

Joined Aug 7, 2020
9,667
Do the SPI ones allow you to change one LED in the center of the string, as oppsed to writing the whole thing? If so, this would be an advantage.

Bob
I guess not, as there is only a 24-bit shift register in each one, with data in and data out pins. To access the nth shift register in the chain, you have to send data through the first n-1.
 

John P

Joined Oct 14, 2008
2,025
Yeah, when I shifted from the PIC16F690 (2MIPS) to the PIC16F18345 (8MIPS) I realized "Hey, I can play with those serial-interfaced LEDs!" One of Microchip's application notes talks about doing it with one of the Configurable Logic Controllers, but I used a PWM output instead.

Yes, you do have to write the entire string every time you write anything at all, but I think you'd be likely to arrange it so that the data is held in RAM and the entire string gets re-written at some fast rate, say 50Hz. Then any time you want to load data, you just write it to the RAM and let it get sent out to the LEDs automatically.
 

ElectricSpidey

Joined Dec 2, 2017
2,757
The real issue with the single wire type is the delay timing needs to be shorter than 1us, so there is no standard Delay() function to accommodate this, so you are left with bit-banging or some other very clever method.

I believe the single wire is popular because there are already many libraries available to do patterns and effects, but as soon as you go off the beaten path and need something custom...you are in a world of hurt, if you are not a top programmer.

The perfect example is...me, I couldn't bit-bang to save my life and I couldn't get anything else figured out...but when I found the 2 wire type I had them working within a day.
 

John P

Joined Oct 14, 2008
2,025
For this timing-critical stuff, you have to forget about Delay() functions, and do the kind of programming where you know what every instruction will do and where all your data is. I could never do anything like this without an oscilloscope to check on what's happening.

Here is a very humble WS1812B setup that just demonstrates that it really works. The LEDs are written at a 30Hz rate, which is also how fast the pattern of colors advances down the string. It sets the 3 bytes for each pixel to 0xFF or 0x00, so there are 8 colors, including white and all-off.
 

ElectricSpidey

Joined Dec 2, 2017
2,757
Of course they work, did I suggest otherwise?

Oh, I get it...you are being defensive because you suggested one kind and I suggested another.

Sorry, it wasn't my intention to one up you, just trying to make it easier for the OP.
 

Ian0

Joined Aug 7, 2020
9,667
Of course they work, did I suggest otherwise?

Oh, I get it...you are being defensive because you suggested one kind and I suggested another.

Sorry, it wasn't my intention to one up you, just trying to make it easier for the OP.
I'd be really pleased to know who makes and where to get the SPI type. WS2812 is a pain. It takes up a lot of processor time.
 

BobTPH

Joined Jun 5, 2013
8,804
The perfect example is...me, I couldn't bit-bang to save my life and I couldn't get anything else figured out..
At 8 MHz, 125us instruction time, it is

1. Set the bit on
2. 2 or 6 NOPs for zero or 1
3. Set the bit off.

Note that the “set the bit off” adds 1 more to the delay since the output changes at the end of the instruction.

This gives pulses of 375us and 875us where the spec calls for 400 and 850 ± 150. I will post my functions when I get home.

Bob
 
Top