5.3. Encoder input handling
This section explains the details of how the Tic reads quadrature encoder signals and converts them to a target position or velocity.
The Tic does not support closed-loop control with encoder feedback. The Tic’s encoder input is meant to be connected to a rotary encoder that is turned by hand to control the stepper motor’s position or speed. If you have a stepper motor with an integrated encoder, you should not try to connect the motor’s encoder to the Tic.
Encoder monitoring on the RX and TX pins
The Tic’s RX and TX pins are normally used for TTL serial communication, but they can be configured as encoder inputs, and that is their default configuration when the Tic’s control mode is set to “Encoder speed” or “Encoder position”. Each of these pins has a 100kΩ pull-up resistor and a series resistor, as shown in the diagram below.
The Tic expects to see a quadrature encoder signal like this on the RX and TX pins:
The time between the channel transitions (labeled T1-4 in the diagram above) must be at least 100 µs. The signal must rise to 4 V or higher, and must stay within 0 V to 5 V.
The Tic stores the raw encoder counts in the “Encoder position” variable. This variable can be read over serial, I²C, or USB, and it is displayed in the “Status” tab of the Tic control center. The “Encoder position” variable gets reset to zero when the Tic’s motor power supply is too low, when the Tic is experiencing a motor driver error, when the Tic’s control mode is changed, and when the Tic receives a Reset command.
An increasing encoder position corresponds to the TX signal leading the RX signal, and a decreasing encoder position corresponds to the RX signal leading the TX signal.
The Tic’s default encoder scaling settings.
When the Tic’s control mode is set to “Encoder position” or “Encoder speed”, the encoder prescaler and postscaler settings, along with the “Enable unbounded position control” option, determine how the encoder position maps to the “Input after scaling” variable, a 32-bit signed integer which is used to set the target position or target velocity of the motor.
The Tic internally keeps track of an encoder “cursor” variable, which is always a multiple of the encoder prescaler. When the encoder position is more than the prescaler value away from the cursor, the cursor increases or decreases by the prescaler amount to get closer to the encoder position. When the cursor increases or decreases, the Tic adds or subtracts the postscaler value to the “Input after scaling” variable if unbounded position control is enabled or the change to the “Input after scaling” variable would keep it within the bounds defined by the “Target maximum” and “Target minimum” settings.
The unbounded position control option can only be enabled when the control mode is “Encoder position”, not “Encoder speed”. With this option enabled, the “Input after scaling” can overflow and wrap around from +2,147,483,647 to −2,147,483,648.
When the Tic’s control mode is “Encoder position”, the Tic sets its target position equal to the “Input after scaling” variable described above. For tips about how to set the encoder scaling parameters in encoder position mode, see Section 4.11.
When the Tic’s control mode is “Encoder speed”, the Tic sets its target velocity equal to the “Input after scaling” variable described above. For tips about how to set the encoder scaling parameters in encoder speed mode, see Section 4.12.