TMCStepper
Library supporting Trinamic Stepper Drivers for Arduino platforms
Loading...
Searching...
No Matches
TMC5130Stepper.h
Go to the documentation of this file.
1
7#pragma once
8
9#define INIT5130_REGISTER(REG) TMC5130_n::REG##_t REG##_register{}
10
12 public:
13 TMC5130Stepper(uint16_t pinCS, float RS = default_RS, int8_t link_index = -1);
14 TMC5130Stepper(uint16_t pinCS, uint16_t pinMOSI, uint16_t pinMISO, uint16_t pinSCK, int8_t link_index = -1);
15 TMC5130Stepper(uint16_t pinCS, float RS, uint16_t pinMOSI, uint16_t pinMISO, uint16_t pinSCK, int8_t link_index = -1);
16
17 void begin();
18 void defaults();
19 void push();
20
21 void rms_current(uint16_t mA) { TMC2130Stepper::rms_current(mA); }
22 void rms_current(uint16_t mA, float mult) { TMC2130Stepper::rms_current(mA, mult); }
24
25 // R: IFCNT
26 uint8_t IFCNT();
27 // W: SLAVECONF
28 uint16_t SLAVECONF();
29 void SLAVECONF(uint16_t input);
30 // R: IOIN
31 uint32_t IOIN();
32 bool refl_step();
33 bool refr_dir();
34 bool encb_dcen_cfg4();
35 bool enca_dcin_cfg5();
36 bool drv_enn_cfg6();
37 bool enc_n_dco();
38 bool sd_mode();
39 bool swcomp_in();
40 uint8_t version();
41
42 // RW: GCONF
45
46 // RW: SW_MODE
47 uint32_t SW_MODE();
48 void SW_MODE(uint32_t input);
49
50 void stop_l_enable(bool B);
51 void stop_r_enable(bool B);
52 void pol_stop_l(bool B);
53 void pol_stop_r(bool B);
54 void swap_lr(bool B);
55 void latch_l_active(bool B);
56 void latch_l_inactive(bool B);
57 void latch_r_active(bool B);
58 void latch_r_inactive(bool B);
59 void en_latch_encoder(bool B);
60 void sg_stop(bool B);
61 void en_softstop(bool B);
62
63 bool stop_r_enable();
64 bool pol_stop_l();
65 bool pol_stop_r();
66 bool swap_lr();
67 bool latch_l_active();
68 bool latch_l_inactive();
69 bool latch_r_active();
70 bool latch_r_inactive();
71 bool en_latch_encoder();
72 bool sg_stop();
73 bool en_softstop();
74
75 // R+C: RAMP_STAT
76 uint32_t RAMP_STAT();
77 bool status_stop_l();
78 bool status_stop_r();
79 bool status_latch_l();
80 bool status_latch_r();
81 bool event_stop_l();
82 bool event_stop_r();
83 bool event_stop_sg();
84 bool event_pos_reached();
85 bool velocity_reached();
86 bool position_reached();
87 bool vzero();
88 bool t_zerowait_active();
89 bool second_move();
90 bool status_sg();
91
92 // RW: ENCMODE
93 uint32_t ENCMODE();
94 void ENCMODE(uint32_t input);
95 void pol_a(bool B);
96 void pol_b(bool B);
97 void pol_n(bool B);
98 void ignore_ab(bool B);
99 void clr_cont(bool B);
100 void clr_once(bool B);
101 void pos_edge(bool B);
102 void neg_edge(bool B);
103 void clr_enc_x(bool B);
104 void latch_x_act(bool B);
105 void enc_sel_decimal(bool B);
106 bool pol_a();
107 bool pol_b();
108 bool pol_n();
109 bool ignore_ab();
110 bool clr_cont();
111 bool clr_once();
112 bool pos_edge();
113 bool neg_edge();
114 bool clr_enc_x();
115 bool latch_x_act();
116 bool enc_sel_decimal();
117
118 // W: OUTPUT
119 bool TMC_OUTPUT();
120 void TMC_OUTPUT(bool input);
121 // W: X_COMPARE
122 uint32_t X_COMPARE();
123 void X_COMPARE(uint32_t input);
124 // RW: RAMPMODE
125 uint8_t RAMPMODE();
126 void RAMPMODE(uint8_t input);
127 // RW: XACTUAL
128 int32_t XACTUAL();
129 void XACTUAL(int32_t input);
130 // R: VACTUAL
131 int32_t VACTUAL();
132 // W: VSTART
133 uint32_t VSTART();
134 void VSTART(uint32_t input);
135 // W: A1
136 uint16_t a1();
137 void a1(uint16_t input);
138 // W: V1
139 uint32_t v1();
140 void v1(uint32_t input);
141 // W: AMAX
142 uint16_t AMAX();
143 void AMAX(uint16_t input);
144 // W: VMAX
145 uint32_t VMAX();
146 void VMAX(uint32_t input);
147 // W: DMAX
148 uint16_t DMAX();
149 void DMAX(uint16_t input);
150 // W: D1
151 uint16_t d1();
152 void d1(uint16_t input);
153 // W: VSTOP
154 uint32_t VSTOP();
155 void VSTOP(uint32_t input);
156 // W: TZEROWAIT
157 uint16_t TZEROWAIT();
158 void TZEROWAIT(uint16_t input);
159 // RW: XTARGET
160 int32_t XTARGET();
161 void XTARGET(int32_t input);
162 // R: XLATCH
163 uint32_t XLATCH();
164 // RW: X_ENC
165 int32_t X_ENC();
166 void X_ENC(int32_t input);
167 // W: ENC_CONST
168 uint32_t ENC_CONST();
169 void ENC_CONST(uint32_t input);
170 // R: ENC_STATUS
171 bool ENC_STATUS();
172 // R: ENC_LATCH
173 uint32_t ENC_LATCH();
174
176
184
186
187 protected:
205
206 struct IFCNT_t { constexpr static uint8_t address = 0x02; }; // R
207 struct VACTUAL_t { constexpr static uint8_t address = 0x22; }; // R
208 struct XTARGET_t { constexpr static uint8_t address = 0x2D; }; // RW
209 struct XLATCH_t { constexpr static uint8_t address = 0x36; }; // R
210 struct X_ENC_t { constexpr static uint8_t address = 0x39; }; // RW
211 struct ENC_STATUS_t { constexpr static uint8_t address = 0x3B; }; // R+C
212 struct ENC_LATCH_t { constexpr static uint8_t address = 0x3C; }; // R
213
214 /*
215 INIT_REGISTER(MSLUT0);
216 INIT_REGISTER(MSLUT1);
217 INIT_REGISTER(MSLUT2);
218 INIT_REGISTER(MSLUT3);
219 INIT_REGISTER(MSLUT4);
220 INIT_REGISTER(MSLUT5);
221 INIT_REGISTER(MSLUT6);
222 INIT_REGISTER(MSLUT7);
223 INIT_REGISTER(MSLUTSEL);
224 INIT_REGISTER(MSLUTSTART);
225 INIT_REGISTER(MSCNT);
226 INIT_REGISTER(MSCURACT);
227 */
228
229 static constexpr float default_RS = 0.15;
230
231 protected:
245
250
253};
void pwm_symmetric(bool B)
Definition PWMCONF.cpp:26
void pwm_grad(uint8_t B)
Definition PWMCONF.cpp:23
bool diag1_pushpull()
Definition GCONF.cpp:55
void pwm_autoscale(bool B)
Definition PWMCONF.cpp:25
void pwm_freq(uint8_t B)
Definition PWMCONF.cpp:24
void pwm_ampl(uint8_t B)
Definition PWMCONF.cpp:22
void PWMCONF(uint32_t value)
Definition PWMCONF.cpp:17
void freewheel(uint8_t B)
Definition PWMCONF.cpp:27
void shortfilter(uint8_t)
void pwm_autograd(bool B)
Definition PWMCONF.cpp:52
void GLOBAL_SCALER(uint8_t)
void drvstrength(uint8_t)
Definition DRV_CONF.cpp:25
void SHORT_CONF(uint32_t)
void s2g_level(uint8_t)
TMC2160Stepper(uint16_t pinCS, float RS=default_RS, int8_t link_index=-1)
void otselect(uint8_t)
Definition DRV_CONF.cpp:24
uint8_t pwm_scale_sum()
void s2vs_level(uint8_t)
void pwm_reg(uint8_t B)
Definition PWMCONF.cpp:54
void DRV_CONF(uint32_t)
Definition DRV_CONF.cpp:17
void bbmclks(uint8_t)
Definition DRV_CONF.cpp:23
uint16_t OFFSET_READ()
void pwm_lim(uint8_t B)
Definition PWMCONF.cpp:55
void pwm_ofs(uint8_t B)
Definition PWMCONF.cpp:48
void shortdelay(bool)
void filt_isense(uint8_t)
Definition DRV_CONF.cpp:26
uint16_t pwm_scale_auto()
void bbmtime(uint8_t)
Definition DRV_CONF.cpp:22
TMC5130Stepper(uint16_t pinCS, float RS=default_RS, int8_t link_index=-1)
bool en_softstop()
Definition SW_MODE.cpp:44
bool velocity_reached()
Definition RAMP_STAT.cpp:23
bool position_reached()
Definition RAMP_STAT.cpp:24
INIT_REGISTER(RAMPMODE)
INIT_REGISTER(ENC_CONST)
uint32_t RAMP_STAT()
Definition RAMP_STAT.cpp:11
bool event_stop_sg()
Definition RAMP_STAT.cpp:21
INIT_REGISTER(OUTPUT)
INIT_REGISTER(SW_MODE)
bool latch_l_inactive()
Definition SW_MODE.cpp:39
INIT_REGISTER(TZEROWAIT)
uint32_t ENCMODE()
Definition ENCMODE.cpp:16
bool clr_enc_x()
Definition ENCMODE.cpp:44
bool latch_r_inactive()
Definition SW_MODE.cpp:41
INIT_REGISTER(VSTART)
void stop_l_enable(bool B)
Definition SW_MODE.cpp:21
bool status_latch_r()
Definition RAMP_STAT.cpp:18
bool second_move()
Definition RAMP_STAT.cpp:27
INIT_REGISTER(VSTOP)
bool event_stop_r()
Definition RAMP_STAT.cpp:20
uint8_t version()
Definition IOIN.cpp:125
bool status_latch_l()
Definition RAMP_STAT.cpp:17
bool en_latch_encoder()
Definition SW_MODE.cpp:42
bool neg_edge()
Definition ENCMODE.cpp:43
uint16_t rms_current()
INIT_REGISTER(ENCMODE)
void rms_current(uint16_t mA)
bool refl_step()
Definition IOIN.cpp:117
uint32_t IOIN()
Definition IOIN.cpp:116
void rms_current(uint16_t mA, float mult)
static constexpr float default_RS
bool latch_r_active()
Definition SW_MODE.cpp:40
INIT_REGISTER(X_COMPARE)
bool stop_r_enable()
Definition SW_MODE.cpp:34
bool refr_dir()
Definition IOIN.cpp:118
bool enc_sel_decimal()
Definition ENCMODE.cpp:46
bool clr_once()
Definition ENCMODE.cpp:41
INIT_REGISTER(XACTUAL)
bool diag1_poscomp_pushpull()
bool pol_stop_l()
Definition SW_MODE.cpp:35
bool drv_enn_cfg6()
Definition IOIN.cpp:121
bool encb_dcen_cfg4()
Definition IOIN.cpp:119
bool pol_stop_r()
Definition SW_MODE.cpp:36
bool pos_edge()
Definition ENCMODE.cpp:42
bool clr_cont()
Definition ENCMODE.cpp:40
bool enca_dcin_cfg5()
Definition IOIN.cpp:120
bool sg_stop()
Definition SW_MODE.cpp:43
bool swcomp_in()
Definition IOIN.cpp:124
bool latch_l_active()
Definition SW_MODE.cpp:38
bool swap_lr()
Definition SW_MODE.cpp:37
bool event_stop_l()
Definition RAMP_STAT.cpp:19
uint16_t SLAVECONF()
Definition SLAVECONF.cpp:44
INIT_REGISTER(SLAVECONF)
bool event_pos_reached()
Definition RAMP_STAT.cpp:22
bool enc_n_dco()
Definition IOIN.cpp:122
bool latch_x_act()
Definition ENCMODE.cpp:45
bool t_zerowait_active()
Definition RAMP_STAT.cpp:26
bool sd_mode()
Definition IOIN.cpp:123
bool ignore_ab()
Definition ENCMODE.cpp:39
bool status_stop_l()
Definition RAMP_STAT.cpp:15
bool status_stop_r()
Definition RAMP_STAT.cpp:16
uint32_t SW_MODE()
Definition SW_MODE.cpp:13
void diag1_poscomp_pushpull(bool B)
uint16_t rms_current()
#define OUTPUT
Definition rpi_bcm2835.h:11
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address