Protocol of µC stepper <=> PC communication

!!! every byte is "echoed" by the µC !!!

PC  Address ("CR" not allowed)
PC  Command No. (ranging from 0 to A, number as ascii code)
PC  Direction & Mode (ranging from 0 to F, number as ascii code)
PC  Steps Digit 6 (ranging from 0 to F, number as ascii code)
...
PC        Digit 1 (ranging from 0 to F, number as ascii code)
PC  "CR"

Command No. decode as follows
0   move motor, master mode
1   move motor, slave mode
2   set maximum stepping frequency
3   set acceleration
4   write GPIO
5   read GPIO
6   snapshot steps to do
7   home search (to be implemented)
8   check motor status
9   check software version
A   stop motor

Direction & Mode decode as follows
0   full step, clockwise
1   full step, counterclockwise
2   half step, clockwise
3   half step, counterclockwise
4   quarter step, clockwise
5   quarter step, counterclockwise
6   quarter step, clockwise
7   quarter step, counterclockwise
8-F same as 0-7, but with /SyncMaster impulse

Example: "B04000100"
device address B; command 0 (move motor, master mode); quarterstep, clockwise; 256 steps

Please note:
The command end sign is not allowed to appear at any other position.
If motor no. is out of range the command is ignored.
Further characters following time digit 1 will be ignored. Commands with
more than 128 bytes will lead to an overflow. The length of command
lines for non µC control devices is not limited.
Disclaimer: No warranty at all!
Copyright by Martin Clausen, Germany.
Contact the author: mc AT rotgradpsi DOT de
Impressum