Using TMC2130 stepper drivers with Megatronics

This topic will help you use the Stepstick TMC2130 Stepper drivers with Megatronics. The setup is fairly easy, but the wiring may become a bit messy, as there is quite some extra wires necessary. The TMC2130 use SPI to allow the Microprocessor to communicate with the driver and set Microstepping settings for example. For more information on the features of the chip, please check the TMC2130 datasheet.

Prerequisites

First you need to hook up the wirring. SPI works with four wires: Data (Master -> Slave or MOSI), Data (Slave -> Master or MISO), Clock (SCK) and Chip Select (SS, CSN or CS). The Chip select wiring determines which device is active, only one device can be active at a time, so if you are using SD and a LCD for examples, they should be quiet and not listen when talking to a stepper driver. There is one chip select wire for each device, while the MISO, MOSI and SCK wire can be connected in parallel. The Stepsticks have a description on the back on how to connect them: Data in (SDI), Clock (SCK), Chip select (CSN) and Data out (SDO). Note that Data In is to be connected to the master data out (MOSI), while Data Out should got to MISO.

Megatronics support SPI in the SDOUT header, but it can be used to hook up a external SD or LCD, so it it more convenient to use the ICSP header. Chip select can be connected to any digital I/O and can be changed in the firmware. So you may use the I/Os from the keypad header too. But in this example we will use AUX3. Review the following wiring schema:

 The blue wire is MOSI, purple is Clock,green is MISO and the orange wires are Chip select.The Chip select wire go to AUX3 pins 3-6 in this example.

That's it for the wiring. In the firmware we need to setup some things. In this example we will look at MK4Duo, but other firmwares work about the same. In the Megatronics v3 pin mapping files (MK4duo/src/boards/703.h) change the CS_PIN definitions for each stepper driver to the I/Os you choose. If you used the wiring above, this will work:


//###X_AXIS
#define ORIG_X_STEP_PIN            58
#define ORIG_X_DIR_PIN             57
#define ORIG_X_ENABLE_PIN          59
#define ORIG_X_CS_PIN              49

//###Y_AXIS
#define ORIG_Y_STEP_PIN             5
#define ORIG_Y_DIR_PIN             17
#define ORIG_Y_ENABLE_PIN           4
#define ORIG_Y_CS_PIN              48

//###Z_AXIS
#define ORIG_Z_STEP_PIN            16
#define ORIG_Z_DIR_PIN             11
#define ORIG_Z_ENABLE_PIN           3
#define ORIG_Z_CS_PIN              46

//###EXTRUDER_0
#define ORIG_E0_STEP_PIN           28
#define ORIG_E0_DIR_PIN            27
#define ORIG_E0_ENABLE_PIN         29
#define ORIG_E0_CS_PIN             47
#define ORIG_SOL0_PIN              NoPin

In configuration_feature.h, find the driver types section and change the driver type for each axis you want to TMC2130, like this:


/****************************************************************************
 ******************************** Driver types ******************************
 ****************************************************************************
 *                                                                          *
 * Set driver type:                                                         *
 *  - A4988                                                                 *
 *  - A5984                                                                 *
 *  - DRV8825                                                               *
 *  - LV8729                                                                *
 *  - L6470                                                                 *
 *  - TB6560                                                                *
 *  - TB6600                                                                *
 *  - TMC2100                                                               *
 *  - TMC2130                                                               *
 *  - TMC2130_STANDALONE                                                    *
 *  - TMC2208                                                               *
 *  - TMC2208_STANDALONE                                                    *
 *  - TMC26X                                                                *
 *  - TMC26X_STANDALONE                                                     *
 *  - TMC2660                                                               *
 *  - TMC2660_STANDALONE                                                    *
 *  - TMC5130                                                               *
 *  - TMC5130_STANDALONE                                                    *
 *                                                                          *
 * See Configuration_Motor_Driver.h for configuration Motor Driver          *
 *                                                                          *
 ****************************************************************************/
#define  X_DRIVER_TYPE  TMC2130
#define  Y_DRIVER_TYPE  TMC2130
#define  Z_DRIVER_TYPE  TMC2130
#define X2_DRIVER_TYPE  A4988
#define Y2_DRIVER_TYPE  A4988
#define Z2_DRIVER_TYPE  A4988
#define E0_DRIVER_TYPE  TMC2130
#define E1_DRIVER_TYPE  A4988
#define E2_DRIVER_TYPE  A4988
#define E3_DRIVER_TYPE  A4988
#define E4_DRIVER_TYPE  A4988
#define E5_DRIVER_TYPE  A4988

That's it. If you get a compilation error, verify that the TMCStepper driver library is installed. Connecting to the Megatronics board shoul give message that the stepper drivers got connected upon startup:

Info:echo:MK4duo_4.3.7_beta
echo:Last Updated: Nov 13 2018 16:23:14 | Author: (none, default config)
echo:Compiled: Nov 13 2018
echo:Free Memory: 4121 PlannerBufferBytes: 1184
echo:stepperX connect!
echo:stepperY connect!
echo:stepperZ connect!
echo:stepperE0 connect!
echo:Factory Settings Loaded
Config:  G21    ; Units in (mm)


OVer ReprapWorld
ReprapWorld

RepRapWorld is de nummer één webshop voor al uw reprap benodigdheden voor uw 3D printer. We hebben een grote collectie 3D printer onderdelen, van onze beroemde elektronica lijnen tot filament van onze eigen productie. En dit alles aan een zeer scherpe prijs!

Contact

RepRapWorld B.V.
Wagenmaker 6a
2631RL Nootdorp
The Netherlands

Email: info@reprapworld.com
Tel: +31 (0) 85 - 009 15 31

Copyright 2009 - 2018 | ReprapWorld B.V.