Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TMC2208 and TMC2209 support (includes improvements) #1447

Draft
wants to merge 63 commits into
base: edge
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
9eda179
Basic UART communication with TMC2208 stepper motor driver
tiagojbalmeida May 3, 2018
c8db7dd
Define and document all registers
tiagojbalmeida May 4, 2018
595ad5b
Move SoftSerial and Modbus to libs folder
tiagojbalmeida May 4, 2018
f8fc5b1
Use Software UART libs to communicate with TMC2208 driver
tiagojbalmeida May 4, 2018
2c2de51
Import functions to configure driver via UART
tiagojbalmeida May 8, 2018
3070a61
Add StealthChop and StealthChop threshold functions
tiagojbalmeida May 16, 2018
0b1cb9a
Add TMC2208 config file
tiagojbalmeida May 16, 2018
33b5b48
Update velocity threshold
tiagojbalmeida May 16, 2018
72d0ab1
Move print information about successfull configured motor drivers
tiagojbalmeida May 16, 2018
0772b83
Add TMC2208 stepper motor driver support
tiagojbalmeida May 17, 2018
bb66641
Move Modbus lib back to spindle module
tiagojbalmeida May 17, 2018
51d0aa1
Put SPI and UART pins in an union to save memory
tiagojbalmeida May 18, 2018
f0fd91b
Delete UART object after initial driver configuration
tiagojbalmeida May 18, 2018
c1fc3e2
Put SPI and UART objects inside union to save memory
tiagojbalmeida May 18, 2018
2d140d4
Fix SPI/UART union structure
tiagojbalmeida May 18, 2018
d96e1ad
Remove driver setup condition
tiagojbalmeida May 18, 2018
1491367
Disable stealthChop threshold as default
tiagojbalmeida May 24, 2018
de542f6
Set general configuration register
tiagojbalmeida May 31, 2018
d10e6d3
set slaveconf register
tiagojbalmeida May 31, 2018
bfa686a
set HOLD parameters
tiagojbalmeida May 31, 2018
17624c6
Add tpowerdown register
tiagojbalmeida Jun 1, 2018
31af12e
Fix mode parameter name
tiagojbalmeida Jun 6, 2018
59f85fa
Added `motor_driver_control.timeout`.
LastDragon-ru Feb 23, 2019
07484e0
Added `motor_driver_control.driver.tpwmthrs`.
LastDragon-ru Feb 23, 2019
4cb6964
Fixed `motor_driver_control.driver.microsteps` description.
LastDragon-ru Feb 23, 2019
86a09a8
Write only mode support.
LastDragon-ru Feb 23, 2019
13a555b
Config description and small fixes
LastDragon-ru Feb 24, 2019
5254bc9
Optimized chip configuration (reduced number of writes)
LastDragon-ru Feb 24, 2019
6d97219
More settings:
LastDragon-ru Feb 24, 2019
a939716
Forced `setStepInterpolation(1)`
LastDragon-ru Feb 24, 2019
93e122a
Stealthchop settings support.
LastDragon-ru Mar 9, 2019
73db435
Removed tx/rx `port_number` shifting.
LastDragon-ru Sep 6, 2019
663b88b
created parent class for drivers, making the main code cleaner. Tuned…
V1pr Mar 1, 2020
53fc1ed
TMC22X still with debug messages (but fewer), compiles ok.
V1pr Mar 4, 2020
8968475
changed current for set_current from uint32_t to uint16_t (65535 mA s…
V1pr Mar 4, 2020
7a1785c
fixed missing type conversions. Compiles ok.
V1pr Mar 4, 2020
62f1126
M122 debugging (for TMC22X now)
V1pr Mar 8, 2020
7cdd4f4
debug msg fine tune
V1pr Mar 8, 2020
38b247e
added/finished TMC2209 support; renamed helper namespace to Stepstick…
V1pr Mar 8, 2020
e456e4d
renamed TMC22X to TMC220X to be more informative
V1pr Mar 9, 2020
c25d12b
added TMC2209 registers descriptors
V1pr Mar 14, 2020
f8cdb42
more coolconf settings, set_options handles coolconf for TMC220X
V1pr Mar 17, 2020
4b11eef
added credits, typo fix and example tmc2209 config
V1pr Mar 22, 2020
2d54262
removed timeout for driver init
V1pr Mar 22, 2020
183f909
motorcontrol default OFF
V1pr Mar 22, 2020
d79fc30
removed unneded motorcontrol.enable check
V1pr Mar 23, 2020
3ffb868
fixed typo for SEIMIN
V1pr Apr 5, 2020
53cb671
added TMC21X support from beeverycreative fork (modified function nam…
V1pr Apr 12, 2020
7d52f17
added missing config snippet
V1pr Apr 12, 2020
7cfa483
dirname fix
May 18, 2020
c449b8b
dirname fix 2
Jun 27, 2020
e8306f6
dirname fix 3
Jun 27, 2020
c8f1cf7
initialize connection_method and max current for TMC2130
mvadu Jun 28, 2020
873a364
Merge pull request #2 from mvadu/fix_2130
V1pr Jun 28, 2020
13750d7
Fix set_current signature
mvadu Jul 9, 2020
34a152e
Fix current calculation
mvadu Jul 9, 2020
d6b49ab
Fix current calculation
mvadu Jul 9, 2020
974f952
Merge pull request #3 from mvadu/fix_2130
V1pr Jul 10, 2020
5efdbe7
reverted current calculations to use PEAK + added notes about it
Jul 10, 2020
7e82903
Fix typo in default nc compared with NC
mvadu Aug 6, 2020
c6c0183
Implement Jim's 8b5afad
mvadu Aug 6, 2020
958a964
Check if RX pin is Interrupt Enabled
mvadu Aug 7, 2020
53f3f57
Merge pull request #4 from mvadu/fix_2209
V1pr Aug 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions ConfigSamples/Snippets/tmc2130_motor_driver.config
@@ -0,0 +1,10 @@
## Motor driver configuration
motor_driver_control.driver.enable true # Enable motor driver module
motor_driver_control.driver.axis X # Axis designator on which the motor driver is set
motor_driver_control.driver.chip TMC2130 # Motor driver chip type
motor_driver_control.driver.spi_channel 0 # Set corresponding pins of the selected spi channel
motor_driver_control.driver.spi_cs_pin 0.16 # Set chip select pin
#motor_driver_control.driver.current 1000 # Motor currents in mA - PEAK current, multiply with 0.707 to get RMS current
#motor_driver_control.driver.sense_resistor 50 # Sensing resistor value as a reference in milliOhms
#motor_driver_control.driver.microsteps 16 # Set microstepping value per step pulse. It can be 1, 2, 4, 8, 16, 32, 64, 128 or 256 microsteps
#motor_driver_control.driver.chopper_mode 2 # 0 = stealthChop ; 1 = spreadCycle ; 2 = traditional constant off-time
35 changes: 35 additions & 0 deletions ConfigSamples/Snippets/tmc2208_motor_driver.config
@@ -0,0 +1,35 @@
## Motor driver configuration
motor_driver_control.enable true # Enable module
motor_driver_control.alpha.enable true # Enable motor driver module
motor_driver_control.alpha.axis X # Axis designator on which the motor driver is set
motor_driver_control.alpha.chip TMC2208 # Motor driver chip type
motor_driver_control.alpha.sw_uart_tx_pin 0.27 # Transmitting line from the board to the alpha. Required.
motor_driver_control.alpha.sw_uart_rx_pin 0.28 # Receiving line to the board; NC if not connected (default).
#motor_driver_control.alpha.sw_uart_baudrate 9600 # Software UART baudrate. Value higher than 50k is not recommended
#motor_driver_control.alpha.current 1000 # Motor currents in mA - PEAK current, multiply with 0.707 to get RMS current
#motor_driver_control.alpha.sense_resistor 50 # Sensing resistor value as a reference in milliOhms
#motor_driver_control.alpha.microsteps 16 # The actual microstep resolution (MRES) that will be extrapolated to 256 microsteps.
# It can be 1, 2, 4, 8, 16, 32, 64, 128 or 256 microsteps
#motor_driver_control.alpha.chopper_mode 0 # 0 = spreadCycle ; 1 = stealthChop

# Stealthchop
# ! Please see datasheet for more details
motor_driver_control.alpha.stealthchop_tpwmthrs 0 # The upper velocity for stealthChop voltage PWM mode. When the velocity exceeds this value, the
# driver switches to spreadCycle. Default 0 (disabled).
#
# If enabled you probably should also tune SpreadCycle
motor_driver_control.alpha.stealthchop_pwm_lim 12 # PWM_LIM
motor_driver_control.alpha.stealthchop_pwm_reg 1 # PWM_REG
motor_driver_control.alpha.stealthchop_freewheel 0 # freewheel
motor_driver_control.alpha.stealthchop_pwm_autograd 1 # PWM_AUTOGRAD
motor_driver_control.alpha.stealthchop_pwm_autoscale 1 # PWM_AUTOSCALE
motor_driver_control.alpha.stealthchop_pwm_freq 1 # PWM_FREQ
motor_driver_control.alpha.stealthchop_pwm_grad 0 # PWM_GRAD
motor_driver_control.alpha.stealthchop_pwm_ofs 36 # PWM_OFS

# SpreadCycle
# ! Please see datasheet for more details
#motor_driver_control.alpha.spreadcycle_toff 5 # TOFF (2 - 15)
#motor_driver_control.alpha.spreadcycle_tbl 32 # TBL (16/24/32/48)
#motor_driver_control.alpha.spreadcycle_hstrt 4 # HSTART (1 - 8)
#motor_driver_control.alpha.spreadcycle_hend 0 # HEND (-3 - 12)
46 changes: 46 additions & 0 deletions ConfigSamples/Snippets/tmc2209_motor_driver.config
@@ -0,0 +1,46 @@
## Motor driver configuration
motor_driver_control.enable true # Enable module
motor_driver_control.beta.enable true # Enable motor driver module
motor_driver_control.beta.axis Y # Axis designator on which the motor driver is set
motor_driver_control.beta.chip TMC2209 # Motor driver chip type
motor_driver_control.beta.sw_uart_tx_pin 4.28 # Transmitting line from the board to the alpha. Required.
motor_driver_control.beta.sw_uart_rx_pin 2.11 # Receiving line to the board; NC if not connected (default).
motor_driver_control.beta.sw_uart_baudrate 19200 # Software UART baudrate. Value higher than 50k is not recommended
motor_driver_control.beta.current 2000 # Motor currents in mA - PEAK current, multiply with 0.707 to get RMS current
motor_driver_control.beta.sense_resistor 50 # Sensing resistor value as a reference in milliOhms
motor_driver_control.beta.microsteps 256 # The actual microstep resolution (MRES) that will be extrapolated to 256 microsteps.
# It can be 1, 2, 4, 8, 16, 32, 64, 128 or 256 microsteps
#motor_driver_control.beta.chopper_mode 0 # 0 = spreadCycle ; 1 = stealthChop

# Stealthchop
# ! Please see datasheet for more details
motor_driver_control.beta.stealthchop_tpwmthrs 0 # The upper velocity for stealthChop voltage PWM mode. When the velocity exceeds this value, the
# driver switches to spreadCycle. Default 0 (disabled).
#
# If enabled you probably should also tune SpreadCycle
motor_driver_control.beta.stealthchop_pwm_lim 12 # PWM_LIM
motor_driver_control.beta.stealthchop_pwm_reg 1 # PWM_REG
motor_driver_control.beta.stealthchop_freewheel 0 # freewheel
motor_driver_control.beta.stealthchop_pwm_autograd 1 # PWM_AUTOGRAD
motor_driver_control.beta.stealthchop_pwm_autoscale 1 # PWM_AUTOSCALE
motor_driver_control.beta.stealthchop_pwm_freq 1 # PWM_FREQ
motor_driver_control.beta.stealthchop_pwm_grad 0 # PWM_GRAD
motor_driver_control.beta.stealthchop_pwm_ofs 36 # PWM_OFS

# SpreadCycle
# ! Please see datasheet for more details
#motor_driver_control.beta.spreadcycle_toff 5 # TOFF (2 - 15)
#motor_driver_control.beta.spreadcycle_tbl 32 # TBL (16/24/32/48)
#motor_driver_control.beta.spreadcycle_hstrt 4 # HSTART (1 - 8)
#motor_driver_control.beta.spreadcycle_hend 0 # HEND (-3 - 12)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having some sane suggested values here would be gerat.

# Stallguard & Coolconf
#motor_driver_control.beta.stallguard_tcoolthrs 0 # Lower coolstep velocity treshold
#motor_driver_control.beta.stallguard_thrs 0 # SG_RESULT <= SGTHRS*2

#motor_driver_control.beta.coolconf_seimin 0 # 0 = 1/2 current setting (IRUN) - use with IRUN >= 10!
# 1 = 1/4 current setting (IRUN) - use with IRUN >= 20!
#motor_driver_control.beta.coolconf_sedn 0 # 0/2/8/32
#motor_driver_control.beta.coolconf_semax 0 # 0-15
#motor_driver_control.beta.coolconf_seup 0 # 1,2,4,8 - current increment steps per measured SG value
#motor_driver_control.beta.coolconf_semin 0 # 0: CoolStep off, 1-15