Please describe the feature you would like implemented
Provide for conditional inclusion of user source file spindle_curve.h to recalculate rpm to linearise response.
Why do you think this would improve Grbl_ESP32?
Allows user mod without touching a managed source module
Will this feature appear to a lot of users?
Probably.
“text`
diff --git a/GrblEsp32/spindlecontrol.cpp b/GrblEsp32/spindlecontrol.cpp
index 1886983..4b36600 100644
--- a/GrblEsp32/spindlecontrol.cpp
+++ b/GrblEsp32/spindlecontrol.cpp
@@ -111,6 +111,11 @@ uint32t spindlecomputepwmvalue(float rpm)
// Compute intermediate PWM value with linear spindle speed model.
// NOTE: A nonlinear model could be installed here, if required, but keep it VERY light-weight.
sys.spindle_speed = rpm;
+#if defined _hasinclude
+ #if _hasinclude("spindle_curve.h")
+ #include "spindle_curve.h"
+ #endif
+#endif
pwmvalue = floor((rpm-settings.rpmmin)*pwmgradient) + SPINDLEPWMMINVALUE;
}
return(pwm_value);
@@ -169,4 +174,3 @@ void spindlesetenable(bool enable)
#endif
#endif
}
-
Sample user spindle_curve.h (not to be included in managed source).
`text
//optional user customisation of spindle PWM curve
//needs consistent settings.rpmmin and settings.rpmmax
//use block to make vars private
{
// static long spdcuri[]={0,24000,1000000};
// static float spdcurm[]={0,1,0};
// static long spdcurb[]={0,0,24000};
static long spdcuri[]={1000,3360,5760,24000,1000000};
static float spdcurm[]={0,0.1412,0.325,0.8872,0};
static float spdcurb[]={0,1013,382,-2592,24000};
int i;
for(i=0;i
Tested and working.
Owen
评论 (4)
#2 - owenduffy 于 2019-10-11
A little blog article expanding on an implementation: CNC6040 router project – spindle speed linearisation.
#3 - bdring 于 2019-10-11
I'll give this a look next week. I think I would reformat it into a more Grbl like style using #defines and cpp files. I will look at implementing the #define ENABLEPIECEWISELINEAR_SPINDLE as well.
#4 - bdring 于 2019-10-13
#1 - owenduffy 于 2019-10-09
I might explain that the reason the file is named .h is to work around the way Arduino IDE builds stuff.