Wednesday, September 23, 2009

PWM motor speed control of a toy car

This simple project can be assembled in an evening. It demonstrated using PWM (Pulse Width Modulation) to vary the speed on a simple 3V motor found in a toy car. The car was cut open to show off the simple worm & pinion 12:1 gear motor drive; typically 3V toy motors run at about 10,000 RPM. The toy car was bought at a dollar store for are you ready $1. Assembled on a small prototyping PCB, the layout is not critical except to make the small motor less electrically noisy; a 0.1uf capacitor was placed across the motor terminals as close to the motor as possible (located on top of the motor, barely visible in the above photo). A 1N5817 Schottky diode acts as an inductive spike suppressor and an NPN 2N2222A transistor acts as a high current ~300ma switch. A PWM speed of 1 KHz was chosen (oscillator @ 1MHz, PR2 = 250) as it was close enough for the A/D conversion of VR1 (0-255). Keep in mind any value entered into CCPR1L greater than the PR2 value will set the duty cycle to 100%; so A/D values > 250 will be at 100% duty cycle. Only when the PWM signal is high is power applied to the motor.

DOWNLOAD

0 comments:

Post a Comment