HPWM vs PWM

I'm trying to figure out the differences between the new HPWM and the classic PWM commands... Does anyone have any insights as to the differences and when to use one or the other?
 

MPep

Senior Member
I haven't tried it myself.
But reading the manual however, shows that commands using H as the prefix use the Microchip's hardware. eg HPWM uses a set pin. You have no control over this. The standard PWM can be used on any output pin.

A major implication of this is in HSERIN/HSEROUT. Using hardware, higher data rates are now possible, but using standard SERIN/SEROUT you are limited, as the pins used are effectively a pseudo Comms port, not actual.

Hope this makes sense.
 

hippy

Technical Support
Staff member
Classic PWM provides a single output signal which has a square wave on it of varying frequency and duty ratio.

Enhanced HPWM is a single signal which is internally routed to two or four output pins which can be connected directly to a half-bridge or a full-bridge motor driving circuit.

The single classic PWM line can be used to modulate the speed of a motor which only goes in one direction, or to modulate a H-Bridge driver controlled by additional output pins ( which must be set separately ) for direction control.

With HWPM the speed modulation is part of the routing and motor direction is set by specifying the particular routing to use.

The advantage of HWPM is that the four lines can be interfaced to <i>any </i> H-Bridge driver to control speed and direction without needing any additional circuitry or control lines for altering the speed. There are additional control registers which help ensure that a H-bridge will never inadvertently turn on transistors or FET's which could cause a short across the supply.

All in, HPWM simplifies H-Bridge design and motor control. Without HPWM all it offers would have to be dealt with in software or with external hardware.

The 16F886 datasheet section on Enhanced PWM is the best place to read up on its functionality and capabilities.
 

Tom2000

Senior Member
Agreed, Hippy. RevEd did a great job front-ending the very capable PWM peripheral in that chip.

BTW - I'm using hpwm to control an LCD backlight in a project I'm trying to implement on an A.0 28X1. The &quot;hpwm off&quot; command doesn't. To turn pwm off, I had to issue another hpwm command with the duty cycle set to zero.

Tom
 
hmmm... I still a bit confused (mostly due to my &quot;newbieness&quot;. Any chance you could post a very simple schematic and demo program using the HPWM command, L293D (I have a SN754410 Quad Half H-Bridge, but I believe it is pin for pin compatible with the L293D), and a small DC motor.

A sample program showing how a motor ramps up in speed going forward, down in speed going forward, the ramping up to spee going backwards and back down would be a great sample program!

Thanks so much in advance to whomever can provide the schematic and sample program!

Edited by - Steve Joblin on 04/07/2007 21:24:20
 
Top