Which AVR would fit my project ?

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

Hey everyone,

I'm aiming to use a mega328p to drive an rgb led strip.
I would like to have the following features:

1. Ability to drive a the 3 rgb channels at 7 or 8 bit pwm AFTER gamma correction, therefor I think i would need an effective 16 bit pwm (or 10/12 at least).
I can't achieve this with hardware pwm, only software pwm.

2.The ability to drive these led, from an audio source which will be fed to the A/D. Maybe some FFT to be done or at least some basic audio analysis to animate the led strip according to the beat or whatever.

3.Interfacing and communicating through bluetooth, to set setting and change animation types and such.

4.Having software RTC
------------------------
Can a mega328 handle all of this ? especially having 3 channel software pwm (or BAM) while doing simple FFT ?

Or should I switch to a mega128 and drive the leds from hardware pwm ?

Thanks in advance,
Mike.

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

Quote:

1. Ability to drive a the 3 rgb channels at 7 or 8 bit pwm AFTER gamma correction, therefor I think i would need an effective 16 bit pwm (or 10/12 at least).
I can't achieve this with hardware pwm, only software pwm.


Now I'm curious--can you give a reference on gamma correction, and why hardware PWM is inferior to software PWM?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

I answered much of my first question by searching this forum for prior "gamma correction" discussions. The second question about not being able to achieve with hardware PWM is still a mystery to me.

