Linear intensity !

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dea freinds
I have used a 8 bit pwm wave to control the intensity of 128 leds! using my spartan device!( i have used 74xx buffers).but the problem is that the led intensities are not linear respect to the 8 bit value.Is there a solution for the problem?

Any ideas are welcome :idea:

I love Digital
and you who involved in it!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

lookup table?

Linear in respect to what? Your perceived intensity? In which case remember the human eye is not linear!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's logarithmic, like hearing.

Leon Heller G1HSM

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The light intensity from a LED is very linear to its current. We have done a lot of tests with this for current measuring on the high side of a 4000V power supply, and we only had to do gain and offset compensation. The same was seen when we did a ~2 inch separation optocoupler.

A more complicating problem is aging. The LEDs loose intensity quite fast over the hours. If you want them stable you need to age them. Let them run for 2-3 weeks and they should be a lot more stable. Some LEDs are a little less sensitive to aging.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But intensity and perceived intensity are not the same! and I guess Ali wants visually linear dimming! So he needs to implement gamma correction!

This Maxim appnote might be useful: http://www.maxim-ic.com/app-notes/index.mvp/id/3667!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, but since the LEDs are linear he should focus on the human eye model for light perception.

So something logarithmic.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

and to accomplish that, he's going to need more than an 8 bit PWM if he wants to have 8 bits of intensity.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

He did say he was using a Spartan programmable logic chip, so he should not be limited to a 8-bit PWM. It's pretty easy to switch a 8-bit peripheral core to a 10 or 16 bits PWM.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yeah, was just pointing it out. IIRC the bare minimum is 12bits.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Guys thanks for your replies.
there is another question.
can you suggest a better solution? dose 12bit pwm solve the problem? how should i connect the 8 bit data to 12bit pwm module? what is the bit order? can you give me a hint on led driver circuit? remember i need things to be as cheap as possible.

I love Digital
and you who involved in it!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It is not a simple mapping, you need to calculate the 12bit value from the 8 bit one. [or look it up from a pre-calculated table] The relationship is logarithmic. Do as suggested earlier, study on the human eye model.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

8-bit data in, 12-bit lookup table with 256 entries.

You could use PPM or PWM modulation, whatever is easier for you - same duty cycle. Drive the LED via resistor.

But the real question is, do you really need 256 different intensities? Are you able to see the difference between two of them? Would 16 intensities suffice to create 8-bit logarithmic PWM values?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
8-bit data in, 12-bit lookup table with 256 entries.

Hi Jespael.
can you explain it more to me.And in fact i need the 8bit intensities.

I love Digital
and you who involved in it!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Let me explain in pseudocode:

uint16_t LEDLUT[256];

for (uint8_t i=0; i<=255; i++)
    LEDLUT[i]=exp_something_curve(i);

later on:
 intensity=42; // 0..255 = linear intensity
 PWMVALUE=LEDLUT[intensity]; // convert to 12 or 16-bit pwm value

Point being, when you use 8-bit linear values for PWM, you see big difference between 0 and 1 or 1 and 2, but you don't see any difference between 254 and 255. So you must make a lookup table so, that in the low end, lut[0]=0 and lut[1]=1, but in the high end, the values may be lut[255]=4000 and lut[254]=3500, i.e. bigger spacing.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your reply.but the problem is how to calculate the table data.do you have any suggestion.

thanks for your time.

I love Digital
and you who involved in it!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jayjay already posted the best suggestion there is. It does gamma correction with value of 2.5, I guess anything in the ballpark would do.

Edit: So basically, in a spreadsheet program, you scale your 8-bit input values from 0..255 (or any other range you may end up with) to range 0..1, raise them to the power of 2.5, and multiply with the value how many PWM counts you have, like 65536 for 16-bit PWM.

Did you notice, that if you want exactly 256 different intensities, you need a 20-bit PWM counter range, for 128 intensities a 16-bit PWM value is enough, and for 64 intensities a 14-bit PWM value should be enough.