Introduction: UART This! Serial Control of Stepper Motors With the TMC2208, Ramps 1.4 and Marlin

About: I'm a former electrical engineer who's changed careers and become a physical therapist. I still have a passion for tech though, as well as healthcare now.

Most people who are involved with DIY 3D printers or just like tinkering with a Maker-Grade commercial printer, will have heard of the Trinamic series of stepper motor driver chips. These little chips are making waves throughout the consumer and prosumer 3D printer markets due to their astonishing ability to render a 3D printer practically silent.

The TMC2208 is also used by the German manufacturer Watterott in their SilentStepStick stepper motor driver product series. However, there is very little information written in layman's/Maker's terms regarding how to actually wire up this stepper motor driver board, to a traditional Ramps 1.4 to 1.6 style Arduino shield, in order to use the feature of serial communications over UART to control the stepper motors. In this Instructable, I will try to alleviate this by taking you through a step-by-step setup of how to use a TMC2208 based SilentStepStick in a UART configuration on your 3D printer.

EDIT-August 2018: When I originally wrote this Instructable, the default Pin assignments within Marlin were different from what they are now. The photo above shows my Y-cables in different positions to what they would be now, in the current version of Marlin. See Step 10 for details on how to find these current Pin assignments.

Step 1: Why Write This Instructable?