(I guess a very short answer would be to use an AVR model with three or more 16-bit PWM channels (and all Xmega would fit that criterion). But hardware PWM isn't allowed...)

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

So its a color organ. How many channels? How can we do a cpu budget without some perf specs? (I;ve tried this with hi and lo pass iir filters rather than fft)

Imagecraft compiler user

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

In terms of compute performance, a mega128 isnt going to do any better than a mega 328. The major difference is ram, peripherals and i/o.

A FFT is probably not the best choice, you might be able to get away with simple filtering or a Goertzel.

I'm also puzzled about the gamma correction - I would've thought it was a lookup table regardless of the actual pwm method. PWM is pwm regardless of how you implement it.

As to whether it will all fit onto a mega328 is up to you. If it doesnt fit, just move the code to a bigger/faster cpu.

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

Quote:
Or should I switch to a mega128 and drive the leds from hardware pwm ?

m128 has two 16-bit timers with 3PWM channels each so it is definitely easier than playing with software PWM. After that, when the results are satisfactory, you can switch back to attiny.

No RSTDISBL, no fun!

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

Don't use an AVR. It isn't appropriate to this task. The AVR could do this job, but it would be much more:

easier,
cheaper,
fun,
reliable,

with a Texas Instruments LP3950 Color LED Driver with Audio Synchronizer integrated circuit or two.

Most people on AVRfreaks will give you great advice on how to get an AVR to do whatever you can imagine. Well, duh, yeah, it's an AVR specific site.

But few people here will just recommend using an analog or near-analog specialized integrated circuit to do the task better.

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

theusch wrote:
The second question about not being able to achieve with hardware PWM is still a mystery to me.

Since our eye's response to light isn't linear (we are much more sensitive to low light) the gamma correction compensates for that.
Therefore, I will need more resolution at low duty cycle.

Gamma correction might not be exactly the term for that. As I said it's more like fitting the led linear response to our eye's exponential response.

The whole purpose is to drive a single RGB led strip that means 3 pwm channels (as I said before).
---------
As I said before, the obvious solution is to use a different avr with 3 hardware 16 bit pwm channels (like the atmega128).

Obviously I could use two avr chips and split the work between them, or get a pwm chip like the LTC5940 or something.

But I would rather try to fit it all in the atmega328p since it much much more common and easy to use (DIP package).

I don't have to use FFT for the mic input visualization, I just don't know any other visualization algorithms.

Any suggestions on how to visualize the audio in the room (music) to light up the led strip ?
Beat detection is very simple (too simple).

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

hehe

In the '70s I made one of these with 741 op amps and SCRs. A low pass filter, a midrange filter and a high pass filter made a quite dynamic display. Mom thought it was a hoot when I plugged in the Christmas tree lights and played Christmas music.

 

"We trained hard... but it seemed that every time we were beginning to form up into a team, we would be reorganized. I was to learn later in life that we tend to meet any new situation by reorganizing. And a wonderful method it can be of creating the illusion of progress while producing confusion, inefficiency and demoralization." Petronius Arbiter, approx. 2000 years ago.

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

Quote:

Therefore, I will need more resolution at low duty cycle.

-- Many of the links that I followed use 8-bit PWM for "gamma-corrected output" after doing a table lookup
-- With a bit of fussing, I'd think that you could have one color be the "master" with an 8-bit value, and then have the other two colors use 16-bit PWM in relation to the "master".

IME, the 150/meter light strips look like discrete LEDs anyway, and (especially the silicone-encased waterproof) don't blend the colors all that well even with a diffuser. (I.e., one can see the pinpoint of the R & G & B.) Perhaps yours are different.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

I still didn't get the strip I ordered but the one I ordered is 60 leds/meter, each led is a 5050 smd rgb led.

I never saw an RGB strip with discrete red blue and green leds, if that's what you meant.

I don't really see the benefit of having a master color at 8 bit pwm, I mean it's better than having all 3 colors at 8 bit pwm.
Wouldn't it make a sluggish color transfer when the "master" color is on low duty cycle ?

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

There's also Mega1284P, Mega(16/32)U4 with at least three 16 bit PWM channels.

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

Gamma correction has to do with brightness compensation on cathode ray tube phosphor doesnt it?

Imagecraft compiler user

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

Yeah Bob, but you can apply the same "formula" to match the linear led light to match the non linear eye sensitivity.

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

Like Torby I recall Color Organs of days gone by using an analog hardware front end and SCRs or Triacs to drive the output for the various channels. The mic would feed several gain stages and then three filter channels.

One could certainly "update" the design a little, with op-amps for the mic gain and analog filters, feeding 3 ADC channels, and then a look up table, followed by 3 PWM outputs.

I think it is important to decide how quickly the system is suppose to update the PWM data.

There have been several Threads on FFTs on AVRs. Search should help to locate them. The two issues seem to be both speed and memory for the rather large data arrays.

The only good thing about a three channel system is that one only needs a few Frequency bins for the entire audio spectrum. eg Calc an 8 bin FFT, 1-3 = Bass, 4 & 5 = Mid, 6-8 = Treble. Sum them for a simple energy estimate for that portion of the spectrum.

There is lots of info available for making FIR and IIR digital filters. Truly cool to see them work.

I suspect you want to do this project with an AVR, which is great. There are micros with multiply and add instructions that make FFT calcs much faster, and DSP chips that are specifically designed for this type of task.

JC

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

Quote:

I never saw an RGB strip with discrete red blue and green leds, if that's what you meant.

Depending on the particular 5050 RGB LED used and its in-built diffuser, many times you can spot the e.g. red LED(s) in the 5050 package when displaying an arbitrary RGB color.

Quote:

Wouldn't it make a sluggish color transfer when the "master" color is on low duty cycle ?

??? if the PWM frequencies are roughly the same, what would be "sluggish"?

I don't know whether the "master" approach would work or not. Here is what I'm thinking... 8-bit PWM has 256 steps; let's say 200 so each step is about 0.5% of full duty cycle.

So if you want e.g. 0.75% then you use e.g. 0.5% and feather the 16-bit PWMs on the other channels down by a corresponding amount. Just a theory.

Another story: I've got a current industrial app where a strip of RGB is to be mounted on the device for indication. A very simple app compared to yours--only Green ("good to go"), Red ("cannot proceed"), and Yellow (warning condition) are to be generated.

So the app is quite simple compared to yours. What we found is that the simple Yellow, Red+Green, is too green on most strips. So Yellow might be tuned to be 100% Red + 60% Green.

But then you get another strip with seemingly identical specs from a different source. That one might need only 40% Green to get approximately the same yellow color to the eye.

So once you get the app all tuned up to your liking with a gamma-correction lookup table, I predict that you will get a rude surprise when you get another reel that isn't identical to the one you are using.

AT90PWM3 would do the PWM part but may not have neough resources for the rest of the stuff.

I've seen simple "color organ" approaches where instead of FFT or similar processing, a series of notch filters gives values in a handful of frequency bands.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.