|
Project 9
Stepper Motor
|
Neff Site |
This module implements a command line interface for the A4988 stepper motor driver.
Implementing a protocol for a command line interface is not easy. One has to know what a protocol and a state machine is and how they work. Please see the following modules for more information:
Refer to Module 5.3.3 for an implementation example with a Visual Studio and a Code::Blocks solution.
The description of the states is:
| State | Description |
|---|---|
| C | Parse command. |
| A1 | Parse first digit of advance argument. |
| A2 | Parse second digit of advance argument. |
| D | Parse argument of direction command. |
| M | Parse argument of motor state command. |
| T | Parse terminal character. |
| E | Execute command. |
The transitions are:
| State | Condition | Transition | Description |
|---|---|---|---|
| C | token = A | A1 | Command is Advance. → Parse first digit of argument. |
| token = T | D | Command is Turn. → Parse argument. | |
| token = M | M | Command is Motor State. → Parse argument. | |
| token = S | T | Command is Step. → No argument required, parse terminal. | |
| A1 | token = digit | A2 | First digit parsed. → Parse second digit. |
| A2 | token = digit | T | Second digit parsed. → Parse terminal. |
| D | token = R | T | Argument parsed. → Parse terminal. |
| token = L | T | Argument parsed. → Parse terminal. | |
| M | token = O | T | Argument parsed. → Parse terminal. |
| token = F | T | Argument parsed. → Parse terminal. | |
| T | token = space | E | Terminal parsed. → Execute. |
| E | - | C | Command executed. → Parse next command. |
Every parsing function gets the new token and returns the subsequent state. Some functions return extra information (command, argument) via a reference parameter. The basic workflow is as follows:
| Contact |
Generated by
1.8.13
|