Spindle control for dummies

Alright, on to the next phase of my MPCNC.

While the machine is working like a champ, I like to be able to control the spindle via gcode as this is how I’m used to controlling the spindle on my other CNC and without it I find myself fumbling to quickly turn it on before it tries to cut on the MPCNC. I am aware of and understand the safety concerns with this…

I saw several posts here on spindle enable, pin 45, fan pin, etc. and thought I’d give it a shot. However, when I enable/un-comment “#define SPINDLE_LASER_ENABLE” and try to compile, I get the error below.

I tried to follow the error, went in to menu_temperature.cpp to see if it was as simple as enabling/disabling something but it’s way over my head so figured I’d come to the pros…

What am I missing?

sketch/src/lcd/menu/menu_temperature.cpp: In function ‘void lcd_spindle_laser_on(bool)’:
sketch/src/lcd/menu/menu_temperature.cpp:318:34: error: ‘set_spindle_direction’ was not declared in this scope
set_spindle_direction(is_M4);
^
In file included from sketch/src/lcd/menu/menu_temperature.cpp:31:0:
sketch/src/lcd/menu/menu_temperature.cpp: In function ‘void menu_spindle_laser()’:
sketch/src/lcd/menu/menu.h:294:56: error: no matching function for call to ‘TMenuItem<MenuItemInfo_int3>::action_edit(const char*, uint8_t*, int, int, void (&)())’
MenuItem##TYPE ::action ## VARIANT(VA_ARGS); </em>
^
sketch/src/lcd/menu/menu.h:330:62: note: in expansion of macro ‘_MENU_ITEM_VARIANT_P’
#define MENU_ITEM_EDIT_CALLBACK(TYPE, LABEL, …) _MENU_ITEM_VARIANT_P(TYPE, edit, false, PSTR(LABEL), PSTR(LABEL), ## VA_ARGS)
^
sketch/src/lcd/menu/menu_temperature.cpp:332:9: note: in expansion of macro ‘MENU_ITEM_EDIT_CALLBACK’
MENU_ITEM_EDIT_CALLBACK(int3, MSG_LASER_POWER, &spindle_laser_power, SPEED_POWER_MIN, SPEED_POWER_MAX, update_spindle_laser_power);
^
sketch/src/lcd/menu/menu.h:294:56: note: candidate is:
MenuItem##TYPE ::action ## VARIANT(VA_ARGS); </em>
^
sketch/src/lcd/menu/menu.h:330:62: note: in expansion of macro ‘_MENU_ITEM_VARIANT_P’
#define MENU_ITEM_EDIT_CALLBACK(TYPE, LABEL, …) _MENU_ITEM_VARIANT_P(TYPE, _edit, false, PSTR(LABEL), PSTR(LABEL), ## VA_ARGS)
^
sketch/src/lcd/menu/menu_temperature.cpp:332:9: note: in expansion of macro ‘MENU_ITEM_EDIT_CALLBACK’
MENU_ITEM_EDIT_CALLBACK(int3, MSG_LASER_POWER, &spindle_laser_power, SPEED_POWER_MIN, SPEED_POWER_MAX, update_spindle_laser_power);
^
Multiple libraries were found for “U8glib.h”
Used: /home/victor/snap/arduino-mhall119/5/Arduino/libraries/U8glib
Not used: /home/victor/snap/arduino-mhall119/5/.arduino15/packages/rambo/hardware/avr/1.0.1/libraries/U8glib
sketch/src/lcd/menu/menu.h:183:17: note: static void TMenuItem<NAME>::action_edit(const char*, TMenuItem<NAME>::type_t*, TMenuItem<NAME>::type_t, TMenuItem<NAME>::type_t, screenFunc_t, bool) [with NAME = MenuItemInfo_int3; TMenuItem<NAME>::type_t = int; screenFunc_t = void ()()]
static void action_edit(PGM_P const pstr, type_t * const ptr, const type_t minValue, const type_t maxValue, const screenFunc_t callback=NULL, const bool live=false) {
^
sketch/src/lcd/menu/menu.h:183:17: note: no known conversion for argument 2 from 'uint8_t {aka unsigned char*}’ to ‘TMenuItem<MenuItemInfo_int3>::type_t* {aka int*}’

sketch/src/lcd/menu/menu.h:298:110: error: cannot convert ‘uint8_t* {aka unsigned char*}’ to ‘MenuItemInfo_int3::type_t* {aka int*}’ for argument ‘5’ to ‘void draw_menu_item_edit_int3(bool, uint8_t, const char*, const char*, MenuItemInfo_int3::type_t*, …)’
draw_menu_item ## VARIANT ## _ ## TYPE(encoderLine == _thisItemNr, _lcdLineNr, PLABEL, ## VA_ARGS); </em>
^
sketch/src/lcd/menu/menu.h:330:62: note: in expansion of macro ‘_MENU_ITEM_VARIANT_P’
#define MENU_ITEM_EDIT_CALLBACK(TYPE, LABEL, …) _MENU_ITEM_VARIANT_P(TYPE, _edit, false, PSTR(LABEL), PSTR(LABEL), ## VA_ARGS)
^
sketch/src/lcd/menu/menu_temperature.cpp:332:9: note: in expansion of macro ‘MENU_ITEM_EDIT_CALLBACK’
MENU_ITEM_EDIT_CALLBACK(int3, MSG_LASER_POWER, &spindle_laser_power, SPEED_POWER_MIN, SPEED_POWER_MAX, update_spindle_laser_power);
^
exit status 1
Error compiling for board RAMBo."

I am not sure, the errors are tough. What I have been taught is start with the first one and try again. They cascade so typically only the first is very valid.

For you that means, ‘set_spindle_direction’, Try un-commenting or defining that. Try to recompile.

I had this same issue when enabling the pin while trying to get the PID project going. I can’t remember off the top of my head how I solved it, but I’m thinking it was a marlin bug that has been fixed in the latest version and I just had to manually correct in my local copy. I’ll try and remember to figure out what I did for sure tonight when I get home.

1 Like

I figured it was associated with the LCD menu so I just disabled it in menu_temperature.cpp and was able to upload - got it to work somewhat, but am having trouble getting 5V out of pin 45.

On a side note, I noticed quite a bit of float on pin 45. Has anyone else noticed this? I plan to use a pull down resistor to keep it off until m3 is issued. Any concerns with a pull down resistor between pin 45 and ground?

Just a warning-- turning off LCD related stuff in that file was what I did as a band-aid as well and it ended up having unintended consequences in the implementation of spindle control through gcode (I think my issue was with the actual speed commands I was sending rather than enable/disable, but just saying be careful if you’re like me and don’t have a ton of background in programming).

For reference, here is the marlin bug fix thread that addresses the issue if you’re curious:

I’m not sure if the full solution has been pushed to the main release yet or not, I haven’t updated in a while.

 

But to answer your other question, yes a 10K pulldown to ground should work just fine. That’s exactly what I and others have used.

1 Like

Because I control the spindle through my gcode, having the menu functional is not that big of a deal, but would be nice…

Now that the electronics are sorted out, I plan to spend some time troubleshooting the code - thanks for the Marlin link.

From a safety perspective, the way I have my electronics setup, if something happens to the Rambo board (e.g., looses power), the spindle stops automatically.

1 Like