Microchip PIC Microcontrollers for Motor Control: PIC16F648, PIC16F785 and PIC18F2331

While many of the PIC microcontroller models have at least one hardware PWM output channel that could be used to control an h-bridge, we’ll take a quick look at several models that are particularly well suited for servo and stepper motor control applications.  

The PIC16F648 is a small 14 pin microcontroller with a single PWM module whose outputs can be routed to one, two or four of the I/O pins.  In addition to the usual single-pin PWM output, the chip can be configured to output two complementary signals, which is very handy for controlling a pair of half-bridge drivers such as the IR2104.  When using the complementary mode to individually drive the high and low side of one half-bridge, a programmable dead-time can be inserted between the switching of each pin to prevent shoot-through.  There is also a four-pin mode that provides individual signals for each of the four transistors in an h-bridge.  Unfortunately, you can only modulate one pin at a time, so it is limited to sign-magnitude modulation without synchronous rectification. 

In addition to an analog to digital converter, there is also a pair of comparators that can be configured to override the PWM output.  This “auto shutdown” mode can be used to implement an over current protection or chopper current limiting scheme all in hardware. 

The PIC16F785 is unique in that contains special a “Two-Phase Asynchronous Feedback PWM” module.  Along with the two built-in comparators, this gives you all the control hardware you need to implement a two-phase, fixed frequency chopper current regulator for a stepper motor driver.  If only it also had two standard PWM channels instead of just one, it would be perfect for a microstepping controller.  If you want to microstep you need to add some scheme of digital to analog conversion to generate the two sinusoidal phase current reference voltages. 

The PIC18F2231 is a very powerful microcontroller for servo motor control.  A major feature is a built-in quadrature encoder interface (QEI) module.  Also called the “Motion Feedback Module”, this hardware translates a two channel quadrature encoder signal into a simple position register readable by your firmware.  The three-channel “Power Control PWM Module” is also no slouch.  It can control anything from a PMDC motor to a three-phase brushless motor or even an AC induction motor inverter.