This library is used to control one or more TMC2209 modules via UART using an AVR microcontroller. Apart from reading and writing the TMC2209 registers, this library can also be used to drive a stepper motor by using the stepperCon library in the background. The stepperCon library provides non blocking functions by using an interrupt, to drive multiple stepper motors with custom acceleration and speed, to keep track of motor positions, 3-axis motor coordination, as well as other useful functions. UART library is also provided that can use up to 2 USART peripherals at the same time: one for interfacing with the driver IC and one for debugging (assuming the microcontroller has two USART peripherals).
The serial communication has some extra features for checkup such as:
- reads the interface transmission counter (IFCNT) register after every write to ensure the IC received the correct data.
- compares CRCs.
- checks if correct number of bytes has been received.
- if an error occurs it retries 2 times then sets a communication error flag that the user can check after each function is executed and take the appropriate action if an error occurs.
If you wish to learn on how to wire the TMC2209 driver, you can find a tutorial here.
Contents
- Library Structure
- Default Settings
- Usage
- Documentation
- Create a structure object for each driver
- Initialization
- Read IC version
- Read Global Status Flags (GSTAT)
- GSTAT check if module was Reset
- GSTAT check if Driver Error
- GSTAT check if Charge Pump is Under Voltage
- Status check for UART error
- Read register PWM_SCALE_SUM
- Read register PWM_SCALE_AUTO
- Read register PWM_OFS_AUTO
- Read register PWM_GRAD_AUTO
- Read register SG_RESULT (StallGuard)
- Read register TSTEP
- Read register DRV_STATUS (Driver Status Flags)
- DRV_STATUS check Standstill
- DRV_STATUS check Chopper type
- DRV_STATUS check CS_ACTUAL
- DRV_STATUS check Temperature flags
- DRV_STATUS check Open Load flags
- DRV_STATUS check Low Side Short flags
- DRV_STATUS check Short to Ground flags
- DRV_STATUS check Over-temperature flag
- DRV_STATUS check Over-temperature Pre-warning flag
- Set micro-step resolution
- Set speed
- Set acceleration and deceleration
- Set direction
- Set chopper
- Set SpreadCycle threshold
- Set register IHOLD_IRUN
- Set register TPOWERDOWN
- Set register SGTHRS (StallGuard)
- Set register TCOOLTHRS (CoolStep threshold)
- Set register COOLCONF (CoolStep)
- Set Standstill mode
- Enable/disable driver by software
- Move to absolute position
- Move to relative position
- Start TMC2209 internal step generator
- Stop TMC2209 internal step generator
- StealthChop Automatic Tuning (AT)
- Download