[Grbl_Esp32 Issue#630] $Spindle/PWM/Invert Not work correctly

未分类 bolang 5个月前 (10-14) 50次浏览

Issue #630 | 状态: 进行中 | 作者: semos2k | 创建时间: 2020-10-06

标签: bug


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)

#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


原始Issue: https://github.com/bdring/Grbl_Esp32/issues/630

喜欢 (0)