explanation of step array
Hi. First post. I'm a relative newbie to PICbasic. I've been intermittantly tinkering with pics since 97, (but only ever got to the stage of flashing LEDs on and off etc with assembly. Now recently switched to PIC basic pro, and enjoying the satisfaction of getting real projects to work. Now Ive started playing with steppers and had a bit of success with making the thing rotate via a 16F84- although a bit jittery- and looking to improve things.
Ive tried to do my homework and figure this out for myself, but no luck.
I'm looking at controlling a stepper from a 16F84, and reading snippets from the net to understand various ways of doing it. ( directly or using a stepper driver like the 5804 chip).
I took the code below from tigoe.net, but don't understand a few things.
1. How exactly does the step array fuction work in the program below?. Does the program automatically step through each step array from [0] to [3]? I don't see any loop function.
2. Whats the [steps //4] bit do. I though this was for division, but why use it here?
Apologies if this is too simple, and doesn't belong on this forum.
Thanks
Regards
Ross
start:
High PORTB.0
' set variables:
x VAR BYTE
steps VAR WORD
stepArray VAR BYTE(4)
clear
TRISD = %11110000
PORTD = 255
input portb.4
Pause 1000
stepArray[0] = %00001010
stepArray[1] = %00000110
stepArray[2] =%00000101
stepArray[3] = %00001001
main:
if portb.4 = 1 then
steps = steps + 1
else
steps = steps - 1
endif
portD = stepArray[steps //4]
pause 2
GoTo main