Hi Ross
I suggested a 'select case' simply because there is not much you are doing after 'branch'ing to the subroutine. You seem to be just incrementing the step variable and going back. That would be very wasteful speedwise because a branch usually takes longer to execute. I am not sure if a select case saves time; haven't checked.
For the table approach, I usually keep the 4 bit stepper values in a table. These 4 bits are jammed to a port that drive the stepper coils. So, a typical step table would have values like
HalfStep=[0b0001,0b0011,0b0010,0b0110,0b0100,0b1100,0b1000,0 b1001];
Sorry, I do not have a PBP example at hand, so, I have given you a quick and easy 'C' table. At each step, you load the next value from the table and jam it out to the port. This table shows values to drive a stepper motor in a half step sequence. For full stepping, you just use every alternate value.
Hope this helps
Jerson
PS: have you read through this thread? It might have something useful to you
http://www.picbasic.co.uk/forum/showthread.php?t=101
Bookmarks