Well, the PIC18F2550 wasn't working for me so I changed to the PIC18F2520.
I don't know why it was giving me problems, but it essentially was not letting me set the clockrate fuses correctly (and I seemed to be missing pieces out of my 18F2550.h file, compared to other people's projects I found on the net.) The only thing I'm really missing is the USB-capability of the 2550, but I wasn't going to use it anyway.
I have completed the PIC code to read from the analog-to-digital converter, as presented in my last post. I have also verified the duty cycle on my
GDS-820C oscilloscope.
Here's the Science:
I created a spreadsheet to determine how the PIC timing needed set up. It gave me the
absolute timing specs that I needed to get the performance I needed.
I used the max clock of my PIC: 20Mhz, coupled with the fastest clock division I could use (division of 1). The pic timers already use 1/4 of the clockrate as the timer clock so that gives us a max resolution of 5Mhz.
I also used the following specs to target my calculations: range of .5revolutions/sec to 30revolutions/sec

click here to download the .xls spreadsheet
The calculations show that I need 128 increments between changing the output to step the motors in full-step mode vs. 32 increments in 1/4 step mode. 1/8th step mode would be half of that, or 16 increments. Seeing that 16 clock increments leaves virtually no time for any calculation, debug output, or capture I opted to configure the motor controller for full-step mode and use 128 steps between toggles.
Here Comes the Proof:
I used my
GDS-820C oscilloscope to check the output of my PIC stepper driver.
First I calibrated my code until I could specify a 2mS period waveform (1mS between toggles). I set up triggering on the rising edge. Here is the output waveform:

At 0V, the circuit generates the fastest waveform for the stepper motor (spreadsheet: clock incs/sec = 129) here is the waveform:

At Vdd, the circuit generates the fastest waveform for the stepper motor (spreadsheet: clock incs/sec = 7716) here is the waveform:
As you can see this deviates from the theory a little bit (theory: 19.44kHz, reality: 15.34kHz; theory: 324Hz, reality: 324Hz).
I think that is because the Analog-to-Digital conversion and math in the middle of the loop is slowing the program down a little bit. Though these values still give a range of .5rev/sec to ~25rev/sec which is pretty damn good as far as I'm concerned at the moment.
Meanwhile
Testing the circuit with the stepper motor, I can only get it up to 2.8kHz before the motor stalls. Also I have to baby the thing (ramping speed up gradually) so it doesn't stall. 2.8kHz is approximately 5rev/sec. Almost there...
Code (7/5/2006):
This compiles for the 18F2520 chip
PIC Program:
main.c
Header File:
stepper_driver.h
HEX File:
main.hex