IO Ports for Moto ModuleIndex

The TEA VM gives each I/O (Input/Output) device a unique 2-byte address, or port ID.  System values, system constants, some reflex elements, and VM semaphores also have IO ports.  Additional features and operations may also be controlled with IO ports.  Each VM implementation will offer different subsets of these IO ports to allow the VM to interact with the specific I/O offered by the module or host where the VM is running.  Most of these ports duplicate the functionality of a command.

To write to an output device, push a value onto the stack.  Then pop that value into a device port with the popbm , popbmx , popsm , or popsmx command.  To read from an input device, push a value from a device port onto the stack using the pushmb , pushmbx , pushms , or pushmsx command.

The table below lists the ports and reserved address ranges for various I/O devices specific to the Moto 1.0 Module.  Some devices have multiple functions.  Each multi-function device gets a set of sequential port IDs.  The least significant bits of the port ID select the appropriate function.

The table also lists the ports along with the functions, access modes, and default data sizes associated with each port.  An asterisk (*) in the data size entry means that the size is strictly enforced.  Executing an opcode that uses a different data size will cause an error.  If there is no asterisk, the type will be converted appropriately.  A char will be padded with a zero byte to convert it to an int.  An int will be truncated to convert it to a char.

(See the GP Module IO Ports chart for a quick reference.)

Port Summary

Port ID Name Description Access Size
0x0480 - 0x04BF aPortA2D Analog to Digital inputs (32*2)
0 - RD
1 (reserved)

r


char

0x0500 - 0x05FF aPortDigital Digital IO pins (64*4)
00 - CFG
01 - IO
10 (reserved)
11 (reserved)

r/w
r/w



char
char


0x0600 - 0x061F aPortMoto Motor control (16*2)
0000 - CFG
0001 - P
0010 - I
0011 - D
0100 - COFFSET
0101 - X2
0110 - PERIOD
0111 - LATENCY
1000 - PWMFREQ
1001 - Setpoint
1010 - CINPUT
1011 - RMPCFG
1100 - RMPENA
1101 - ENCH
1110 - ENCL
1111 - CDUTY

r/w
r/w
r/w
r/w
r/w
r/w
r/w
r/w
r/w
r/w
r
w
w
r/w
r/w
r

int*
int*
int*
int*
int*
int*
int*
int*
int*
int*
int*
char*
char*
int*
int*
int*
0x0620 aPortMotoPIDErr Calculates PID errors
for channels 0 and 1

w

char*

aPortA2D

This group of memory addresses is reserved for A2D input access.  Each A2D device has two functions associated with it:

Function Description Port Calculation Equiv.  CMD
A2D RD read (device number * 2) + 0 cmdA2D_RD
A2D reserved (none) (device number * 2) + 1 (none)

Reading an int from the A2D RD port pushes two bytes with the 10-bit analog conversion result onto the stack.  Reading a char from the A2D RD port pushes a byte with the 8 most significant bits of the conversion result onto the stack.

Port Summary

aPortDigital

This group of memory addresses is reserved for digital I/O pin access.  On the Moto module, each digital I/O pin has two functions associated with it:

Function Description Port Calculation Equiv.  CMD
Digital CFG control timing, polling, IO dir (pin number * 4) + 0 cmdDIG_CFG
Digital IO read or write bit (pin number * 4) + 1 cmdDIG_IO
Digital (reserved) (none) (pin number * 4) + 2 (none)
Digital (reserved) (none) (pin number * 4) + 3 (none)

Reading from the Digital CFG port pushes the current pin configuration onto the stack.  Writing to the Digital CFG port sets the pin configuration.  Reading from the Digital IO port pushes a 0 or 1 onto the stack depending on the pin state.  The pin must be configured as an input in order to read it.  Otherwise, a read will generate an error.  Writing to the Digital IO port sets the specified pin to 0 if the stack parameter is 0 or 1 if the stack parameter is non zero.  The pin must be configured as an output in order to write to it.  Otherwise, a write will generate an error.

Port Summary

aPortMoto

This group of memory addresses is reserved for access to motor control functions.  Each motor control channel has sixteen functions associated with it:

Function Description Port Calculation Equiv.  CMD
CFG Motion control mode (channel number * 16) + 0 cmdMO_CFG
P P constant for PID control (channel number * 16) + 1 cmdMO_CFG
I I constant for PID control (channel number * 16) + 2 cmdMO_CFG
D D constant for PID control (channel number * 16) + 3 cmdMO_CFG
COFFSET offset for control input (channel number * 16) + 4 cmdMO_CFG
X2 reserved (channel number * 16) + 5 cmdMO_CFG
Period Time between PID computations (channel number * 16) + 6 cmdMO_CFG
Latency Stall time for back-EMF speed control (channel number * 16) + 7 cmdMO_CFG
PWMFREQ Codes for setting PWM frequency (channel number * 16) + 8 cmdMO_CFG
Setpoint Setpoint for PID loop (channel number * 16) + 9 cmdMO_SET
CINPUT Current input to PID loop (channel number * 16) + 10 cmdMO_PEEK
RMPCFG Ramp control parameters (channel number * 16) + 11 cmdMO_RMPCFG
RMPENA Ramp enable (channel number * 16) + 12 cmdMO_RMPENA
ENCH High 2 bytes of 32-bit encoder (channel number * 16) + 13 cmdMO_ENC32
ENCL Low 2 bytes of 32-bit encoder (channel number * 16) + 14 cmdMO_ENC32
CDUTY Current duty cycle of PID loop (channel number * 16) + 15 cmdMO_PEEK

The CDUTY and CINPUT ports are read-only.  They are used to observe the current input and output of the PID control loop.

The RMPCFG port is write-only.  A control byte is written to the port to indicate a read or write of a ramp configuration parameter.  The high nibble must be 1 to indicate a read and 0 to indicate a write.  The low nibble is the index of the parameter to be accessed.  To perform a write, the 2-byte ramp control parameter must be on the stack prior to writing the control byte to the port.  After a read operation, the 2-byte ramp control parameter will be pushed onto the stack.

The RMPENA port is write-only.  A control byte is written to the port to select the desired enable/disable operation.  The high nibble must be 0 or 1 to indicate STOP or GO.  The low nibble is the index of the channel to enable/disable.  A low nibble of 0 or 1 indicates channel 0 or channel 1.  A low nibble of 2 applies the enable/disable operation to both channels.

All other ports are read/write capable and use a 2-byte parameter.

aPortMotoPIDErr

Writing any byte to this memory address will make the VM perform an operation that pushes four bytes onto the stack.  The first two bytes are an int with the signed error between the setpoint and feedback input for channel 0.  The last two bytes are an int with the signed error between the setpoint and feedback input for channel 1.  A user can access the Setpoint and CINPUT ports and do subtractions to get the same results, but using this port is more efficient.

NOTE:

This port was added in Moto 1.0 Firmware Build 5.

Port Summary


version: 1.0, build 80903
© Copyright 1994-2008 Acroname, Inc., Boulder, Colorado.  All rights reserved.