LED Colour Organ using 20X2 and MSGEQ7 Freq Analyser chip

hamtech

Member
I have in mind using a Picaxe 20X2 and the new Graphic analyser chip MSGEQ7 to make a colour organ . My problem is with using PWM.

I know what it is, but don't understand the difference of implementation on a PICAXE chip. Those I have looked at have both HPWM and a PWM output. The MSGEQ7 has 7 output channels of which six are probably the most l would want. Is it possible to use HPWM and PWM at the same time so I can drive six LEDs. Not sure I can, or if there is a chip with enough PWM outputsso I can drive all channels.

Can anyone give me some advice and guidance please
 

nick12ab

Senior Member
How exactly do you want to use the frequency analyzer chip? Check the levels with the PICAXE and then drive the LEDs from the PICAXE?

The maximum number of pwmout channels are four and you are limited with the ability to use hpwm at the same time and timer sharing on certain pins (see pwmout page) means that you can't have all the PWM channels at different frequencies although that won't matter since you're only driving LEDs so they can all be the same frequency.

Another approach is to bit-bang PWM on the LEDs - that way you can have as many PWM channels as you want but you'll be limited to maybe 16 levels of brightness.

A third approach is to use an analogue multiplexer to demultiplex the output from the MSGEQ7 then feed each output into an op-amp which can drive an LED.
 

hamtech

Member
How exactly do you want to use the frequency analyzer chip? Check the levels with the PICAXE and then drive the LEDs from the PICAXE?

The maximum number of pwmout channels are four and you are limited with the ability to use hpwm at the same time and timer sharing on certain pins (see pwmout page) means that you can't have all the PWM channels at different frequencies although that won't matter since you're only driving LEDs so they can all be the same frequency.

Another approach is to bit-bang PWM on the LEDs - that way you can have as many PWM channels as you want but you'll be limited to maybe 16 levels of brightness.

A third approach is to use an analogue multiplexer to demultiplex the output from the MSGEQ7 then feed each output into an op-amp which can drive an LED.

Thanks for your suggestions. What I want to achieve is for each channel to drive the brightness of the corresponding channel LED acording to the amplitude received by the adc.
The MSGEQ7 chip has to be strobed and after each strobe pulse it puts a value on the output in sequence, which can be read by the adc and stored as a value. The stored value would be provided to the PWM output to control brightness. That's sort of what I had in mind.

Not sure how I couldlink the two 14M2s together for PWM as suggested by Eclectic..
 

Buzby

Senior Member
The Master reads all 8 values from the MSGEQ7.
It drives 4 PWMs from 4 of the values, and sends the remaining 4 by using 'serout' to the Slave.

The Slave receives the values ( using 'serin' ), then drives 4 more PWMs.

Simples !
 

hamtech

Member
The Master reads all 8 values from the MSGEQ7.
It drives 4 PWMs from 4 of the values, and sends the remaining 4 by using 'serout' to the Slave.

The Slave receives the values ( using 'serin' ), then drives 4 more PWMs.

Simples !
Thanks I 'll have a look at that and also at Nicks altenatives. Thanks all.
 

eclectic

Moderator
Not correct code, but just for illustration
Say you use a notional 15900 Hz

pwmout B.2, 62, 126 ; 50% 15.9 kHz
pwmout B.2, 62, 252 ; 100%
Join say pin B.1 on each 14M2 (via a 1k resistor)

The "master" calculates the values.
The values are converted to the range 0 (0%) to 252 (100%)

Switches on two of its own pwmout pins
Four values, say b0, b1, b2 and b3 are to be sent.

Master
Serout B.1, n2400, (b0, b1, b2, b3)

Slave
Serin B.1, n2400, b0,b1,b2,b3
pwmout B.2, 62, b0
pwmout B.4, 62, b1
pwmout C.0, 62, b2
pwmout C.2, 62, b3
go to standby receive.

e (and oe)
 

premelec

Senior Member
I'll mention one more approach I've used successfully driving LED strings: I used an 08M and TLC2543 8 channel DAC to drive constant current - set by the DAC values - with this method there is no strobing problem [light flicker from PWM] - it's not so energy efficient as the constant current drivers [a transistor with emitter resistor] dissipate some energy more than PWM. The DAC has two separate reference inputs if you want to use those for additional modulation possibilities. A lot depends on how fast you want the color organ to follow the sound... in my case I was changing currents fairly slowly.
 

hamtech

Member
Or, for LED's, stick with a single chip and multiplex two sets of LEDs per PWM output pin.
An interesting thought. I have 7 LEDS to light at most though probably will only use six. I am fairly sure I can sort the clocking of the sound chip by using pulseout and reading input by ReadAdc but am struggling with the HPWM . I have tried to understand how multiplexing output to leds might be possible, grateful if you could go into a little more detail. I envisage having let us say 6 outputs connected to LEDs that I weant to control brightness of by varying the duty cycle??. Would that be the way to connect the leds , and given that HPWM is only available on 4 pins how do I resolve that. Any thoughts to give me a steer would be appreciated. I may still may try the two chip approach at a later date, but this is attractive if I can understand how it would work.

Thanks in anticipation
 
Last edited:

hippy

Ex-Staff (retired)
Would that be the way to connect the leds , and given that HPWM is only available on 4 pins how do I resolve that.
You don't want HPWM, just PWMOUT.

Connect a PWMOUT out channel to the anode of a LED+R and its cathode to an output pin. The LED will only be controlled by the PWM when the cathode controlling output pin is set low.

Connect the PWMOUT out channel to the anode of another LED+R and its cathode to a different output pin. This LED will only be controlled by the PWM when its cathode controlling output pin is set low.

Alternate setting cathode controlling output pins low with different PWMOUT duties and you will be controlling two LED's from one PWMOUT. Use three PWMOUT's for six LED's.
 

hamtech

Member
You don't want HPWM, just PWMOUT.

Connect a PWMOUT out channel to the anode of a LED+R and its cathode to an output pin. The LED will only be controlled by the PWM when the cathode controlling output pin is set low.

Connect the PWMOUT out channel to the anode of another LED+R and its cathode to a different output pin. This LED will only be controlled by the PWM when its cathode controlling output pin is set low.

Alternate setting cathode controlling output pins low with different PWMOUT duties and you will be controlling two LED's from one PWMOUT. Use three PWMOUT's for six LED's.
hippy thanks. not sure what you mean by LED+R what it refers to but i got the gist of your post, however does it not mean that I can only ever have three Leds alight at any one time or am i missing something. (Wouldn't surprise me nor be a first). I would want all leds on if the output from the graphics chip called for it. Am I being thick?
 

hamtech

Member
LED + R Ah I see.

Hippy thanks. Yes that would work if the switching was fast enough over 30 times a sec would probably be enough. I will look at using PWMout inthis context..
 
Top