A very simple and useful PWM motor control circuit can be constructed using MSP430 integrated circuit manufactured by Texas Instruments.
Many of the MSP430 microcontrollers have either the Timer_A module or the Timer_A and Timer_B modules included in them. These modules contain a 16-bit counter that can be incremented from a number of clock sources. They can even count in low power modes. These timers also have a number of capture/compare registers that lend themselves to a variety of applications. One of these applications is the automatic generation of a PWM output to control a DC motor.
The PWM motor control circuit operates by polling the two push button input pins and either incrementing or decrementing the Timer_A capture/compare register CCR1, when either of the inputs is at a logic low state. The software checks the value of the register to ensure that it does not exceed the minimum or maximum values the register will hold, and thereby prevents it from rolling over. Timer_A is configured in UP-mode with MCLK as timer clock source and output unit Out1 in output mode 7 to produce a PWM square wave output on P1.2/TA1.
The CCR0 value is set to 255 to define Timer_A to count up to 256 counts (8 bits).
Changing the value in CCR1 varies the duty cycle of the PWM signal produced by Timer_A. The PWM signal is used to switch a Darlington transistor. The transistor in turn powers the DC motor. As the PWM duty cycle varies, the average power to the motor also changes.
This change in average power is what controls the speed of the motor. The motor speed is variable in 256 steps from 0 to maximum. The DCO is set to approximately 5MHz to achieve a PWM frequency around 20KHz thereby allowing the motor to run without producing any audible PWM noise.
The TI TPS77133 shown in the circuit provides both the regulated VCC to the MSP430 and a power on reset signal to control the reset input of the MSP430. The TPS77233 can be
used if the supply voltage supervisor (power good) function is required. The code is written in assembly language using the IAR Kickstart integrated development environment.
Programming code for pwm control with msp430