Trinamic's TMC5160-BOB setup

Driving Stepper Motors with the new TMC5160 by using TRINAMIC’s API on a Raspberry Pi

This start-up guide explains how to connect your Raspberry Pi 3 to the TMC5160-BOB – the breakout board of the brand new TMC5160. We’ll be using the internal Motion Controller and +3V3 logic supply for the TMC5160. The wiring will be limited to the basic functionality to communicate via SPI. The usage of the TRINAMIC’s API – TMC-API – is minimizing the software effort.


In this tutorial we are using a fresh Raspbian Stretch System (Version November 2017 – Release date 2017-11-29) with the latest updates:

Download and install the bcm2835 library. Note XXX is a placeholder for the latest version. For this guide version “1.52” was used. In this case, XXX is replaced by “1.52”. You can check the latest version by scrolling to the bottom of the following page:

Create a project folder and download the latest TMC-API. Note X.XX is a placeholder for the latest version. For this guide version “3.02” was used. In this case, X.XX is replaced by “3.02”. You can check the latest version by scrolling to the bottom of the following page:


The wiring is very simple. You will need 8 jumper wires. As a reference you can use the TMC5160-BOB_datasheet_Rev1.0.pdf. You will find the signals that are on each pin.

Signal Raspberry Pi 3 TMC5160-BOB
VCC_IO GPIO02 (3) VCC_IO (1)
GND GND (39) GND (2)
SPI Chip select (CS) SPI0 SCLK (23) CSN (3)
TMC5160 CLK GPIO04 (7) CLK (8)
TMC5160 DRV_ENN GPIO03 (5) DRV_ENN (9)


Raspberry Pi 3 GPIO Header – Source:

Raspberry Pi Code

An example code to initialize the TMC5160 is shown below. These files need to be placed in the same project folder as the TMC-API, in this case into ~/TMC_EXAMPLE. First, +3.3V is supplied to VCC_IO, the driver stages are enabled by pulling down DRV_ENN and the internal clock is used by pulling down CLK16. Afterwards, the TMC5160 is initialized and a simple move to position cycle is executed. The sequence will rotate a 200 full stepper motor 10 revolutions clockwise and 10 revolutions counterclockwise – depending on the wiring of the stepper motor. Please refer to the TMC5160 datasheet or the TMCL-IDE as a reference for the different registers.

You can also download the source files directly with your Pi:





Compiling and running the code

Use the following command to compile the code.

Now you are able to execute this example.

Be aware that the motor runs as soon as you execute the program.

Related Pages




TRINAMIC Technology Access Package -TMC-API


  • Radek Reply

    Hello Mario,
    Very nice example.
    Will this API compile on Beaglebone or will work with Arduino either?
    How about reading encoder pulses by this BOB module – any code is available in API?
    And last question: how 5160-BOB is comparable to 2660-BOB – I mean about reading encoder pulses for close loop and also about powering stepper with 2.8A/phase?
    Best regards

    • Mario Nolten Reply

      Hi Radek,
      yes, you can use this API also on a Beaglebone. You probably need to adapt the SPI function for the Beaglebone. On an Arduino it is not so easy to use. The Arduino IDE does not allow to have a folder structure as we have in our API.
      For reading encoder pulses, you can directly connect the encoder to the TMC5160-BOB and read out the pulses from TMC5160_XENC. By setting the prescaler it shows directly the encoder position in microstep.
      The TMC2660-BOB is a bit different. The TMC2660 is a plain driver IC (without integrated motion controller as the TMC5160 has) so you need to apply step/dir pulses to drive the motor and the encoder has to be connected directly to the MCU. For this we have no API code for a Raspberry Pi or Beaglebone, since it is for both crucial to have a realtime OS.
      Best regards,

      • Radek Reply

        Thank you for valuable information.
        This is a very interesting product. I needed some time to break through the documentation. At the beginning I will try to run in mode 2 with an external application and without collecting the signal from the encoder. Then I will try mode 1 and encoder. One more question: if two motion controllers are used for controlling axes X/Y (amateur laser cutter), then both of them must be addressed separately or is there some form of communication between them and the code can be simplified? Will I find the answer to this problem in the API or do I have to implement it myself? In addition, is there any documentation how to electrically connect several axes in such a system using 5160 so that the motion controllers cooperate?
        Best regards

Leave a Reply

Your email address will not be published. Required fields are marked *