pwmout / hpwmout confusion on 14m2 / 20m2

PaulRB

Senior Member
Please help me clear the brain-fog on this one... can't seem to figure it out by reading manuals or searching the forum.

Q1. Can pwmout be used to generate pwm signals on more than one pin simultaneously on 14/20m2?

Q2: how many simultaneously and on which pins? Pins marked hwpm in the manuals?

Q3: are there any limitations, e.g. must be same frequency but can be different duty cycles?

Q4: what are advantages/limitations of hpwm vs. Pwmout?

Thanks!
 

nick12ab

Senior Member
Q1. Can pwmout be used to generate pwm signals on more than one pin simultaneously on 14/20m2?
Yes.

Q2: how many simultaneously and on which pins? Pins marked hwpm in the manuals?
The pwmout command can be used on the pins marked as having pwm on the relevant pinout diagram. The hpwm command can be used with pins marked as having hpwm on the relevant pinout diagram.

Q3: are there any limitations, e.g. must be same frequency but can be different duty cycles?
Yes - certain pins share a timer so must be the same frequency but can be different duty cycles. Other pins do not share the timer and can have a different frequency. The shared pins are C.0 + C.2 on PICAXE-14M2, C.3 + C.5 on PICAXE-20M2, C.1 + C.2 on PICAXE-28X2. See pwmout.

Q4: what are advantages/limitations of hpwm vs. Pwmout?
A description from hpwm:

Hardware PWM is an advanced method of motor control using PWM methods. It can use a number of outputs and modes, as defined by the PIC microcontroller's internal pwm hardware.

hpwm can be used instead of, not at the same time as, the pwmout command on 2 (28/40 pin). However pwmout on 1 can be used simultaneously if desired.

hpwm gives access to the advanced pwm controller in the PIC microcontroller. It uses up to 4 pins, which are labelled here A,B,C,D for convenience.. Some of these pins normally 'default' to input status, in this case they will automatically be converted to outputs when the hpwm command is processed.
 

hippy

Technical Support
Staff member
Q1. Can pwmout be used to generate pwm signals on more than one pin simultaneously on 14/20m2?
A PWMOUT command can control one pin, multiple PWMOUT commands can be used together to control a number of pins.

A HPWM (HPWMOUT) command can control one to four HPWM pins simultaneously.

Q4: what are advantages/limitations of hpwm vs. Pwmout?
It's a bit of an abstract question like whether one style of vehicle is better than another. It really depends on what it is you want to do; which is most appropriate for that.

PWMOUT is most suited to independent control of PWM pins. HPWM is most suited to collective control of HPWM pins.

HPWM is useful for driving the simplest H-Bridge circuits but many H-Bridge circuits can also be driven by PWMOUT and other control pins.

HPWM can be used to create PWM output on pins that cannot be controlled by PWMOUT.
 

radiogareth

Senior Member
OK, fog clearing a bit too, .....but can you use PWMOUT and HPWMOUT at the same time (not on the same pins)?
E.g. PWMOUT on C.2, B.2 & B.4. (RGB)
Could I use HPWMOUT on C.0 and b.5? (2 strings of white LEDs for instance).

Not asking much am I ;-)
 

Peter Graat

New Member
Make this thread alive again... Try to use the HPWM-command. Was struggling with the syntax and especially with the PWMDIV4-qualifier. On the top of the page the syntax is mentioned e.g. HPWM DIV4, mode, polarity, setting, period, duty and it should be:
HPWM PWMDIV4 etc. Is it possible to change this in the manual. Thanks....
 

Peter Graat

New Member
Thanks Hippy, but maybe I have found another typo.... In the description of the HPWM command the pinning is given for a 14pin device. The reference to 14M2 is not correct.
A = input 2 on 14M = C.2 on 14M2
B = input 1 on 14M = C.1 on 14M2
C = input 0 on 14M = C.0 on 14M2
D = output 5 on 14M = B.5 on 14M2
 

hippy

Technical Support
Staff member
I have added that to my note, updated the online reference. Thanks.
 

Peter Graat

New Member
Hi Hippy, in your post #7 indeed the online command reference is changed and now correct. But today I have printed out the latest Manual 2, rev 7.9.2 and there still the wrong syntax in the header is mentioned. Further in the description (approx in the middle of the page) indeed is referenced to PWMDIV. Hope this can be changed in the next iteration of the manual.
 

hippy

Technical Support
Staff member
Unfortunately it does appear we missed that in the syntax description for HPWM and I will log a report for that.
 

PhilHornby

Senior Member
The online documentation (hpwm - BASIC Commands - PICAXE ) says:-

Single Mode

Supported:20X2, 28X1, 28X2, 28X2-3V, 40X2, 40X2-3V
Not Supported:14M, 14M2, 20M2, 28X2-5V, 40X1, 40X2-5V
In single mode each pin works independently.

However, I just discovered that 'Single mode' definitely does work on the 14M2. It cannot be used at the same time as pwmout
Better late than never ;)
 
Top