WS2812B based switch array -- circuit design

Thread Starter

wambecqa

Joined Dec 10, 2023
3
I would like to pursue on the work described in https://hackaday.io/page/6514-why-doesnt-someone-make-a-ws2812b-switch-array
It makes use of the WS2812b protocol (see summary description in https://voltiq.ru/datasheets/WS2812B_datasheet_EN.pdf).
However this circuit only detects the "first" switch pressed in the array, and has no support for multiple switches pressed at the same time.

I would like to extract from the DIN (WS2812b) bitstream a signal that a certain addressable LED is "active". So I would like a signal that becomes HIGH at the rising edge of the first bit received by that LED, stays HIGH for 20 to 24 us, and then is LOW until a RESET is on the communication line(RESET is a LOW on the communication line for at least 50 uS). After a RESET, the signal remains LOW until the first bit of a new transmission is received.
Otherwise explained: I would like a monostable multivibrator that generates a 24uS pulse at the first rising edge of the first bit of a transmission, and then is inhibited to trigger again until a RESET is found on the transmission line.

Then I would like to combine this "active" signal with a switch or other digital detector to communicate the signal multiplexed on a single line to the microcontroller. (Since only one LED can be active at any given time, the microcontroller can determine which switches are activated.)

Any support or suggestions to design a circuit that supports this is highly appreciated.
 

BobTPH

Joined Jun 5, 2013
8,653
I have read your post and the linked post and I have no idea what either of you is trying to do.

My best understanding is that you misinterpreted what the linked post was doing.

Here is what I think he was doing:

He has a bunch of pushbuttons in a line and wants to know which is the first one pressed. He added the WS2812B string, one for each switch, to generate a series of pulses, one for each switch, where the first pulse seen comes at a different tine for each LED. He then wire ORs together all of the signals for which the switch is pressed. This allows him ti determine which switch is the first one in the line pressed. Yes, that could work, but there are far better ways to do it.

But you seem to be asking for something different. I interpret you as wanting to create a pulse for each update of an existing LED strip if a specific LED is on. Which is actually much more complicated, since there are 24 bits to consider in determining that.

What is the problem you are trying to solve? Forget about how you solve it, just tell us what you have now, and what additional thing you want it to do. There is surely a better solution than what I think you are proposing.
 

Thread Starter

wambecqa

Joined Dec 10, 2023
3
Hello BobTPH, let me try to clarify what I am looking for.
I am developing an application with a large number (say 256) of cells. Each cell has a momentary switch, and an RGB LED that can change color depending on the application, and the switches that are pressed.
The cells are controlled by a microcontroller, but the connection possibilities of the microcontroller are limited (say 50 digital input/output ports).
By using addressable LEDs, the needed ports for steering dynamically all the LEDs can be limited to just one port, using the WS2812b communication. (allowing for a re-coloring of all LEDs within 77 ms)
The WS2812b communication serializes the 24 (3*8) bits of all LEDs (which is a frame of 30 us), and chains all LEDs together in one large burst of e.g. 256*30us duration, followed by a reset period of at least 50 us. Each LED consumes the first 24 bits (to be its own setting) and then puts out the rest of the burst to the following LED. This gives the microcontroller full knowledge of at what moment a certain LED is actively consuming its own 24 bits.
There is no such mechanism, as far as I know, that allows the information on 256 switches to be collected in that timeframe with a smalll number of ports (say 5 to 10) on the microcontroller.
So the idea was to use a single input-port, time-multiplexing the switches, BUT also detecting simultaneous switch-activations.
For this, all switches need to have some logic around it to only signal the switch-pressed at the moment the LED is active with the communication.
To make the requirement short: How to collect information on 256 switches, within a short timeframe, and using reasonable amounts of ports on a microcontroller.
 

BobTPH

Joined Jun 5, 2013
8,653
I don’t need an explanation of the WS2812B, I have completed multiple projects using them on different microcontrollers.

I will try to digest what other information you have given and get back to you later.
 
Last edited:

BobTPH

Joined Jun 5, 2013
8,653
Here us how I understand your situation:

You have 256 units if some type, each of which has a single WS2812B LED and a single pushbutton.

The WS2812B LEDs are all connected serially through their Din and Dout pins. A single microcontroller controls the LEDs and needs to respond in some way to the pushbuttons.

You have noted that the first transition of the Din pin occurs at a different time for each unit.

You have proposed using that fact as a mechanism for scanning all the units and having each one place its button status on a single input to the micro during a short period while its LED is receiving its data.

Is this right? I think it is possible, but will definitely require additional hardware on each unit.
 

Thread Starter

wambecqa

Joined Dec 10, 2023
3
Hello BobTPH, you explained it exactly right!
So a cell shall only give a HIGH signal back during the period it is consuming its own RGB data on the DIN of that LED.
And of course I understand additional hardware is needed. But I am looking for as little number of components as possible.
 

BobTPH

Joined Jun 5, 2013
8,653
Hello BobTPH, you explained it exactly right!
So a cell shall only give a HIGH signal back during the period it is consuming its own RGB data on the DIN of that LED.
And of course I understand additional hardware is needed. But I am looking for as little number of components as possible.
Good. We are on the same page.

So, the problem with doing this simply, is that it has multiple states, it is not simple combinatorial logic.

I suggest there is a “button input” line coming from the micro, pulled high. Each unit can control this with a tristate signal, which is high impedance except when it is sending its button data when that unit and that unit only drives the line.

State 1: Initial state. Waiting to see a pulse on the Din line. Button line not driven. When a pulse is seen, go to state 2.

State 2: Active state. The button status is asserted on the button line. This state can be exited after a fixed time, or after some number of pulses. The timing of this will be critical because the micro is likely to be able to check the status only after completing the 24-bit data for this LED, but not into the data for the next LED.

State 3: Waiting for reset. Wait until no pulses are seen on Din for 150 usec, then go to state 1.

I am not good at designing hardware state machines, I have never done one. A micro might well be the minimal hardware solution, but the timing is critical and might be difficult to achieve using low end 8-bit micros.

With discrete hardware, at least two flip-flops are needed and maybe on the order of 5-10 gates. I am not up for designing that, maybe someone else could jump in.
 
Top