With these TMC2208-based SilentStepSticks, the only option really discussed anywhere on the web is for direct plug-and-play replacement of the Pololu A4988 drivers (which doesn't give you the benefits of the UART serial communication for control over your stepper motors), but the TMC2208 driver is actually capable of three different modes of operation in controlling the stepper motors of your 3D printer:

  • Legacy mode: Direct plug-in replacement for the Pololu A4988 on a Ramps 1.4 - 1.6 style board
  • Standalone mode (no active serial communications) with the STEP/DIR settings being preset by setting the OTP (One Time Programmable) bits
  • Active STEP/DIR Driver with full UART serial control giving full diagnostics and control over the stepper motors

Mode 1 (Legacy Mode): this has already been discussed in the opening paragraph of this Instructable, basically solder on header pins, stick on a heat sink so it looks just like a Pololu A4988 board, and plug it into the Ramps board.

Mode 2 (Standalone Mode): This mode has been explained very well by YouTube creator Keith Young in which he shows you how to solder the header pins to the SilentStepStick board and then set/program the OTP (one-time programmable) bits to change the chip from stealthChop2 mode to spreadCycle mode.

Note, these OTP bits are truly one-time programmable. Once you "set" these bits you make a permanent change in the silicon of the chip and this cannot be reversed. So I would recommend operating these chips in the default stealthChop2 mode for a while, to see if you get any skipped steps, before considering changing them to the spreadCycle mode by setting these OTP bits.

Mode 3 (Active STEP/DIR Driver): This mode is what this Instructable is all about. YouTube creator Alex Kenis has put out a great video on this option in which he explores the best micro-step settings in firmware and driver voltage levels (12V vs 24V), to get the most torque from your motors.(edit: Alex Kenis put out an update video on this process and goes into a lot more detail)

The intent of this Instructable is to expand upon his work (in terms of explanation) and make it more approachable to the less technical Makers out there. In short, Mode 3 allows the TMC2208-based SilentStepStick to be actively/dynamically controlled through UART (serial communications) by firmware (Marlin in this case).

You don't have to fiddle with jumpers to set your micro-steps, just change it in the firmware, and you can dynamically change the amount of current going to each stepper motor (no more adjusting that small potentiometer on the driver board) just by sending a GCode command (M906).

BENEFITS OF MODE 3

  • Motor current can be set arbitrarily through the firmware
  • Micro-steps can be set arbitrarily through the firmware (up to 256 real micro-steps)
  • Real and interpolated micro-steps can be combined to achieve max torque
  • Firmware can switch the stepper motors between stealthChop2 and spreadCycle mode on the fly via UART (sect. 1.4 of datasheet, so no need to set those OTP bits)
  • Motor standby current can be reduced dynamically (via UART) when the motor is not moving (sect. 1.6 of datasheet)

...just to name a few benefits

One more bit of explanation before I get into this in detail. For those who haven't realized this yet, there are two companies involved here:

  1. Trinamic who actually design and make the TMC2208 chip, and
  2. Watterott who use the TMC2208 chip on their SilentStepStick stepper motor driver board

So let's get into it...

Step 2: Supplies and Tools

Here are the basic tools and supplies you will need to complete this Instructable. Mostly, these items are needed to make the Y-cable required for the UART communication between the SilentStepStick and the Ramps board.

NOTE: the following links are shortened URLs, they are NOT affiliate links.

Supplies

  • Heat shrink tubing, approx. 5cm (2") in length and 3mm (3/16") in diameter for each Y-cable. If you don't have any heat shrink tubing at all, I suggest getting a pack of it in various sizes for future projects (see photo).
  • Metal Dupont connectors (female), along with 1-pin and 2-pin plastic housings for each Y-cable. Again, get a pack that includes both male and female connectors and a variety of plastic housings
  • Wire: I used 22AWG or 0.326mm2 (10cm for each Y-cable)
  • 1KOhm resistor (the tolerance of the resistor doesn't matter), one resistor is needed for each Y-cable
  • Heat sinks: both the Pololu and taller SilentStepStick varieties. You'll need one of each for each stepstick you are using.
  • Watterott V2 Protector Boards (U.S), Europe or Female riser header pins (not shown: to elevate the SilentStepSticks enough to get a small heat sink underneath)
  • Optional: The heat sinks should come with thermal adhesive tape already applied. If not then you can get some here.

Tools

Step 3: SilentStepStick Jumper Pads

By default, the UART pin on the Trinamic TMC2208 chip is not connected to the header pin(s) of the Watterott SilentStepStick. In order to make this physical connection from the chip to the header pin we need to solder a jumper between the jumper pads on the bottom of the SilentStepStick board. You can see these solder pads in the Fritzing and photographic images above.

There have been several versions of the Watterott TMC2208 board, with some having only two jumper pads. On the iteration I have (and that shown in the photos in this Instructable), there are three pads grouped together. The center pad is the direct connection back to the TMC2208 chip. The two pads on either side connect directly to the header pin they are closest to. The silkscreen side of the board has these two header pins labeled collectively as PDN UART.

They are both available to be used as the PDN_UART line, because neither pin is used by the Arduino Mega for the Pololu A4988 drivers. So Watterott has decided to designate both header pins as being available for solder connection to the TMC2208 PDN_UART pin of the chip.

We only need one of these two header pins for our UART serial connection, so you can either solder the center pad to the left or right pad, or to both. If you only solder to one side, then you must remember to solder the header pin for that side pointing up, so you can attach your UART jumper wire to it later. If you want to eliminate any chance of mistake, then just solder all three pads together. That way it doesn't matter which header pin you solder pointing up, as they will both work.

Step 4: SilentStepStick Header Pins

Now that the jumper pads are soldered we can solder the header pins in place (if your board didn't already come with the header pins attached). According to the Trinamic TMC2208 datasheet (page 5), a benefit to using the chip configured as Option 3 (UART) is that all control lines (EN, DIAG, INDEX, MS1, MS2, and analog current setting VREF) are replaced by the one UART line, and therefore are configured through, and controlled by, firmware.

So technically speaking, the only header pins actually required on this side of the SilentStepStick board are the Dir (direction), Step, and PDN_UART pins. The PDN_UART pin will need to be soldered pointing up so you can attach the jumper wire to the Ramps board; however, in reality, the EN pin must be soldered down as well. I give credit to Instructables member crzcrz for pointing this out to me.

If the EN header pin is not soldered in, then no enable signal is sent to the TMC2208 chip, and your motors will not turn on. I'm not sure if this is an issue with the current version of Marlin (1.1.8 as of the time of writing this Instructable) or with the latest version of the Watterott 2208 boards. I'll update this 'ible once I find out more. Regardless, just remember to also solder on the EN header pin. The images above are correct. If you want to play it completely safe, then just solder on all of the header pins, with the PDN UART pin pointing up, and the others pointing down.

Step 5: Heat Sinks

These TMC2208 chips run hot (as do any of the stepper driver chips that are sinking close to an amp or more of current). These chips have built-in thermal protection, but that means your stepper motors will lose steps if these chips get too hot (and the thermal protection turns on), thereby ruining your print.

So do yourself a favor and put plenty of heat sink surface area on these chips. In the video referenced previously by Alex Kenis he uses two heat sinks and also puts a fan on his Ramps board. I have used my chips with only one Pololu type heat sink on top, along with a fan, and I still lost steps about two hours into a print (motor current set to 800ma in Marlin). So I now also use two heat sinks (see photos above) on mine, with a fan, and everything runs very well.

The top heat sink is 9mm x 9mm x 12mm and the bottom heat sink is a typical Pololu A4988 heat sink measuring approx. 9mm x 9mm x 5mm. In order to allow space for the bottom heat sink, the SilentStepStick needs to be put onto either the Watterott V2 Protector Board or a line of female riser pins, to raise it up enough to clear the pins on the Ramps board underneath.

Watterott makes the specialized "V2 Protector" riser board, which uses a Schottky diode, to ensure the driver chips are powered in the correct sequence, between the VIO (logic level 3.3V/5V) and VM (12v/24v supply) voltages. At the time of writing this Instructable, I didn't have any of these diode protector boards available to me, so I just used some female risers, and it worked without a problem.

I have since purchased some of the V2 Protector boards and now use them, simply because they are cheap insurance against burning up your TMC2208 stepsticks. Just be aware that without these V2 protector boards, if you manually move your axes around quickly, the back EMF produced within the stepper motors could be substantial and could feed back into the stepsticks and destroy the logic circuitry in the TMC2208 chip. So if you decide not to get the V2 Protector Boards, just move the axis slowly to minimize the amount of back EMF produced.

Both the female risers and V2 Protector Boards fit VERY tightly on the Ramps board, so install them first, like you see in the photo, then plug your stepsticks into the risers.

Step 6: Connection to Ramps Board

Looking at the image above from Watterott, we can see that in order for the SilentStepStick to communicate with the Ramps board via UART, there needs to be a one wire connection from the UART pin on the SilentStepStick. That one wire then splits into two lines (Rx and Tx) for connection to the Ramps board, with the Tx (transmit) connection being made through a 1K Ohm resistor.

The way I chose to make my Y-cable places the split from the one wire into the two wires, near the AUX2 header pins on the Ramps board. For those experienced makers out there, you will have no problem making this cable. For the new Makers, I'll explain step-by-step how I made my Y-cables.

The single wire connects to the SilentStepStick, and the double wire end connects to the Ramps board. The 1K Ohm resistor is covered with the blue heat shrink tubing.

ALTERNATIVELY (use two cables):
If your TMC2208 SilentStepStick has three solder pads on the bottom of the board, you can solder all three jumper pads together, which ties both associated PDN_UART header pins together on the SilentStepStick, and you can put both header pins pointing up. Since both header pins are physically tied together, you don't have to make a "Y" cable. Just solder a 1KOhm resister in line with one of the cables (for the Tx line), plug that Tx wire into one of the two available header pins on the SilentStepStick, and use a second plain wire to go from the Rx pin on the Ramps board to the second header pin on the SilentStepStick.

Just ensure you keep track of the Tx and Rx pins on the Ramps board, making sure both cables go to the same SilentStepStick.

Step 7: Prep the Wire and Resistor

Cut The Wire To Length

  • Get some small gauge wire (I used approx. 22AWG or 0.326mm2), and cut a piece 10cm long
  • From this 10cm piece, cut off a short piece 28mm (or approx. 1 1/8") long, then strip some of the insulation jacket off of both ends.
  • Get a 1K Ohm resistor and cut one lead to 12mm (approx. ½") in length. This cut end will be crimped and soldered to a female Dupont connector.


Attach The Dupont Connectors

  • Crimp a female Dupont connector to one end of the wire
  • Crimp and solder a female Dupont connector to the cut lead of the 1K Ohm resistor. I soldered the connector on because the resistor lead was so thin I wasn't able to get a firm connection with crimping alone.

Step 8: Combine the Two Leads

  • Push both Dupont connectors into the 2-pin female plastic housing
  • Slip a bit of heat shrink tubing over the resistor to prevent accidental shorts (and thus signal injections) from the environment.
  • Twist the end of the wire and other lead of the resistor together, and then fold the remaining lead of the resistor back to form a hook.

Step 9: Soldering the Y-cable

  • Take the remainder of the original 10cm long wire and strip one end, then fold this stripped end back to make a hook
  • Hook this wire over the hook you made from the resistor lead, and pinch down to lock them together
  • Solder the two halves together.

For those new to soldering, I like to use a solder flux pen to apply a little liquid solder to the connection. It makes the process so much faster and cleaner. I use this in addition to flux core solder wire, because the liquid solder really pulls the solder in between the individual strands of wire.

  • Lastly, push a bit of heat shrink tubing over this connection to reinforce it

The last step will be to cut the single wire to length, strip the wire, crimp on a Dupont connector and attach that end to the SilentStepStick, but the "hard" part of making the Y-cable is complete.

Step 10: Firmware (Marlin 1.1.8): Pins.h File

Within Marlin, the pins.h file identifies which pins on the Ramps board are to be the receive and transmit pins for the UART software serial connection. By default, these pins are located within the AUX-2 header on the Ramps board. In the image above, you can see these header pins along with the default motor/axis they are assigned to in Marlin 1.1.8.

To find this section in the pins.h file, just open the file in a decent text editor like NotePad++ or Atom, and search for "HAVE_TMC2208". If you wish to change the pin numbers, that go to each axis, the pins.h file is where you make this change. The graphic above, of the Ramps board, shows the default pin assignments within the pins.h file in Marlin 1.1.8.

Plug each Y-cable from the respective set of header pins, in the AUX2 header, to the corresponding SilentStepStick PDN_UART pin. Be sure you put the resistor side of the Y-Cable on the Tx (Transmit) pin.

Since writing this Instructable, I have added a 5th SilentStepStick driver to my Ramps board (for a second Z-Axis motor), and have chosen to use pins 57 and 58 from the AUX1 header for this UART connection (see graphic above).

Step 11: Firmware (Marlin 1.1.8): Configuration_adv.h File

If you decide not to adjust the pins.h file, and just go with the default pin assignments in the AUX2 header, then the only file you will need to modify is the configuration_adv.h file. In this file, you need to turn on/activate the section for the TMC2208 so Marlin will begin communicating with the SilentStepStick over the UART serial interface.

You can open the configuration_adv.h file either in the Arduino IDE or using a text editor such as Notepad++ or Atom. Once open, follow these steps to activate the TMC2208 feature:

Part 1: Activate the TMC2208 feature

  • search for "HAVE_TMC2208"
  • Remove the two "//" that are at the start of this line (this "uncomments" the line, and makes it active)


Part 2: Tell Marlin which axes have stepsticks

A few lines further down you will find separate lines for each of the axes of the machine

  • Uncomment the line for each axis you want to use a TMC2208 SilentStepStick on

The next area further down (stepper driver settings) is where we can specify how the stepper driver controls the motors.

Part 3A: Stepper driver settings (hold current and step interpolation)

  • Hold current: this value is set from 0.0 to 1.0 and establishes how much current is used by the stepper motors when they are not moving, i.e. on hold. The range of 0.0 to 1.0 changes the normal run current from 0-100%. The default value is 0.5 (50%).
  • Step interpolation: setting this to "true" turns on 256 step interpolation. When we combine this step interpolation with the physical micro-step settings (talked about next), we can maximize the torque delivered by the stepper motors.

Part 3B: Stepper driver settings (motor run current and physical micro-steps)

  • Motor Current: here you can specify how much current your individual stepper motors will use while they are running. Prior to UART serial control, you had to use a small screwdriver and physically adjust the small potentiometer on the stepstick driver board. Well, not anymore, just make the change here in firmware. Even better, you can send the GCode command M906 from your printer software and dynamically change the run current while the printer is operating.
  • Micro-steps: this is where you set the physical/real micro-steps of your motors. You can set these from 0-256 real micro-steps, but the most torque is produced when this value is set to 4 (1/4 stepping...see below).

In the video by Alex Kenis, he tested torque values of a motor under different configurations and found that the motor produced the most torque when the TMC2208 SilentStepSticks were run in the following configuration:

  • powered from a 24v source
  • Step Interpolation was made "true" (Part 3A above)
  • real micro-steps were set to 4 (for 1/4 stepping)
  • Mode of operation was set to stealthChop (as opposed to spreadCycle mode)


Part 4: enable stealthChop mode

  • Uncomment the line that says "#define STEALTHCHOP" in order to enable the stealthChop mode


Part 5: enable Hybrid mode (switches dynamically between stealthChop and spreadcycle modes)

  • The last portion of this section will be to uncomment/enable the line that says "#define HYBRID_THRESHOLD"
  • You can adjust the speed values to specify at what speed the driver switches from stealthChop mode to spreadCycle mode and back again.

Part 6 (not pictured): add the TMC2208 library to your Arduino IDE so Marlin can use this library when compiling.

  • In your Arduino IDE, go the "Sketch" menu, down to "Include Library" and finally choose "Manage Libraries..."
  • In the Library Manager window that opens, type "2208" in the search box, and the library file for the TMC2208 will appear
  • Click on the "TMC2208Stepper" result and you should see an Install button appear, just click that to install the library

Re-calibrate the Printer

Lastly, if you change your micro-steps, from what you were using previously, then you will need to re-calibrate your printer (all motors) by opening the configuration.h file in Marlin, going to the section "@section motion", and changing the steps/mm numbers in this line:

#define DEFAULT_AXIS_STEPS_PER_UNIT { 40, 40, 200, 48.2 }

NOTE: these are my values for my printer, you will need to establish your own values based on your printer and what micro-step values you are using, because the firmware will be using these values to send a certain amount of steps/mm for each axes movement. But, if your stepper driver is driving the stepper motors at a different steps/mm count (because your micro-step settings are now different), then your printer's resolution will not be accurate.

Step 12: Firmware (Marlin 1.1.9): Pins.h File

This is an update of this Instructable to account for the changes in Marlin with release 1.1.9

Of particular note, the developers changed the default pin assignments for the SilentStepStick axes. See the graphic above for the default 1.1.9 pin assignments for each axis. Since writing this Instructable, I have added a 5th SilentStepStick driver to my Ramps board (for a second Z-Axis motor), and have chosen to use pins 57 and 58 from the AUX1 header for this UART connection (see graphic above).

Step 13: Firmware (Marlin 1.1.9): Configuration.h File

In Marlin 1.1.9 the developers moved the stepper driver selection section from the Configuration_adv.h file into the Configuration.h file. They also expanded on how you can identify what type of mode you are operating the SilentStepStick in, by typing:

  • TMC2208 -- to indicate you want to control the SilentStepStick via UART
  • TMC2208_STANDALONE -- to not use UART control and instead use the TMC2208 SilentStepStick in the same manner as you would a standard Pololu A4988, in other words plug-in-play

configuration.h

Within the configuration.h file, search for "stepper drivers". This should bring you to the correct section of the file. By default, all potential stepper motors are identified as using the Pololu A4988 driver.

For each axis and extruder you plan on using a TMC2208 SilentStepStick on, change the A4988 to either TMC2208 or TMC2208_STANDALONE.

I operate five SilentStepSticks. You can see how I have set up my configuration.h file above.

This is the only change you will need to make within the configuration.h file, in order to use the TMC2208 SilentStepSticks. Now move on to the next step to set up the configuration_adv.h file.

Step 14: Firmware (Marlin 1.1.9): Configuration_adv.h File

Within the configuration_adv.h file you will set up everything, just as in Step 11 of this Instructable, except for specifying which axes and extruders use the TMC2208 driver, as this was moved to the configuration.h file (see Step 13). Nothing else has changed in this configuration_adv.h file--related to the TMC2208 drivers.

To find this section, just search for "section tmc_smart".

Step 15: Finish!

Whew! You finally made it. Now plug in your Ramps board, flash your firmware and try it out.

For those who noticed that I had Fritzing parts for the Ramps board and the TMC2208 SilentStepStick board, and wondered where I got them from, well, nowhere. I had to make them for this Instructable. At the time of writing this Instructable, the Fritzing site "sign-up" page was broken, and I was unable to create an account in order to upload my Fritzing files, so I am attaching them to this Instructable for those who want to import them into your Fritzing projects.