DIY Emergency Stop Button

Replicating the e-stop functionality from an Arduino via an MCP2515 CAN interface module is cheap and easy since the e-stop is the simplest function.

You can see the simplicity of the module code here, where the core function is the main module loop here: Snapmaker2-Modules/stop_module.cpp at 322043f97a68e69d04e486b89cda2f722f103bc1 · Snapmaker/Snapmaker2-Modules · GitHub

Pseudocode: if (switch.checkStatus() && isConnected()) then ReportStatus(20) //FUNC_REPORT_STOP_SWITCH is function 20

And ReportStatus is just a basic can Send function:
ReportStatus: Snapmaker2-Modules/switch.cpp at 322043f97a68e69d04e486b89cda2f722f103bc1 · Snapmaker/Snapmaker2-Modules · GitHub
PushSendStandardData: Snapmaker2-Modules/can_bus.cpp at 322043f97a68e69d04e486b89cda2f722f103bc1 · Snapmaker/Snapmaker2-Modules · GitHub

There is also some startup code in route.cpp that inits the function list and in registry.cpp that reports the function ids (line 149) when requested (line 108).

There’s only a couple request function IDs that need to be listened for, and only 1 function response. And almost all of the code can be copy/pasted out of there (maybe not, but at least it’s easy to see how it functions).

I have a couple MCP2515’s and have been meaning to implement something like this, probably in an ESP8266 so I can have access to it via wifi. Haven’t gotten around, still just a bunch of parts on the workbench. Lately I’ve been using tasmota to integrate with my home automation system via MQTT - I could add the snapmaker as an MQTT module to home automation and keep a central eye on it…hmmm.

1 Like