Browse over 10,000 Electronics Projects

Simple ?C acts as dedicated motor control

Simple ?C acts as dedicated motor control

Motion-control systems often use a PWM signal to control the duty cycle for a motor driver or amplifier module. Typical designs generate the PWM signals using µCs with dedicated PWM output lines.
Such as the PIC16C65 (Microchip Technology, and the HC11 (Motorola Inc, However, these µCs may have more features than necessary for a motion-control system with multiple degrees of freedom. Using this type of µC on each degree of freedom becomes costly, particularly if all you need to do is generate motor-control signals.

An alternative approach uses one low-cost µC, in this case the PIC16C84, as a dedicated motor-control register (Figure 1). The circuit accepts control words from an 8-bit digital bus, and the chip-select line triggers the µC, much the same as other standard 8-bit hardware. You can arrange multiple µCs on a bus and communicate with a higher level motion-control computer or µC. For example, you can use the parallel port of a PC to control all the degrees of freedom on a robot arm. By using PWM signals to modulate the speed at each joint, coordinated motion is possible.


The RA3 and RB1-to-RB7 data-bus lines are digital inputs that connect to an output-controlled data bus. The PIC16C84 ignores these inputs until there is a high-to-low transition on Pin 6 (RB0/INT). On this transition, the µC places the state of RA3 on the output RA0 (direction bit) and places the state of RB1 on RA1. The state of the remaining lines, RB2 to RB7, set the pulse width of the PWM output, RA2. Note that these outputs are subject to special conditions.

The RB0/INT digital input latches the word on the 8-bit data bus. A 74HC138 1-of-8 device selector drives this active-low input. The high-to-low transition generates an interrupt to update the state of the register. At all other times, the circuit ignores the state of the 8-bit data bus.

RA0 drives the motor-drive chip and determines the polarity of the current going through the motor in the output stage of the driver. RA1 also drives the motor-drive chip. When RA1 is high and RA2 is high, active braking of the motor occurs. When RA1 is high and RA2 is low, the motor coasts to a stop.

The RA2 PWM output has a duty cycle that depends on the binary word on the inputs during a high-to-low transition on RB0/INT. The duty cycle of this signal increases from 1.56 to 100% in increments of 1.56%. In other words, the duty cycle goes from 1/64 to 64/64 in increments of 1/64, depending on the binary word on RB2 to RB7. The duty cycle repeats at a rate of approximately 300 Hz.

Visit Here for more.