grblHAL core  20260318
spindle_control.h
Go to the documentation of this file.
1 /*
2  spindle_control.h - spindle control methods
3 
4  Part of grblHAL
5 
6  Copyright (c) 2017-2026 Terje Io
7  Copyright (c) 2012-2015 Sungeun K. Jeon
8  Copyright (c) 2009-2011 Simen Svale Skogsrud
9 
10  grblHAL is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  grblHAL is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with grblHAL. If not, see <http://www.gnu.org/licenses/>.
22 */
23 
24 #ifndef _SPINDLE_CONTROL_H_
25 #define _SPINDLE_CONTROL_H_
26 
27 #include "pid.h"
28 
29 #define SPINDLE_NONE 0
30 #define SPINDLE_HUANYANG1 1
31 #define SPINDLE_HUANYANG2 2
32 #define SPINDLE_GS20 3
33 #define SPINDLE_YL620A 4
34 #define SPINDLE_MODVFD 5
35 #define SPINDLE_H100 6
36 #define SPINDLE_ONOFF0 7 // typically implemented by driver.c
37 #define SPINDLE_ONOFF0_DIR 8 // typically implemented by driver.c
38 #define SPINDLE_ONOFF1 9
39 #define SPINDLE_ONOFF1_DIR 10
40 #define SPINDLE_PWM0 11 // typically implemented by driver.c
41 #define SPINDLE_PWM0_NODIR 12 // typically implemented by driver.c
42 #define SPINDLE_PWM1 13 // typically implemented by driver.c
43 #define SPINDLE_PWM1_NODIR 14
44 #define SPINDLE_PWM2 15
45 #define SPINDLE_PWM2_NODIR 16
46 #define SPINDLE_PWM0_CLONE 17
47 #define SPINDLE_SOLENOID 18
48 #define SPINDLE_STEPPER 19
49 #define SPINDLE_NOWFOREVER 20
50 #define SPINDLE_MY_SPINDLE 30
51 
52 #define SPINDLE_ALL_VFD ((1<<SPINDLE_HUANYANG1)|(1<<SPINDLE_HUANYANG2)|(1<<SPINDLE_GS20)|(1<<SPINDLE_YL620A)|(1<<SPINDLE_MODVFD)|(1<<SPINDLE_H100)|(1<<SPINDLE_NOWFOREVER))
53 #define SPINDLE_ALL (SPINDLE_ALL_VFD|(1<<SPINDLE_PWM0))
54 
55 typedef int8_t spindle_id_t;
56 typedef int8_t spindle_num_t;
57 
58 // if changed to > 8 bits planner_cond_t needs to be changed too
59 typedef union {
60  uint8_t value;
61  uint8_t mask;
62  struct {
63  uint8_t on :1,
64  ccw :1,
65  pwm :1,
69  at_speed :1,
71  };
73 
75 typedef union {
76  uint16_t value;
77  struct {
78  uint16_t variable :1,
79  direction :1,
80  at_speed :1,
81  laser :1,
83  pid :1,
88  cloned :1,
89  torch :1,
91  };
93 
95 typedef struct {
96  float rpm;
101  bool ccw;
102  uint32_t index_count;
103  uint32_t pulse_count;
104  uint32_t error_count;
108 
109 typedef enum {
115 
116 typedef enum {
124 
125 typedef enum {
129 } spindle_hal_t;
130 
135 typedef enum {
139 
140 struct spindle_ptrs; // members defined below
141 struct spindle_pwm; // members defined below
142 struct spindle_param; // members defined below
143 
148 typedef bool (*spindle_config_ptr)(struct spindle_ptrs *spindle);
149 
155 typedef void (*spindle_set_state_ptr)(struct spindle_ptrs *spindle, spindle_state_t state, float rpm);
156 
157 #ifdef GRBL_ESP32
158 typedef void (*esp32_spindle_off_ptr)(struct spindle_ptrs *spindle);
159 #endif
160 
166 
175 typedef uint_fast16_t (*spindle_get_pwm_ptr)(struct spindle_ptrs *spindle, float rpm);
176 
184 typedef void (*spindle_update_pwm_ptr)(struct spindle_ptrs *spindle, uint_fast16_t pwm);
185 
189 typedef void (*spindle_update_rpm_ptr)(struct spindle_ptrs *spindle, float rpm);
190 
197 typedef spindle_data_t *(*spindle_get_data_ptr)(spindle_data_request_t request);
198 
200 typedef void (*spindle_reset_data_ptr)(void);
201 
207 typedef void (*spindle_pulse_on_ptr)(struct spindle_ptrs *spindle, uint_fast16_t pulse_length);
208 
209 typedef struct {
210  float rpm;
211  float start;
212  float end;
213 } pwm_piece_t;
214 
215 typedef union {
216  uint8_t value;
217  uint8_t mask;
218  struct {
219  uint8_t enable_rpm_controlled :1, // PWM spindle only
220  laser_mode_disable :1, // PWM spindle only
221  pwm_disable :1, // PWM spindle only
223  pwm_ramped :1, // PWM spindle only
224  ignore_delays :1, // PWM spindle only
226  };
228 
229 #if N_SPINDLE == 1
230 #define PWM_SPINDLE_NO_DELAYS
231 #else
232 #define PWM_SPINDLE_NO_DELAYS ",Ignore on/off delays"
233 #endif
234 
235 
236 typedef union {
237  uint8_t value;
238  uint8_t mask;
239  struct {
240  uint8_t allow_axis_control :1,
243  };
245 
246 typedef struct {
249  float rpm_max;
250  float rpm_min;
251  float pwm_freq;
258 
259 typedef struct {
260  uint8_t ref_id;
262  uint16_t ppr;
263  uint16_t on_delay;
264  uint16_t off_delay;
267 
268 typedef struct {
269  uint8_t port_on;
270  uint8_t port_dir;
271  uint8_t port_pwm;
274 
275 typedef union {
276  uint8_t value;
277  struct {
278  uint8_t invert_pwm :1,
280  cloned :1,
286  };
288 
290 typedef struct spindle_pwm {
291  uint32_t f_clock;
293  uint_fast16_t period;
294  uint_fast16_t off_value;
295  uint_fast16_t min_value;
296  uint_fast16_t max_value;
298  uint_fast16_t pwm_overdrive;
300  float rpm_min;
302  int_fast16_t offset;
303  uint_fast16_t n_pieces;
305  void (*set_laser_overdrive)(struct spindle_pwm *pwm_data, float pct);
306  uint_fast16_t (*compute_value)(struct spindle_pwm *pwm_data, float rpm, bool pid_limit);
308 
309 typedef union
310 {
312 } spindle_context_ptr_t __attribute__ ((__transparent_union__));
313 
315 struct spindle_ptrs {
317  uint8_t ref_id;
322  uint_fast16_t pwm_off_value;
323  float rpm_min;
324  float rpm_max;
332 #ifdef GRBL_ESP32
333  esp32_spindle_off_ptr esp32_off;
334 #endif
335  // Optional entry points.
339 };
340 
341 typedef struct spindle_ptrs spindle_ptrs_t;
342 
344 typedef struct {
346  float target_rpm;
347  float delta_rpm;
348  float max_rpm;
349  float tool_offset;
350  uint_fast8_t axis;
352 
354 typedef struct spindle_param {
355  float rpm;
360  struct {
361  uint8_t ramp_up :1,
368 
369 typedef struct {
373 
375 typedef struct {
377  uint8_t ref_id;
379  const char *name;
380  bool enabled;
384 
388 typedef bool (*spindle_enumerate_callback_ptr)(spindle_info_t *spindle, void *data);
389 
390 float spindle_set_override (spindle_ptrs_t *spindle, override_t speed_override);
391 
392 bool spindle_override_disable (spindle_ptrs_t *spindle, bool disable);
393 
394 // Sets spindle running state with direction, enable, and spindle RPM.
395 bool spindle_set_state (spindle_ptrs_t *spindle, spindle_state_t state, float rpm);
396 
397 // Called by g-code parser when setting spindle state and requires a buffer sync.
398 bool spindle_set_state_synced (spindle_ptrs_t *spindle, spindle_state_t state, float rpm, spindle_rpm_mode_t mode);
399 
400 bool spindle_check_state (spindle_ptrs_t *spindle, spindle_state_t state);
401 
402 // Spindle speed calculation and limit handling
403 float spindle_set_rpm (spindle_ptrs_t *spindle, float rpm, override_t speed_override);
404 
405 // Restore spindle running state with direction, enable, spindle RPM and appropriate delay.
406 bool spindle_restore (spindle_ptrs_t *spindle, spindle_state_t state, float rpm, uint16_t on_delay_ms);
407 
408 void spindle_all_off (bool reset);
409 
410 //
411 // The following functions are not called by the core, may be called by driver code.
412 //
413 
414 #define spindle_validate_at_speed(d, r) { d.rpm = r; d.state_programmed.at_speed = !d.at_speed_enabled || (d.rpm >= d.rpm_low_limit && d.rpm <= d.rpm_high_limit); }
415 /*
416 __attribute__((always_inline)) static inline void spindle_validate_at_speed (spindle_data_t *spindle_data, float rpm)
417 {
418  spindle_data->rpm = rpm;
419  spindle_data->state_programmed.at_speed = !spindle_data->at_speed_enabled || (spindle_data->rpm >= spindle_data->rpm_low_limit && spindle_data->rpm <= spindle_data->rpm_high_limit);
420 }
421 */
422 
423 bool spindle_precompute_pwm_values (spindle_ptrs_t *spindle, spindle_pwm_t *pwm_data, spindle_pwm_settings_t *settings, uint32_t clock_hz);
424 
425 spindle_id_t spindle_register (const spindle_ptrs_t *spindle, const char *name);
426 
428 
429 uint8_t spindle_get_count (void);
430 
431 bool spindle_get_id (uint8_t ref_id, spindle_id_t *spindle_id);
432 
433 bool spindle_select (spindle_id_t spindle_id);
434 
435 spindle_cap_t spindle_get_caps (bool active);
436 
437 void spindle_update_caps (spindle_ptrs_t *spindle, spindle_pwm_t *pwm_caps);
438 
439 void spindle_bind_encoder (const spindle_data_ptrs_t *encoder_data);
440 
441 bool spindle_set_at_speed_range (spindle_ptrs_t *spindle, spindle_data_t *spindle_data, float rpm);
442 
444 
445 const char *spindle_get_name (spindle_id_t spindle_id);
446 
448 
450 
452 
453 //
454 
455 bool spindle_is_enabled (spindle_num_t spindle_num);
456 
457 bool spindle_is_on (void);
458 
460 
461 #if N_SPINDLE > 1
462 
463 typedef void (*spindle1_settings_changed_ptr)(spindle1_pwm_settings_t *settings);
464 
465 spindle1_pwm_settings_t *spindle1_settings_add (bool claim_ports);
466 void spindle1_settings_register (spindle_cap_t cap, spindle1_settings_changed_ptr on_changed);
467 
468 #endif
469 
470 #endif // _SPINDLE_CONTROL_H_
#define SPINDLE_NPWM_PIECES
Number of pieces used for spindle RPM linearization, enabled by setting ENABLE_SPINDLE_LINEARIZATION ...
Definition: config.h:116
uint_fast16_t override_t
Definition: grbl.h:262
DCRAM grbl_hal_t hal
Global HAL struct.
Definition: grbllib.c:91
settings_t settings
Definition: settings.c:48
void spindle_bind_encoder(const spindle_data_ptrs_t *encoder_data)
Definition: spindle_control.c:359
void spindle_update_caps(spindle_ptrs_t *spindle, spindle_pwm_t *pwm_caps)
Update the capabilities of a registered PWM spindle. May be used by the driver on spindle initializat...
Definition: spindle_control.c:283
spindle_hal_t
Definition: spindle_control.h:125
@ SpindleHAL_Raw
0 - NOTE: read-only
Definition: spindle_control.h:126
@ SpindleHAL_Active
2
Definition: spindle_control.h:128
@ SpindleHAL_Configured
1
Definition: spindle_control.h:127
float spindle_set_override(spindle_ptrs_t *spindle, override_t speed_override)
Set spindle speed override.
Definition: spindle_control.c:616
bool spindle_is_enabled(spindle_num_t spindle_num)
Check if a spindle is enabled and available or not.
Definition: spindle_control.c:442
bool spindle_restore(spindle_ptrs_t *spindle, spindle_state_t state, float rpm, uint16_t on_delay_ms)
Restore spindle running state with direction, enable, spindle RPM and appropriate delay.
Definition: spindle_control.c:844
spindle_type_t
Definition: spindle_control.h:116
@ SpindleType_VFD
2
Definition: spindle_control.h:119
@ SpindleType_PWM
0
Definition: spindle_control.h:117
@ SpindleType_Basic
1 - on/off + optional direction
Definition: spindle_control.h:118
@ SpindleType_Null
5
Definition: spindle_control.h:122
@ SpindleType_Stepper
4
Definition: spindle_control.h:121
@ SpindleType_Solenoid
3
Definition: spindle_control.h:120
bool spindle_get_id(uint8_t ref_id, spindle_id_t *spindle_id)
Definition: spindle_control.c:321
const char * spindle_get_name(spindle_id_t spindle_id)
Get the registered name of a spindle.
Definition: spindle_control.c:273
bool spindle_set_at_speed_range(spindle_ptrs_t *spindle, spindle_data_t *spindle_data, float rpm)
Definition: spindle_control.c:388
bool spindle_enumerate_spindles(spindle_enumerate_callback_ptr callback, void *data)
Enumerate registered spindles by calling a callback function for each of them.
Definition: spindle_control.c:406
bool spindle_select(spindle_id_t spindle_id)
Enables a spindle and sets it as default spindle (spindle number 0).
Definition: spindle_control.c:203
void spindle_all_off(bool reset)
Turn off all enabled spindles.
Definition: spindle_control.c:878
bool(* spindle_config_ptr)(struct spindle_ptrs *spindle)
Pointer to function for configuring a spindle.
Definition: spindle_control.h:148
spindle_state_t(* spindle_get_state_ptr)(struct spindle_ptrs *spindle)
Pointer to function for getting the spindle state.
Definition: spindle_control.h:165
uint_fast16_t(* spindle_get_pwm_ptr)(struct spindle_ptrs *spindle, float rpm)
Pointer to function for converting a RPM value to a PWM value.
Definition: spindle_control.h:175
spindle_num_t spindle_enable(spindle_id_t spindle_id)
Enable a spindle and make it available for use by gcode.
Definition: spindle_control.c:186
spindle_id_t spindle_get_default(void)
Get the spindle id of the default spindle (spindle number 0).
Definition: spindle_control.c:247
uint8_t spindle_get_count(void)
Get number of registered spindles.
Definition: spindle_control.c:313
bool spindle_check_state(spindle_ptrs_t *spindle, spindle_state_t state)
Checks actual spindle state against given state.
Definition: spindle_control.c:663
int8_t spindle_id_t
Definition: spindle_control.h:55
void(* spindle_update_pwm_ptr)(struct spindle_ptrs *spindle, uint_fast16_t pwm)
Pointer to function for updating spindle speed on the fly.
Definition: spindle_control.h:184
void(* spindle_reset_data_ptr)(void)
Pointer to function for resetting spindle data.
Definition: spindle_control.h:200
bool spindle_is_on(void)
Check if any of the enabled spindles is running.
Definition: spindle_control.c:905
bool(* spindle_enumerate_callback_ptr)(spindle_info_t *spindle, void *data)
Pointer to callback function called by spindle_enumerate_spindles().
Definition: spindle_control.h:388
spindle_id_t spindle_register(const spindle_ptrs_t *spindle, const char *name)
Register a spindle with the core.
Definition: spindle_control.c:151
bool spindle_set_state(spindle_ptrs_t *spindle, spindle_state_t state, float rpm)
Definition: spindle_control.c:758
spindle_rpm_mode_t
Definition: spindle_control.h:135
@ SpindleSpeedMode_RPM
0 - G97 - Default, must be zero
Definition: spindle_control.h:136
@ SpindleSpeedMode_CSS
1 - G96
Definition: spindle_control.h:137
spindle_cap_t spindle_get_caps(bool active)
Get the merged spindle capabilities of all registered spindles.
Definition: spindle_control.c:256
struct spindle_param spindle_param_t
Structure used for holding the current state of an enabled spindle.
void(* spindle_set_state_ptr)(struct spindle_ptrs *spindle, spindle_state_t state, float rpm)
Pointer to function for setting the spindle state.
Definition: spindle_control.h:155
spindle_data_request_t
Definition: spindle_control.h:109
@ SpindleData_RPM
1
Definition: spindle_control.h:111
@ SpindleData_AngularPosition
2
Definition: spindle_control.h:112
@ SpindleData_AtSpeed
3
Definition: spindle_control.h:113
@ SpindleData_Counters
0
Definition: spindle_control.h:110
bool spindle_set_state_synced(spindle_ptrs_t *spindle, spindle_state_t state, float rpm, spindle_rpm_mode_t mode)
G-code parser entry-point for setting spindle state. Forces a planner buffer sync and bails if an abo...
Definition: spindle_control.c:823
spindle_ptrs_t * spindle_get_hal(spindle_id_t spindle_id, spindle_hal_t hal)
Get the handlers (function pointers) etc. associated with the spindle.
Definition: spindle_control.c:224
void(* spindle_pulse_on_ptr)(struct spindle_ptrs *spindle, uint_fast16_t pulse_length)
Pointer to function for outputting a spindle on pulse. Used for Pulses Per Inch (PPI) laser mode.
Definition: spindle_control.h:207
bool spindle_precompute_pwm_values(spindle_ptrs_t *spindle, spindle_pwm_t *pwm_data, spindle_pwm_settings_t *settings, uint32_t clock_hz)
Precompute PWM values for faster conversion.
Definition: spindle_control.c:1006
bool spindle_override_disable(spindle_ptrs_t *spindle, bool disable)
Definition: spindle_control.c:650
spindle_data_t *(* spindle_get_data_ptr)(spindle_data_request_t request)
Pointer to function for getting spindle data.
Definition: spindle_control.h:197
spindle_ptrs_t * spindle_get(spindle_num_t spindle_num)
Get the handlers (function pointers) etc. associated with an enabled spindle.
Definition: spindle_control.c:456
int8_t spindle_num_t
Definition: spindle_control.h:56
spindle_id_t spindle_add_null(void)
Register a null spindle that has no connection to the outside world. This is done automatically on st...
Definition: spindle_control.c:513
struct spindle_pwm spindle_pwm_t
Precalculated values that may be set/used by HAL driver to speed up RPM to PWM conversions if variabl...
void(* spindle_update_rpm_ptr)(struct spindle_ptrs *spindle, float rpm)
Pointer to function for updating spindle RPM.
Definition: spindle_control.h:189
float spindle_set_rpm(spindle_ptrs_t *spindle, float rpm, override_t speed_override)
Calculate and set programmed RPM according to override and max/min limits.
Definition: spindle_control.c:862
Definition: spindle_control.h:209
float rpm
Definition: spindle_control.h:210
float end
Definition: spindle_control.h:212
float start
Definition: spindle_control.h:211
Definition: spindle_control.h:268
uint8_t port_on
Definition: spindle_control.h:269
uint8_t port_pwm
Definition: spindle_control.h:271
uint8_t port_dir
Definition: spindle_control.h:270
spindle_pwm_settings_t cfg
Definition: spindle_control.h:272
Data used for Constant Surface Speed (CSS) mode calculations.
Definition: spindle_control.h:344
float target_rpm
Target RPM at end of movement.
Definition: spindle_control.h:346
float surface_speed
Surface speed in millimeters/min.
Definition: spindle_control.h:345
float tool_offset
Tool offset.
Definition: spindle_control.h:349
uint_fast8_t axis
Linear (tool) axis.
Definition: spindle_control.h:350
float max_rpm
Maximum spindle RPM.
Definition: spindle_control.h:348
float delta_rpm
Delta between start and target RPM.
Definition: spindle_control.h:347
Definition: spindle_control.h:369
spindle_get_data_ptr get
Optional handler for getting spindle data. Required for spindle sync.
Definition: spindle_control.h:370
spindle_reset_data_ptr reset
Optional handler for resetting spindle data. Required for spindle sync.
Definition: spindle_control.h:371
Used when HAL driver supports spindle synchronization.
Definition: spindle_control.h:95
float rpm_programmed
Definition: spindle_control.h:100
float angular_position
Number of revolutions since last reset.
Definition: spindle_control.h:99
float rpm_high_limit
Definition: spindle_control.h:98
float rpm
Definition: spindle_control.h:96
spindle_state_t state_programmed
Definition: spindle_control.h:106
bool at_speed_enabled
Definition: spindle_control.h:105
uint32_t index_count
Definition: spindle_control.h:102
uint32_t pulse_count
Definition: spindle_control.h:103
bool ccw
Definition: spindle_control.h:101
float rpm_low_limit
Definition: spindle_control.h:97
uint32_t error_count
Definition: spindle_control.h:104
Structure holding data passed to the callback function called by spindle_enumerate_spindles().
Definition: spindle_control.h:375
uint8_t ref_id
Definition: spindle_control.h:377
bool enabled
Definition: spindle_control.h:380
const char * name
Definition: spindle_control.h:379
spindle_num_t num
Definition: spindle_control.h:378
const spindle_ptrs_t * hal
Definition: spindle_control.h:382
spindle_id_t id
Definition: spindle_control.h:376
bool is_current
Definition: spindle_control.h:381
Structure used for holding the current state of an enabled spindle.
Definition: spindle_control.h:354
uint8_t ramp_down
Definition: spindle_control.h:362
float rpm_overridden
Definition: spindle_control.h:356
float rpm
Definition: spindle_control.h:355
spindle_state_t state
Definition: spindle_control.h:357
struct spindle_param::@133 option
spindle_ptrs_t * hal
Definition: spindle_control.h:366
uint8_t ignore_delays
Definition: spindle_control.h:363
override_t override_pct
Spindle RPM override value in percent.
Definition: spindle_control.h:358
uint8_t ramp_up
Definition: spindle_control.h:361
uint8_t override_disable
Definition: spindle_control.h:364
spindle_css_data_t css
Data used for Constant Surface Speed Mode (CSS) calculations, NULL if not in CSS mode.
Definition: spindle_control.h:359
Handlers and data for spindle support.
Definition: spindle_control.h:315
spindle_context_ptr_t context
Optional pointer to spindle specific context.
Definition: spindle_control.h:321
spindle_set_state_ptr set_state
Handler for setting spindle state.
Definition: spindle_control.h:327
spindle_update_rpm_ptr update_rpm
Handler for updating spindle RPM.
Definition: spindle_control.h:331
spindle_reset_data_ptr reset_data
Optional handler for resetting spindle data. Required for spindle sync, copied from hal....
Definition: spindle_control.h:338
float rpm_max
Maximum spindle RPM.
Definition: spindle_control.h:324
spindle_config_ptr config
Optional handler for configuring the spindle.
Definition: spindle_control.h:326
spindle_get_data_ptr get_data
Optional handler for getting spindle data. Required for spindle sync, copied from hal....
Definition: spindle_control.h:337
uint_fast16_t pwm_off_value
Value for switching PWM signal off.
Definition: spindle_control.h:322
spindle_get_pwm_ptr get_pwm
Handler for calculating spindle PWM value from RPM.
Definition: spindle_control.h:329
uint8_t ref_id
Spindle id, assigned on spindle registration.
Definition: spindle_control.h:317
spindle_pulse_on_ptr pulse_on
Optional handler for Pulses Per Inch (PPI) mode. Required for the laser PPI plugin.
Definition: spindle_control.h:336
spindle_update_pwm_ptr update_pwm
Handler for updating spindle PWM output.
Definition: spindle_control.h:330
float at_speed_tolerance
Tolerance in percent of programmed speed.
Definition: spindle_control.h:325
spindle_id_t id
Spindle id, assigned on spindle registration.
Definition: spindle_control.h:316
float rpm_min
Minimum spindle RPM.
Definition: spindle_control.h:323
spindle_get_state_ptr get_state
Handler for getting spindle state.
Definition: spindle_control.h:328
spindle_cap_t cap
Spindle capabilities.
Definition: spindle_control.h:320
struct spindle_param * param
Pointer to current spindle parameters, assigned when spindle is enabled.
Definition: spindle_control.h:318
spindle_type_t type
Spindle type.
Definition: spindle_control.h:319
Definition: spindle_control.h:246
float pwm_freq
Definition: spindle_control.h:251
spindle_state_t invert
Definition: spindle_control.h:247
float pwm_off_value
Definition: spindle_control.h:252
float rpm_max
Definition: spindle_control.h:249
spindle_settings_flags_t flags
Definition: spindle_control.h:248
float pwm_max_value
Definition: spindle_control.h:254
float pwm_min_value
Definition: spindle_control.h:253
float at_speed_tolerance
Tolerance in percent of programmed speed.
Definition: spindle_control.h:255
float rpm_min
Definition: spindle_control.h:250
Precalculated values that may be set/used by HAL driver to speed up RPM to PWM conversions if variabl...
Definition: spindle_control.h:290
uint_fast16_t period
Definition: spindle_control.h:293
uint_fast16_t off_value
NOTE: this value holds the inverted version if software PWM inversion is enabled by the driver.
Definition: spindle_control.h:294
uint32_t f_clock
Definition: spindle_control.h:291
void(* set_laser_overdrive)(struct spindle_pwm *pwm_data, float pct)
Definition: spindle_control.h:305
spindle_pwm_settings_t * settings
Definition: spindle_control.h:292
pwm_piece_t piece[SPINDLE_NPWM_PIECES]
Definition: spindle_control.h:304
uint_fast16_t min_value
Definition: spindle_control.h:295
int_fast16_t offset
Definition: spindle_control.h:302
uint_fast16_t pwm_overdrive
Adjusted PWM value to use when turning off enable signal, used when spindle enable is RPM controlled.
Definition: spindle_control.h:298
uint_fast16_t(* compute_value)(struct spindle_pwm *pwm_data, float rpm, bool pid_limit)
Definition: spindle_control.h:306
float off_overdrive_pct
Percent of programmed value to add when turning off enable signal, used when spindle enable is RPM co...
Definition: spindle_control.h:297
uint_fast16_t n_pieces
Definition: spindle_control.h:303
float rpm_min
Minimum spindle RPM.
Definition: spindle_control.h:300
uint_fast16_t max_value
Definition: spindle_control.h:296
float pwm_gradient
Definition: spindle_control.h:301
spindle_pwm_flags_t flags
Definition: spindle_control.h:299
Definition: spindle_control.h:259
uint16_t ppr
Spindle encoder pulses per revolution (PPR).
Definition: spindle_control.h:262
uint8_t ref_id
Definition: spindle_control.h:260
uint8_t encoder_spindle
Definition: spindle_control.h:261
float at_speed_tolerance
Tolerance in percent of programmed speed.
Definition: spindle_control.h:265
uint16_t off_delay
Definition: spindle_control.h:264
uint16_t on_delay
Definition: spindle_control.h:263
Bitmap flags for spindle capabilities.
Definition: spindle_control.h:75
uint16_t at_speed
Spindle at speed feedback is supported.
Definition: spindle_control.h:80
uint16_t unassigned
Definition: spindle_control.h:90
uint16_t laser
Spindle can control a laser.
Definition: spindle_control.h:81
uint16_t pwm_invert
Spindle PWM output can be inverted.
Definition: spindle_control.h:82
uint16_t direction
Spindle direction (M4) is supported.
Definition: spindle_control.h:79
uint16_t cmd_controlled
Command controlled, e.g. over ModBus.
Definition: spindle_control.h:87
uint16_t value
All bitmap flags.
Definition: spindle_control.h:76
uint16_t pid
Definition: spindle_control.h:83
uint16_t gpio_controlled
On/off and direction is controlled by GPIO.
Definition: spindle_control.h:86
uint16_t cloned
Spindle is cloned.
Definition: spindle_control.h:88
uint16_t variable
Variable spindle speed is supported.
Definition: spindle_control.h:78
uint16_t torch
Spindle is plasma torch.
Definition: spindle_control.h:89
uint16_t rpm_range_locked
Spindle RPM range (min, max) not inherited from settings.
Definition: spindle_control.h:85
uint16_t pwm_linearization
Definition: spindle_control.h:84
Definition: spindle_control.h:310
spindle_pwm_t * pwm
Definition: spindle_control.h:311
Definition: spindle_control.h:275
uint8_t cloned
Definition: spindle_control.h:280
uint8_t ramp_pwm
Definition: spindle_control.h:285
uint8_t value
Definition: spindle_control.h:276
uint8_t rpm_controlled
Definition: spindle_control.h:281
uint8_t enable_out
Definition: spindle_control.h:284
uint8_t laser_mode_disable
Definition: spindle_control.h:282
uint8_t laser_off_overdrive
Definition: spindle_control.h:283
uint8_t invert_pwm
NOTE: set (by driver) when inversion is done in code.
Definition: spindle_control.h:278
uint8_t always_on
Definition: spindle_control.h:279
Definition: spindle_control.h:215
uint8_t g92offset
Definition: spindle_control.h:222
uint8_t unassigned
Definition: spindle_control.h:225
uint8_t pwm_ramped
Definition: spindle_control.h:223
uint8_t pwm_disable
Definition: spindle_control.h:221
uint8_t value
Definition: spindle_control.h:216
uint8_t enable_rpm_controlled
Definition: spindle_control.h:219
uint8_t mask
Definition: spindle_control.h:217
uint8_t ignore_delays
Definition: spindle_control.h:224
uint8_t laser_mode_disable
Definition: spindle_control.h:220
Definition: spindle_control.h:59
uint8_t value
Definition: spindle_control.h:60
uint8_t on
Definition: spindle_control.h:63
uint8_t at_speed
Spindle is at speed.
Definition: spindle_control.h:69
uint8_t synchronized
Definition: spindle_control.h:70
uint8_t mask
Definition: spindle_control.h:61
uint8_t pwm
NOTE: only used for PWM inversion setting.
Definition: spindle_control.h:65
uint8_t reserved
Definition: spindle_control.h:66
uint8_t override_disable
Definition: spindle_control.h:67
uint8_t encoder_error
Definition: spindle_control.h:68
uint8_t ccw
Definition: spindle_control.h:64
Definition: spindle_control.h:236
uint8_t unassigned
Definition: spindle_control.h:242
uint8_t value
Definition: spindle_control.h:237
uint8_t mask
Definition: spindle_control.h:238
uint8_t sync_position
Definition: spindle_control.h:241
uint8_t allow_axis_control
Definition: spindle_control.h:240