| cmdDIG_IO | Index |
Command Code:
Input Command Packet:
Output Command Packet:
| 0 | 1 | 2 | 3 | 4 | ||||
| address | 3 | cmdDIG_IO | DigID | DOUT |
| DigID - | Digital IO pin index. |
| DOUT - | Digital output data. Range is 0,1. |
Description:
| Module | DigID range | Input Device IDs |
|---|---|---|
| GP | 0-4 | 5-9 |
| Moto | 0-10 | 5-15 |
Digital Input
This first form of this command retrieves data from a digital IO pin. The pin must be configured as an input with the cmdDIG_CFG command. If the pin is not an input this command will generate an error message. A digital IO pin index that is out of range will generate an error message.
The DEVCODE byte determines which digital IO pin to use and where to send the data. If the HOST bit is set, the BrainStem will send a cmdDEV_VAL reply packet to the host . The reply packet contains the device ID of the digital input in the first data byte and contains the input value in the remaining byte. If the RFLX bit is set, the value will go directly to a reflex routine within the BrainStem. The HOST bit and the RFLX bit may be set at the same time.
The following table shows Console commands and sample replies when requesting digital input from a BrainStem GP 1.0 module with an address of 2. (The Console program automatically inserts a size byte into the command packet and extracts the size byte from the reply packet.)
| Digital IO pin | Device ID | Console Command | Sample Reply |
| 0 | 5 (0x05) | 2 27 128 | 02:04,05,00 |
| 1 | 6 (0x06) | 2 27 129 | 02:04,06,00 |
| 2 | 7 (0x07) | 2 27 130 | 02:04,07,00 |
| 3 | 8 (0x08) | 2 27 131 | 02:04,08,00 |
| 4 | 9 (0x09) | 2 27 132 | 02:04,09,00 |
Digital Output
The second form of this command sends a bit to a digital IO pin. The pin must be configured as an output with the cmdDIG_CFG command. If the pin is not an output this command will generate an error message. A digital IO pin index that is out of range will generate an error message. There is no reply packet.
Digital IO Limitations for Moto 1.0
On the Moto 1.0, some of the digital IO pins must also serve as motion control outputs and encoder inputs. When a motion control mode is enabled, some of the digital IO pins may not be used as general purpose inputs or outputs. The tables below show how different motion control mode selections change the set of available general purpose digital IO pins. An 'X' indicates a pin that can not be used with a particular mode. See the Moto 1.0 Module hardware information page for digital IO pin locations.
| Digital IO Pin Exclusions for Channel 0 | |||||||||||
| Mode | D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | D8 | D9 | D10 |
| OFF | |||||||||||
| STEP | X | X | X | X | |||||||
| PWM | X | X | |||||||||
| PWMENC | X | X | X | X | X | X | |||||
| A2DPOS | X | X | |||||||||
| ENCPOS | X | X | X | X | X | X | |||||
| A2DVEL | X | X | X | ||||||||
| ENCPOS | X | X | X | X | X | X | |||||
| PWMA2D | X | X | |||||||||
| Digital IO Pin Exclusions for Channel 1 | |||||||||||
| Mode | D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | D8 | D9 | D10 |
| OFF | |||||||||||
| STEP | X | X | X | X | |||||||
| PWM | X | X | |||||||||
| PWMENC | X | X | X | X | X | X | |||||
| A2DPOS | X | X | |||||||||
| ENCPOS | X | X | X | X | X | X | |||||
| A2DVEL | X | X | X | ||||||||
| ENCPOS | X | X | X | X | X | X | |||||
| PWMA2D | X | X | |||||||||