[Grbl_Esp32 Issue#252] Error in spindle_control.cpp, spindle_set_speed()

未分类 bolang 4个月前 (10-14) 36次浏览

Issue #252 | 状态: 已关闭 | 作者: owenduffy | 创建时间: 2019-10-15

标签: bug


Please answer the following questions.

What version of the firmware are you using?
b7ee4265515757c82a732c4b19e3a976ffc39a56

Is the problem repeatable?
Yes

Under what conditions does the bug occur?
Using INVERTSPINDLEPWM, there is an intercept error in the characteristic of measured dutycycle vs requested dutycycle.
!Clip 058
The intercept should be zero.

The following changes fixes the problem, results in intercept of 2e-5 which is good.

text
@@ -108,11 +108,12 @@ void spindlesetspeed(uint32t pwmvalue)
#else
if (pwm_value == 0) {
grblanalogWrite(SPINDLEPWMCHANNEL, (1<PWMBITPRECISION));
}
else {
- grblanalogWrite(SPINDLEPWMCHANNEL, (1<PWMBITPRECISION) - pwm_value - 1);
+//od grblanalogWrite(SPINDLEPWMCHANNEL, (1<PWMBITPRECISION) - pwm_value - 1);
+ grblanalogWrite(SPINDLEPWMCHANNEL, (1<PWMBITPRECISION) - pwm_value);
}
#endif

#endif

In fact, the other branch of the if statement is redundant, and the code could be simplified.


评论 (5)

#1 – bdring 于 2019-10-15

Is this correct? I have trouble reading your code formatting.

C++
void spindlesetspeed(uint32t pwmvalue)
{
#ifndef SPINDLEPWMPIN
return;
#else
#ifndef SPINDLEENABLEOFFWITHZERO_SPEED
spindlesetenable(true);
#else
spindlesetenable(pwm_value != 0);
#endif

#ifndef INVERTSPINDLEPWM
grblanalogWrite(SPINDLEPWMCHANNEL, pwmvalue);
#else
if (pwm_value == 0) {
grblanalogWrite(SPINDLEPWMCHANNEL, (1<PWMBITPRECISION));
}
else {
grblanalogWrite(SPINDLEPWMCHANNEL, (1<PWMBITPRECISION) - pwm_value);
}
#endif

#endif

}


#2 – owenduffy 于 2019-10-15

YEs, but it simplifies to:

C++
void spindlesetspeed(uint32t pwmvalue)
{
#ifndef SPINDLEPWMPIN
return;
#else
#ifndef SPINDLEENABLEOFFWITHZERO_SPEED
spindlesetenable(true);
#else
spindlesetenable(pwm_value != 0);
#endif

#ifndef INVERTSPINDLEPWM
grblanalogWrite(SPINDLEPWMCHANNEL, pwmvalue);
#else
grblanalogWrite(SPINDLEPWMCHANNEL, (1<PWMBITPRECISION) - pwm_value);
#endif

#endif

}

Ok?


#3 – bdring 于 2019-10-15

OK


#4 – owenduffy 于 2019-10-15

Apologies for not finding that in testing… I attributed the small error to the piecewise approximation. Fixing this improves cal at the low end.

Thanks again.


#5 – bdring 于 2019-10-15

merged to master


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

喜欢 (0)