Multiple Independent PWM outputs?

stevepr

New Member
I have a neat little Picaxe 8M unit driving a MOSFET-based LED constant current driver running a bank of 3 watt LEDS via the single PWM output to allow full PWM based dimming. The 8m simply translates the 1-10v output from my controller system (a GHL Profilux system, although it could be a Picaxe-based solution!) into a PWM output stream (where duty cycle is proportionate to the input voltage). No problems there, works really well and is drop dead simple. However, I actually run four separate LED banks (currently using 4 separate 8M's). Since the enclosed system can get quite warm from the power supply (a spare notebook switched PSU unit) I am adding a 12volt fan, but it would be cool (sorry for the pun!) to make the fan variable depending on the temperature - either using a thermistor/resistor voltage divider and the AD input or a DS 1-wire device to drive another PWM output to the fan - another 8M! It would also be useful to check the ambient light (LDR/resistor divider) to amend the PWM output on the LED drives to adjust for ambient light levels.

Checking through the specs it doesn't seem possible to drive more than 1 PWM output from any PICAXE. The HPWM output doesn't seem to do the trick. The pwm command might allow a pwm output on a pin but would need to cycle round fairly quickly across the pins - don't think that is going to work.

As an interesting aside, I actually had to UNDERCLOCK the chip down to 125kHz (there's a novelty, usually we are trying to speed things up) to get the PWM frequency on the 8M down below 200Hz which is the max PWM input frequency for the MOSFET driver.

Any suggestions, ideas, or do I just take the simple route of running multiple 8Ms, one for each LED bank and another for the fan?

I'll post the schematics and code (all 3 lines!) if anyone is interested. This is for driving LED lighting systems on aquariums but could be used in other applications.

Steve
 

stevepr

New Member
Here is the code

OK, it is actually more than 3 lines, but only because I had to invert the output and added the inevitable extras!

' Create PWM output on pin 2 (Picaxe 8M)
'
symbol pw_out = 2 'pin for PWM output signal to RECOM RCD24 MOSFET LED driver
symbol adc_in = 4 'input pin for 1-10v interface (via voltage divider)
symbol lumin = w1 'word variable for inverted luminance value

poke $8f, %00010000 'UNDERCLOCK to 125kHz, produces PWM at 121Hz approx

pause 10 'allow to stablise

main:
readadc10 adc_in, w2 'value in range 0-1024 (hi value = hi voltage)
lumin = 1024-w2 'invert it to drive RECOM
if w2 < 10 then
lumin = 1024 'turn off completely on low values
endif
pwmout pw_out, 255, lumin 'control pwm output stream

goto main



As I said - pretty simple. I don't claim it is elegant, but it does work! Getting the clock speed down was the challenge, but the answers were all to be found on this forum - a great resource!

Steve
 

hippy

Ex-Staff (retired)
The 28X1/40X1 and 28X2/40X2 can both run two independant PWM ( variable duty, though at same frequency ), however, I'd probably go with what you have which is tried and tested, proven to work and add another 08M. Besides, even if you did replace four 08M's with two X1/X2's, you'd still be short of a PWM channel.
 

premelec

Senior Member
I recall al-williams.com has an 8 channel setable PWM called PAK V. A bit pricey and power hungry but set wtih serial signal...

My own solution to controlling 8 channels of power to some lights was to use a TI 8 ch DAC with a sawtooth and comaprators [ 2 LM324 ] to drive triacs. The DAC channels are set by a PICAXE 08M and just keep the same values until a new value is downloaded from 08M. It worked very successfully....

Good luck with it!
 

BCJKiwi

Senior Member
If all 4 banks of LEDs are to run at the same intensity, then hpwm in full mode will do the 4 banks off the one chip, A separate 08M could be used for the fan.

Check out pages 70 & 71 in Manual2 v6.9
 
Top