Back to Home Page
I am no longer using Microprocessor control for the motor timing, but now using a direct drive system using OpAmps.
Machine Construction Home Page
Back To Electronic Drive Home Page
symbol peri     = b2      
symbol dutyc   = b3
let peri = 63            
readadc B.4, dutyc         
pwmout B.3,peri,dutyc     'period of 63 gives Freq 15700 and 255 dcyc @ 100%, 13 @ 5%
pause  200
goto main
The PWM, once set, runs in the background until power off or until turned off or altered.
The Period (peri) is set at 63, which gives a frequency of 15,700 switchings per second.
The Duty Cycle (dutyc) is adjustable via a 5000ohm variable resistor (pot), and controls the motor voltage, therefore the motor speed. The micro loops back every 200 milli secs to read the input at B.4, and store the value in variable dutyc.
The readadc command has a range of 0 to 255. This works perfectly for a full range of duty cycle at 15,700Hz. Motor theory recommends a frequency of 20,000 to avoid audible switching.
The Picaxe Programming Editor is completely free for private use. It checks your program for errors, and has a simulator to show program operation. Also a Wizard to set the PWM for you.