hpwm + pwm??

tazzik

New Member
Hi,
For my GCSE project I am writing a BASIC program for an as of yet undecided, 28X1 or 40X1 (really need the X2 to come out soon). To decide on 28/40X1 I need to know, what is the difference between hpwm and pwm. I am using pwm to drive MOSFETS, in turn driving banks of LEDs (25R, 25G, 25B, 25Y, 25W).
So what is hpwm and pwm and are they interchangeable, or if not can they both be used for this project.

tazzik
 

BrendanP

Senior Member
If you have a look at the picaxe 'basic commands' manual ,which is availiable for free download at the picaxe web site, you'll will find a explanation of all the commands, pwm and hpwm inlcuded. The index at the front lists all the commands. The manual explains what the command does, whic picaxes it will and wont work with and also gives a example of the command in use. Once you have a read of that youll be able much better understand any explantions people will give you here. People here will bend over backwards to help you but you need to have a basic grasp of what is going on as well.
 

tazzik

New Member
having re-read the manual, didn't know there was 3 parts! So my new question, can I somehow configure hpwm, to act the same as pwm, as in can I get it to drive some LEDs?
tazzik
 

hippy

Technical Support
Staff member
having re-read the manual, didn't know there was 3 parts! So my new question, can I somehow configure hpwm, to act the same as pwm, as in can I get it to drive some LEDs?
tazzik
The simple answer may be that if you just want PWM then don't use HPWM, use PWM !

HPWM is for controlling motors using H-Bridge drivers or in routing a single PWM to one of four outputs. HPWM does not give four separate, independant PWM which can be used at the same time ( unless you want the exact same PWM signal sent to all outputs ). You can however put PWM out on one output, stop that, change the PWM and put it on another output, stop that and move on to the next. That is great for doing four channel Resistor-Capacitor style Digital to Analogue conversion but perhaps not that useful for PWM control of Leds.

How you want your Leds controlled - what you want to achieve as an end result - will dictate what you need to do to control them. Without knowing that it's not clear what the best way to provide control will be.

You're currently asking advice on a solution when we do not know what the requirements are :)
 

Tom2000

Senior Member
One strategy you might use to light five banks of LEDs with one PWM output is time-division multiplexing.

You'll need access to both ends of your LED banks to do this.

Let's say that the top of the banks are common and that you're driving them with a P-channel MOSFET. You'd drive this MOSFET with the PWM line from your processor.

Now you'll take five digital outputs, each driving one of the N-Channel MOSFETs that you're using to switch the cathode ends of each LED bank.

Your LED drive loop would look something like this:

Top of loop:

Set PWM for bank 1 brightness
Turn on bank 1 N-channel
delay
Turn off ban1 N-channel
Set PWM for bank 1 brightness
Turn on bank 1 N-channel
delay
Turn off bank 1 N-channel

Set PWM for bank 2 brightness
Turn on bank 2 N-channel
delay
Turn off bank 2 N-channel

Set PWM for bank 3 brightness
Turn on bank 3 N-channel
delay
Turn off bank 3 N-channel

Set PWM for bank 4 brightness
Turn on bank 4 N-channel
delay
Turn off bank 4 N-channel

Set PWM for bank 5 brightness
Turn on bank 5 N-channel
delay
Turn off bank 5 N-channel

End of loop

If this method wouldn't result in sufficient LED brightness (and it very well might not, with five banks of LEDs), consider five slave 08Ms, each generating PWM for one bank of LEDs, commanded by serial commands from your master processor.

If you could limit this to four LED banks, you could eliminate the P-channel and use the hpwm to drive the N-channel switches at the bottom of each of four banks. Again, you might run into the brightness degradation caused by the four-way time division multiplexing.

Good luck!

Tom
 

tazzik

New Member
Thanks, lots of good ideas, what I thinkI will end up doing is the main chip driving 5 08Ms, can the serial output of the main chip link upto 5 other chips, or will it be main chip > 1st 08M > 2nd 08M > 3rd 08M etc...?
tazzik
 

leftyretro

New Member
Thanks, lots of good ideas, what I thinkI will end up doing is the main chip driving 5 08Ms, can the serial output of the main chip link upto 5 other chips, or will it be main chip > 1st 08M > 2nd 08M > 3rd 08M etc...?
tazzik
One can drive all 5 08Ms serial input pins from a single 'master' serial output pin, however the message sent will have to have an 'address' in it a well as the data value so that only the proper specific 08M responds to the command.

Lefty
 
Top