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

 

54 REPLIES 54

As I said 250us is very short, need to increase it to at least 5ms.

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.

There is a real circuit. There is a transistor for common cathodes in the circuit. There are also forward resistors for the LEDs. There is no mistake in the design. I can also share the full design. I did not want to consult about the design. I opened this title to ask your ideas for coding and maximum efficiency of the brightness of the LEDs.

XooM
Associate III

In LED display, segments are sent at once. Scanning is done as many times as the number of digits. In my design circuit, you have to scan 24 LEDs one by one. 24x5ms= 120ms causes very large flicker.


@XooM wrote:

There is a transistor for common cathodes in the circuit. There are also forward resistors for the LEDs.


So why didn't you say that?

Again, all we have to go on is what you post - if you post a schematic without essential parts, there's no way for us to tell if that's a genuine mistake, or just a simplification.

You could simply have said, "There is a transistor for common cathodes in the circuit. There are also forward resistors for the LEDs. These have been omitted for clarity"

 


@XooM wrote:

 I opened this title to ask your ideas for coding and maximum efficiency of the brightness of the LEDs.


Again, you didn't say that.


@XooM wrote:

. In my design circuit, you have to scan 24 LEDs one by one. 24x5ms= 120ms causes very large flicker.


No. You need to keep the 24LEDs to lit for 5ms at the same time.

For that you need to shift all these 16bit followed by a LATCH enable to keep the data during 5ms. 

You need to check that with an oscilloscope.

 

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:

In LED display, segments are sent at once. 


How, exactly?

First, you need to clock the data into the shift registers.

Then you need to latch that data onto the outputs.

What do you mean by "segments" here?

 


@XooM wrote:

Scanning is done as many times as the number of digits. 


What do you mean by "digits" here?

 


@XooM wrote:

In my design circuit, you have to scan 24 LEDs one by one. 


Why "one by one"?

 


@XooM wrote:

24x5ms= 120ms causes very large flicker.


What is the 5ms?

 

Again, Show a minimum but complete code example.

 

PS:

Do you have access to something like Proteus?

It might help you to be able to simulate the hardware independently of the software.

That way you could concentrate on working out what needs to happen in the hardware, and then implement that in your software...

A lot has already been said in this topic. I'd like to ask a few questions:

  1. What is the purpose of this project? (What are the requirements?)
  2. What are the LEDs connected to? 7 segment displays?
  3. Does each LED have its own current limiting resistor or are those shared by a group of 3?
  4. what strobe rate do you want?
  5. Are glitches in strobing allowed or do you not want LEDS to glitch momentarily?
  6. I see data of second shift unconnected that is not good. How do you intend to control that?

The LED's need to be controlled via strobing if you want to allow all LEDs to be controlled individually (due to persistence of vision at sufficient strobing rates). Otherwise you cannot get all combinations working.

In this case you have 8 groups of 3 (or 3 groups of 8 depending on how you see it)

So I would implement the algorithm the following way:

  • set LED selector to 100
  • set group selectors to 1 for each group that has first LED on
  • delay T/3
  • set LED selector to 010
  • set group selectors to 1 for each group that has second LED on
  • delay T/3
  • set LED selector to 001
  • set group selectors to 1 for each group that has third LED on
  • delay T/3
  • repeat

If you don't want any glitch you need write zeros to one of the shift registers prior to changing (dead time) the other or daisy chain them and Latch them synchronously (no overlap).

The LEDs that need to be on are only on 1/3 of the time. For instance for 333us if you want a strobing rate of 1kHz. So you need to increase the current. If 10mA is the desired continuous current you need to use 30mA. But check the datasheet for maximum pulsed current for the LEDs.

You can use a loop and simple bitshifting to check which group has an LED on. You can store all LEDs in a single uint32_t led_states . group_state[x] = led_states & 1<<(x*3+led_shift)

 

 

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.

@unsigned_char_array wrote:

In this case you have 8 groups of 3 (or 3 groups of 8 depending on how you see it)


I don't think that's true?

I think one 11-bit pattern can be used to turn on any number of LEDs - including all or none?

 

@XooM show the full schematic - transistor, all resistors, etc - for one group of three LEDs

Or confirm if @SofLit guessed correctly with this:

AndrewNeil_0-1732114228000.png

Is there really only one R1 per group of 3, or is there a separate series resistor for each LED ?

 


@Andrew Neil wrote:

@unsigned_char_array wrote:

In this case you have 8 groups of 3 (or 3 groups of 8 depending on how you see it)


I don't think that's true?

I think one 11-bit pattern can be used to turn on any number of LEDs - including all or none?


The groups are connected in parallel. So you cannot have:

 

LED0: 1
LED1: 0
LED2: 0
LED3: 0
LED4: 0
LED5: 1

 

simultaneously.
Because group 0 has LED0 on and group1 has LED3 off and group0 has LED2 off and group1 has LED5 on. Since both groups have active LEDs they need to be selected.
With strobing it is possible because the eyes see fast pulsed LEDs as on. Either in 8 steps of 3 or 3 steps of 8. The latter is quicker and requires less peak current.

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.

@Andrew Neil wrote:

@unsigned_char_array wrote:

In this case you have 8 groups of 3 (or 3 groups of 8 depending on how you see it)


I don't think that's true?

I think one 11-bit pattern can be used to turn on any number of LEDs - including all or none?

 

@XooM show the full schematic - transistor, all resistors, etc - for one group of three LEDs

Or confirm if @SofLit guessed correctly with this:

AndrewNeil_0-1732114228000.png

Is there really only one R1 per group of 3, or is there a separate series resistor for each LED ?

 


Just missed one resistor per LED to limit the current. Need to remove R1 in this case.

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.