cancel
Showing results for 
Search instead for 
Did you mean: 

control algorithm for LED shift register

XooM
Associate III

Friends, which algorithm do you use to control the LEDs in this structure? I need your ideas. I have prepared a table of the LEDs' turn on order.

ttaa

 

34 REPLIES 34
SofLit
ST Employee

Hello,

Not sure what do you mean by


@XooM wrote:

Friends, which algorithm do you use to control the LEDs in this structure? 

 

Define a lookup table where you put your pattern.

const uint16_t tab[] = {0x8080, 0x8040, ....};

Then use this table to shift out the bits to the shift register.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
XooM
Associate III

Have you examined the electronic circuit?

for example, what should be the algorithm to turn on led1 led2 led3 and led4?

Because when led1 led2 led3 is active, the (2nd) 74hc4094 integrated circuit on the right has to give cathode information to all leds.
If you turn on led4 while led1 led2 led3 is on, how will you ensure that led5 and led6 remain off?

Andrew Neil
Evangelist III

I thought you said you had the LEDs working already?

Here: https://community.st.com/t5/stm32-mcus-embedded-software/scan-inputs-and-drive-outputs-after-delay/m-p/741955/highlight/true#M56925

Surely, the table you've provided tells you what to do - load the appropriate values into U1 and U2 ?


@XooM wrote:

what should be the algorithm to turn on led1 led2 led3 and led4?


That's what the table you posted tells you - it tells you what values to write to get each LED illuminated.

You said you already had this working:

https://community.st.com/t5/stm32-mcus-embedded-software/scan-inputs-and-drive-outputs-after-delay/m-p/741955/highlight/true#M56925:~:text=I%20said%20from%20the%20beginning%20that%20I%20can%20activate/pass%20the%20LEDs

 

Yes, I am doing this, I am sending the information of the LEDs that need to be lit with 250us. But the LEDs are dimly lit and there are very, very small traces of the LEDs that should not be lit.
I wanted to get your opinions on whether I need to change the control method.
Otherwise, I can control the LEDs, yes.


@XooM wrote:

 I am sending the information of the LEDs that need to be lit with 250us. But the LEDs are dimly lit and there are very, very small traces of the LEDs that should not be lit..


So why didn't you say that, then?

What do you mean by, "sending the information of the LEDs that need to be lit with 250us" ?

You should know by know that you need to provide a complete and clear description of what's going on - don't leave us guessing, and having to pull the information out of you bit-by-bit!

Show a minimum but complete code example.

 

PS:

It's already been noted that there are no current-limiting resistors in your schematic.

Is that just an omission from the schematic, or are they really not there in the actual hardware?

This is a LED matrix configuration.

You've already answered your question:


@XooM wrote:

Because when led1 led2 led3 is active, the (2nd) 74hc4094 integrated circuit on the right has to give cathode information to all leds.
If you turn on led4 while led1 led2 led3 is on, how will you ensure that led5 and led6 remain off?


You need to ensure that for each clock. And each data needs to correspond to that anode and cathode state at each step with a lookup table:

const uint16_t tab[] = {0x8080, 0x8040, ....};

This is based on the table shared by you:

SofLit_1-1732108215657.png

I don't want to enter in the details value and check the content of the table. I've already provided the concept.

PS:

Need to use transistors for the 74hc4094 on the right. I don't think the pin could sustain a such current consumed by all these LEDs (sink current).

SofLit_0-1732108034763.png

M74HC4094 datasheet:

SofLit_0-1732108633415.png

A proposed structure to prevent to exceed sink current:

SofLit_0-1732110837200.png

For each LED branch you need a transistor. In your case 3 transistors.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

@XooM wrote:

Yes, I am doing this, I am sending the information of the LEDs that need to be lit with 250us. But the LEDs are dimly lit and there are very, very small traces of the LEDs that should not be lit.
I wanted to get your opinions on whether I need to change the control method.
Otherwise, I can control the LEDs, yes.


Normally you need to mention the timing from the beginning.

The timing is the same as for the 7-segment display control, and you need for each step to let the LED to lit for 5ms duration. So 250us is a very short duration to let the human eye to catch the event.

SofLit_0-1732110357647.png

Look also at the HW structure. (source: https://www.st.com/resource/en/application_note/an1781-str71x-gpio-driving-four-7segment-display-stmicroelectronics.pdf)

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
XooM
Associate III

Yes, that's right, I'm using 3 transistors in my circuit as you said. I didn't want to show it here for my algorithm. I asked for some help with the coding part. I'll upload my own codes when I get home.