TIC500 Moving motor both clockwise and counterclockwise

Hi, guys,

I am working on my capstone project and I need to control 6 motors using a raspberry pi 3 programmed with python 3. I am using serial communication to send the commands to my tic and I haven’t been able to set negative positions or negative velocities since I do not know how to send negative bytes. I have already been able to send the exit safe start command, energize, and set velocity but I can only move them in one direction. Please, if you have an idea of how to use pyserial library to move the motors both clockwise and counterclockwise, let me know. I would really appreciate it.

The Tic uses two’s complement notation to define how negative numbers are represented in its signed variables.

I recommend that you look at the “Example serial code in Python” section of the user’s guide. The code there shows how to send a “Set target position” command with a value of -200. To send a “Set target velocity” command instead, all you need to do is change the command byte from 0xE0 to 0xE3.

If you continue to have trouble, please reduce your code to the simplest thing that you think should work but does not, and tell me how you tested it and what the results were.


Thank you for the information, so at the moment I am using pyserial to open a port and send a command to set velocity when I run the code. The motor moves at the speed I am specifying perfectly. I just want it to move at the same speed in the opposite direction. So, should I just change the data byte for its two’s complement byte? Here is the code:

import serial

#configure the serial port of the raspberry pi
ser = serial.Serial(
port=’/dev/ttyS0’, #Replace ttyS0 with ttyAM0 for Pi1,Pi2,Pi0
baudrate = 9600,

command = b’\xAA\x0E\x63\x00\x20\x0B\x20\x00’

Notice that I use the Polulu Protocol correctly. This code set a velocity of 2,100,000 pulses/s (which corresponds to 00200B20 in hexadecimal). So in order to move it in the opposite direction I need to use the two’s complement of 2,100,000 (which corresponds to FFDFF4E0 in hexadecimal, right?

Yes, -2100000 represented as a 32-bit two’s complement variable would be 0xFFDFF4E0. However, you cannot just break those bits up into four bytes and send them to the Tic. Instead, you need to use the command encoding described in the Tic user’s guide to pack those 32 bits into five data bytes, where each data byte has a value between 0 and 127. You can also look at the example Python code I mentioned in my last post.