Any thoughts on this challenge?

Any thoughts on this challenge? – I’m trying to create a group of custom M codes which get routed to a PLC using a Modbus protocol. I’m thinking to use NPM’s NodeJS modbus to websockets bridge in a chilipeppr widget.

It’s a neat idea, but I will say, having done some vaguely similar stuff with linuxcnc, that as soon as you start writing custom g-code interpreters or go outside the standard codebase, you have isolated yourself into only you being able to use only your hardware.

What you could do instead is use the chilipeppr_pause command in comments in your Gcode. That will pause execution of the code at that spot and send a pubsub signal so you can run Javascript code.

It is described in the pubsub dialog with the Gcode widget in CP. Here’s the text from that dialog.

It is getting quite common to connect to multiple serial devices from inside CP and then have your main CNC controller the default serial port (in green) and the secondary controllers to be connected as well but have code sent to them direct from other widgets. See the Texterator workspace for a massive example of this in action. http://chilipeppr.com/texterator

/com-chilipeppr-widget-gcode/onChiliPepprPause

This event is published during the play operation when the chilipeppr_pause string is found inside the Gcode. You can place a chilipeppr_pause string anywhere in the Gcode inside a comment and it will tell ChiliPeppr to pause sending when it hits that line.

The pause acts much like the M6 tool change pause but it is a pause just for ChiliPeppr to interpret and not the CNC controller. This technique was implemented for synchronizing a secondary microcontroller that could trigger an out-of-band event like a laser solderer, or a solder paste dispenser, or some other control that had to trigger at a specific Gcode line. This specific event is not very helpful to subscribe to because it does not have as much meaning as onChiliPepprPauseOnComplete or onChiliPepprPauseOnExecute. Those two events are triggered when the CNC controller actually gets to the specifically paused line and that is where you would synchronize from.

The onChiliPepprPauseOnComplete is triggered by all CNC controllers but is not a very accurate event as most controllers have a planner buffer which means this line is not really what is being executed but will be executed in the very near future at an unknown time. The onChiliPepprPauseOnExecute is a highly accurate event currently only available from TinyG that tells you the CNC controller is exactly executing this line at this moment.

A sample macro is available that shows how to use the onChiliPepprPause events.

Thanks for the direction! I’ll let you know how it works out.

I’d love to hear about your progress on this as well.

Talking PLC would open this a whole lot of industrial machines and help move this out of the hobby market. Please keep us posted on your progress.

OMG - I totally agree with you on PLC expansion. Is a MUST, Curently I am researcing 3DPrinting with TinyG2 and PLC control is next on my list anything I can do to support this i am up for it.