PIC Stepper Motor translator code.
Posted by
dqrwagoner
on 2002-11-28 15:04:08 UTC
To All,
I am submitting this into the public domain in the hopes that it
might be useful to someone trying to build their own CNC controller.
This is a translator for 2 unipolar stepper motors with
direction, stepper motor and full or half-step using the PIC16F84 PIC.
I wrote the JSTEP software as a way of getting used to the
various aspects of using and controlling stepper motors, using the
PIC16F84 and the freeware JAL compiler that was created for the PIC
micro. I got the original idea from a program called STEP.ASM from
DAK Engineering (Maker of TURBO-CNC) and I wondered if I could do the
same in JAL. I added support for full and half stepping, as STEP.ASM
suggested, by looking at the pin a4. The program is table driven for
speed. Best-case execution is about 25 clock cycles and worst case is
about 75 clock cycles. At 400nSec that's 10uSec best case loop time
and 30uSec worst-case loop time. If you have a 50% duty of 30uSec
up and 30uSec down then this is about 16,666Hz max input frequency,
or around 10,000rpm in full step mode and 5,000rpm in half step mode
for a 100 count per rev. stepper motor. (In Theory)
The files include the following:
JSTEP.JAL - My original JAL source code.
JSTEP20I.HEX - A 20MZ, inverted output version.
JSTEP20N.HEX - A 20MZ, non-inverted output version.
JSTEP10I.HEX - A 10MZ, inverted output version.
JSTEP10N.HEX - A 10MZ, non-inverted output version.
JSTEP4I.HEX - A 4MZ, inverted output version.
JSTEP4N.HEX - A 4MZ, non-inverted output version.
I could only test it with two small Howard 12V, 600 gram, motors
and a 555 timer as the pulse stream source. I tested it up to about
400pps before I started dropping steps. This looks to be more of a
problem with my power supply and motor and not having an acceleration
table then the translator program itself. In any case I hope that it
lves up to my expectations.
As always, please use this program a your own risk.
Best Regards
David Q. R. Wagoner
I am submitting this into the public domain in the hopes that it
might be useful to someone trying to build their own CNC controller.
This is a translator for 2 unipolar stepper motors with
direction, stepper motor and full or half-step using the PIC16F84 PIC.
I wrote the JSTEP software as a way of getting used to the
various aspects of using and controlling stepper motors, using the
PIC16F84 and the freeware JAL compiler that was created for the PIC
micro. I got the original idea from a program called STEP.ASM from
DAK Engineering (Maker of TURBO-CNC) and I wondered if I could do the
same in JAL. I added support for full and half stepping, as STEP.ASM
suggested, by looking at the pin a4. The program is table driven for
speed. Best-case execution is about 25 clock cycles and worst case is
about 75 clock cycles. At 400nSec that's 10uSec best case loop time
and 30uSec worst-case loop time. If you have a 50% duty of 30uSec
up and 30uSec down then this is about 16,666Hz max input frequency,
or around 10,000rpm in full step mode and 5,000rpm in half step mode
for a 100 count per rev. stepper motor. (In Theory)
The files include the following:
JSTEP.JAL - My original JAL source code.
JSTEP20I.HEX - A 20MZ, inverted output version.
JSTEP20N.HEX - A 20MZ, non-inverted output version.
JSTEP10I.HEX - A 10MZ, inverted output version.
JSTEP10N.HEX - A 10MZ, non-inverted output version.
JSTEP4I.HEX - A 4MZ, inverted output version.
JSTEP4N.HEX - A 4MZ, non-inverted output version.
I could only test it with two small Howard 12V, 600 gram, motors
and a 555 timer as the pulse stream source. I tested it up to about
400pps before I started dropping steps. This looks to be more of a
problem with my power supply and motor and not having an acceleration
table then the translator program itself. In any case I hope that it
lves up to my expectations.
As always, please use this program a your own risk.
Best Regards
David Q. R. Wagoner