diff --git a/Grbl_Esp32/src/Spindles/TecoL510.cpp b/Grbl_Esp32/src/Spindles/TecoL510.cpp index 156fcb3d..1c3e65b6 100644 --- a/Grbl_Esp32/src/Spindles/TecoL510.cpp +++ b/Grbl_Esp32/src/Spindles/TecoL510.cpp @@ -69,19 +69,7 @@ namespace Spindles { data.tx_length = 6; data.rx_length = 6; - // We have to know the max RPM before we can set the current RPM: - auto max_rpm = this->_max_rpm; - auto max_freq = this->_max_freq; - - // Assuming max frequncy is 400Hz - // Speed is in [0..40,000] - uint16_t freq = (uint16_t(rpm) * max_freq) / uint32_t(max_rpm); - if (freq < 0) { - freq = 0; - } - if (freq > max_freq) { - freq = max_freq; - } + uint16_t freq = rpm_to_frequency(rpm); data.msg[1] = 0x06; // WRITE data.msg[2] = 0x25; // Command ID 0x2502 @@ -97,6 +85,12 @@ namespace Spindles { auto max_rpm = this->_max_rpm; auto max_freq = this->_max_freq; uint16_t freq = (uint32_t(rpm) * max_freq) / uint32_t(max_rpm); + if (freq < 0) { + freq = 0; + } + if (freq > max_freq) { + freq = max_freq; + } return freq; } diff --git a/Grbl_Esp32/src/Spindles/TecoL510_README.md b/Grbl_Esp32/src/Spindles/TecoL510_README.md index 87becce9..1fdafb87 100644 --- a/Grbl_Esp32/src/Spindles/TecoL510_README.md +++ b/Grbl_Esp32/src/Spindles/TecoL510_README.md @@ -21,7 +21,9 @@ this was tested with pin 16 RX and 26 TX mapped in the machine config file. Pin #define VFD_RS485_TXD_PIN GPIO_NUM_26 #define VFD_RS485_RTS_PIN GPIO_NUM_4 #define VFD_RS485_RXD_PIN GPIO_NUM_16 - +// Not sure why this isn't a setting +#define DEFAULT_SPINDLE_RPM_MAX 24000.0 // rpm +#define DEFAULT_SPINDLE_RPM_MIN 6000.0 // rpm ``` not sure how to detect and parse error messages