Description Function Coding Example (for controller ID = 1)
Read DC Motor Current
Reads the DC motor current of each
TETRIX DC Motor attached to the
Motor 1 and Motor 2 ports. The integer
value that is returned is motor load
current in milliamps.
readMotorCurrent(ID#, motor#);
Data Type:
ID# = integer
motor# = integer
Data Range:
motor# = 1 or 2
Data Type Returned:
value = integer
readMotorCurrent(1, 1);
Read the motor load current of Motor 1
channel.
readMotorCurrent(1, 2);
Read the motor load current of Motor 2
channel.
Example: 1500 = 1.5 amps
Read Motor Busy Status
Reads the busy flag read to check
on the status of a DC motor that is
operating in positional PID mode. The
motor busy status will return “1” if it
is moving toward a positional target
(degrees or encoder count). When it
has reached its target and is in hold
mode, the busy status will return “0.”
readMotorBusy(ID#, motor#);
Data Type:
ID# = integer
motor# = integer
Data Range:
motor# = 1 or 2
Data Type Returned:
value = integer
readMotorBusy(1, 1);
Return the busy status of Motor 1.
readMotorBusy(1, 2);
Return the busy status of Motor 2.
Read Encoder Count
Reads the encoder count value. The
DC controller uses encoder pulse
data to implement PID control of a
TETRIX DC Motor connected to the
motor ports. The controller counts the
number of pulses produced over a
set time period to accurately control
velocity and position. Each 1/4 degree
equals 1 pulse, or count, or 1 degree
of rotation equals 4 encoder counts.
The current count can be read to
determine a motor’s shaft position. The
total count accumulation can range
from -2,147,483,648 to 2,147,483,647.
A clockwise rotation adds to the
count value, while a counterclockwise
rotation subtracts from the count
value. The encoder values are set to 0
at power-up and reset.
readEncoderCount(ID#, enc#);
Data Type:
ID# = integer
enc# = integer
Data Range:
enc# = 1 or 2
Data Type Returned:
value = long
readEncoderCount(1, 1);
Read the current count value of encoder 1
(ENC1 port).
readEncoderCount(1, 2);
Read the current count value of encoder 2
(ENC2 port).