PWM DC Motor Controller for PIC12F683




Description

There are lots of designs on the Internet for DC power controllers using Pulse Width Modulation (PWM) to control the speed of a motor or power to a resistive load.  Most of these use analogue methods to generate the PWM signal which in turn drives a power MOSFET or transistor.

DC Motor Controller

When I wanted a speed controller for the PCB drill I use to make all my PIC Projects what else could I do but design a PWM Power Controller around a PIC – a practical PIC project for sure. 

I came up with a fairly straightforward design based on a PIC12F683 using the Capture/Compare/PWM
(CCP) peripheral inside the PIC to generate a PWM output.  An ‘N’ Channel Logic Level MOSFET in a low side configuration is driven by the PIC to control the output power to the motor.

A variable resistor provides a voltage input to the PIC which is converted to a digital value using the onboard Analogue to Digital convertor, this in turn is used to set the PWM duty cycle.  Since the PWM duty cycle is adjusted using a voltage signal input to the PIC it is possible to use an alternative analogue front-end instead of VR1 to provide this voltage input and therefore control of the duty cycle. 

In the original version of this project the input from the Analogue to Digital Converter (ADC) was fed directly to the duty cycle register of the PWM module on the PIC, therefore the PWM output duty changed linearly in direct proportion to the change in input voltage to the ADC; much the same as an analogue PWM.  The switch input allowed the PWM period to be selected in one of three ranges; 15.6Khz, 3.8Khz and 980Hz.

The significant feature in the new version of the firmware which sets it apart from analogue PWM is that it now uses the input from the ADC as an index to a data table.  This table contains the required output duty cycle and period.  By creating a suitable table of data you can map any value at the input of the ADC to any duty cycle and one of 3 fixed periods at the PWM output.  

The switch input now cycles through 3 mapping tables.  The default tables supplied with the code have a one-to-one mapping of input voltage to duty cycle output and fixed periods of 15.6Khz, 3.8Khz and 980Hz respectively to keep it backward compatible with the original version of the code.

More details of this and example map table files can be found in the Operation section.

A push button cycles through three different mapping tables.  The mapping table in use is saved to EEPROM so it always powers up using the last selected table; an LED indicates the current setting.

There is also a digital control input that allows the output driver to be turned off.  When pulled low the PWM output is set to 0%.

 

For more detail: PWM DC Motor Controller for PIC12F683




Current Project / Post can also be found using:

  • pic12c683 motor control
  • sample codes for pic12f683
  • pic12f683 pwm example
  • pic12f683 pwm project

Leave a Comment

*
= 4 + 6

Read previous post:
LED Chaser program
LED Chaser for PIC16F84A and PIC16F628A

Description This simple circuit functions as a 12 LED chaser.  A single illuminated LED 'walks' left and right in a...

Close
Scroll to top