Hi, i am tested the latest version off the main and the option “$Spindle/PWM/Invert=On” not work correctly, when power on the esp32 the value is no set because the next fragment off code:
“C++
void PWM::setoutput(uint32t duty) {
if (outputpin == UNDEFINED_PIN) {
return;
}
// to prevent excessive calls to ledcWrite, make sure duty hass changed
if (duty == currentpwm_duty) {
return;
}
currentpwm_duty = duty;
if (invertpwm) {
duty = (1 << pwmprecision) - duty;
}
//grblmsgsendf(CLIENTSERIAL, MsgLevel::Info, "setoutput(%d)", duty);
ledcWrite(pwmchan_num, duty);
}
``
The code problem is in:
C++“
// to prevent excessive calls to ledcWrite, make sure duty hass changed
if (duty == currentpwm_duty) {
return;
}
only when I run M3 S1000 and M3 S0 does it work, I have commented the code and it works, but for a small instant of time it sets the wrong value.
What version of the firmware are you using? last (main) Devt (#628)
Is the problem repeatable? yes
#1 – AlphaCircuit 于 2021-02-11
Hi Semos2k, did you make sure you updated you pinout the style changed that allocates the PWM output, have a look at my code below SPINDLEPWMPIN is now called SPINDLEOUTPUTPIN.
#define SPINDLE_TYPE SpindleType::PWM
#define SPINDLEENABLEPIN GPIONUM22
#define SPINDLEDIRPIN GPIONUM21
// #define SPINDLEPWMPIN GPIONUM17 previous style
#define SPINDLEOUTPUTPIN GPIONUM17 // new style