Using PWM or HPWM

AllyCat

Senior Member
Hi,

Basically, Yes. HPWM provides 4 output (pin) signals, synchronised in Frequency and Duty Cycle (but differing in polarity and phase). You can use any one of those output pins as a "normal" PWM drive and ignore (i.e. not use) the remaining pins. Or it may be possible to configure the HPWM module to disable the unwanted signals (so that they can be used for another purpose), perhaps by direct command, or by a POKESFR, depending on the particular PICaxe chip.

Cheers, Alan.
 

Gramps

Senior Member
4 output (pin) signals


Sounds interesting. How is it used?
depending on the particular PICaxe chip.
The 28X2 chip. It has 4 PWM pins C.1, C.2, B.0 and B.5.
An old drawing of the 28X2 chip I have only showed C.1 and C.2 as being PWM pins.
Four is plenty for what we want to do.
The plan is to use the BNO055 9 DOF Absolute Orientation IMU Fusion Breakout board to control three pots.
"Yaw and Pitch" feed the MD20A motor controllers. They need a PWN signal.
"Roll" positions the rotator cuff, a servo.
It's not clear to me which pins we can use to position a servo. Any ADC pin?
 

inglewoodpete

Senior Member
I have used the 28X2 to operate 4 channel lighting for several commercial lighting projects with specific requirements (RGB&W channels). I can say it does the job well for lighting purposes.

If you are wanting to use 4 different clocking speeds (Eg One for each channel), then you may have some problems. Some of the PWM channels (pins) in the 28X2 share a clock module. The most important parameter, output duty, is independent for each of the four channels. The use of the PWMDIV parameter, if you require lower PWM frequencies in an X2, is a little quirky.
 

AllyCat

Senior Member
Hi,

PWM and HPWM are different functions and use different pins on the PICaxe, but some pins may be "shared" (only c.2 is shared on the 28X2). All 4 of the HPWM pins are intended to drive only ONE load (motor) in an H-bridge configuration. Thus the pin outputs have the same frequency and Duty Cycle and CANNOT be used to independently control different loads (e.g. motors). If you need to control 4 motors independently, then the only reason to use HPWM (at all) would be if pin c.2 were not available, so you could use one of the other dedicated HPWM pins instead.

To drive servos (using the standard commands) see the Command Reference which says:
"Pulse an output pin continuously to drive a radio-control style servo. Note that on 14M2, 18M2, 20M2 and X2 parts the servo commands only function on portB (B.0 to B.7) ."

Cheers, Alan.
 
Top