Data Sheet
12. Writing PC software to control the Tic
This section is about writing computer software to control the Tic.
Picking an interface
First, you should decide which interface of the Tic your software will talk to: serial, I²C, or USB. The
USB interface is the most natural interface to use for PC software since most computers have USB
ports, and we provide Tic software that uses the USB interface. However, if your computer has a
serial or I²C port, or you want to control the Tic over a radio link, you might decide not to use the
USB interface. All three of these interfaces support nearly the same set of commands, which are
documented in Section 8. Most of this section is about using the USB interface.
Picking a USB API
If you decide to use the USB interface to communicate with the Tic, the next thing to do is decide
which API you want to use to access it.
Almost every operating system has its own API for accessing USB devices, so you could use the
native USB API of your operating system. You would need to decide which commands you are going
to send to the Tic by reading Section 8, then figure out how to encode those commands for the Tic’s
USB interface by reading Section 11, and finally figure out how to send those USB commands using
the API you have chosen by reading the documentation of that API. These APIs are typically meant
for C programs, so you have to carefully manage pointers and memory allocation yourself. However,
you might be able to find an API wrapper in the language of your choice that takes care of managing
pointers for you.
Another option is to use a USB abstraction library like libusbp [https://github.com/pololu/libusbp] or libusb
[http://libusb.info/]. These libraries abstract away the differences between USB APIs for the different
operating systems they support, so you can write code that works on multiple operating systems.
You would still have to read the documentation of the Tic’s commands and USB protocol, read the
documentation of the API you have chosen, and carefully manage pointers. However, you might be
able to find a library wrapper in the language of your choice that manages pointers for you.
In our Tic software package [https://github.com/pololu/pololu-tic-software], we provide a C library called
libpololu-tic that uses libusbp to talk to the Tic. You can compile it as a static or shared library. The
library takes care of the details of encoding the Tic’s USB commands so that you don’t have to know
much about the Tic’s USB interface—you just have to call the appropriate function for each command
you want to send. You would need to read the documentation of the library in the include/tic.h file
to understand how to use the library, and carefully manage pointers.
In general, the easiest way to write software to control the Tic over USB is to install the Tic software
and then invoke the Tic Command-line Utility (ticcmd), which is built on top of libpololu-tic. You can
Tic Stepper Motor Controller User’s Guide © 2001–2018 Pololu Corporation
12. Writing PC software to control the Tic Page 149 of 150