I wanna use 5 registers to save value of velocity, accelerate and numberof steps.
And I only use 5 low bits of each register to save data.
one register for velocity
one for accelerate
and 3 for number of steps, so I'll have 15 bits for number of steps
the highest bit of velocity register will show the direction that the stepper should turn
My command should come as
mm|c|ddddd
mm is select the PIC (I have 2 PIC to drive 2 motor- left and rite)
if c = 0 then select the register with ddddd
if c = 1 then send data ddddd to the active register
I use parallel port to send commands.
data 0 to data 7 of parallel port is connected to rb0 to rb7 of PIC16F628
Questions:
1) How do I select register using my command?
For example I choose 5 register addressed at... in bank 0
2) How do I count number of steps if it is saved in 3 different registers?
3) I wanna send data to 4 pins RA0 to RA3 of PIC to ULN2003, for example sending 9 (1001)
how should i write?
bsf porta,ra3
bcf porta,ra2
bcf porta,ra1
bsf porta,ra0
???????
but if I wanna send all 4 bits at a time, how should i write?
4) assuming that the velocity register is at 0xMM
so when i check for direction, I should write:
btfss 0xMM, 04 (the highest bit of 5 bits data of this register will show direction)
goto turnleft (if direction = 0 then turn left)
goto turn right (if direction=1 then turn right)
is this rite?
5) this will be similar to accelerate register,
if the highest bit is 0 then accelerate
if it is 1 then decelerate.
Deeply thanks