Machsupport Forum

Mach Discussion => Mach4 General Discussion => Mach4 Plugins => Topic started by: wrecks on August 27, 2020, 08:12:15 PM

Title: How can I reset Mach4 Modbus through lua?
Post by: wrecks on August 27, 2020, 08:12:15 PM
I am developing tool changer using an arduino, and have set up communications to Mach4 using the Modbus plugin. This part was way easier to set up than I expected.

I am adding a tool changer tab to the mach4 operator screen. This will show the status of the tool changer arduino, give the capability to do manual control operations, show arduino I/O statuses, etc.

I want to add button to this screen to re-initialize the modbus connection in case it has an error, such as happens if the Ethernet cable is unplugged or the arduino power is cycled. I have discovered that opening and closing the modbus configuration screen will reset the modbus and clear the error. I want to make a button that will perform the same function.

Any advice?
Title: Re: How can I reset Mach4 Modbus through lua?
Post by: jbuehn on August 28, 2020, 01:51:44 PM
I believe you can write "RESTART" to mbcntl/command register.
Title: Re: How can I reset Mach4 Modbus through lua?
Post by: wrecks on August 28, 2020, 06:26:02 PM
Ha! Thanks for that info. I didn't know about mbcntl/command.

I couldn't get "RESTART" to work, but sending "STOP" and then "START" once the status changes to stopped does what I want.

You made my day. Thanks again.