Machsupport Forum
Third party software and hardware support forums. => Modbus => Topic started by: BenBouwer on January 31, 2018, 01:09:33 AM
-
Modbus Arduino slave for Mach3 by Ben Bouwer
The purpose of this scetch is to link the Arduino digital and analog pins to Mach3 using the Modbus Protocol.
To keep things simple I used a register for each pin in the arduino.
Each register can be a Digital input, Digital output, Analog input or PWM output register
Choose what you want each Arduino Pin to be (Digital input, Digital output, Analog input, PWM output or MPG input):
See attached Arduino Scetch
Unzip it
Place it in a folder within the Arduino folder the same name as the file
Arduino/Mach3_Modbus_Slave_Version_6_Point_5/Mach3_Modbus_Slave_Version_6_Point_5.ino
-
Nice to see more Arduino stuff. If I get a chance I will try this out on my lathe since I want to add 2 pots.
-
Find attached pictures of:
Brain Setup
Brain View Register 18
Brain View Register 19
ModBus Configuration
Brain View Register 20 and 22 will be similar to Brain View Register 18
Brain View Register 21 and 23 will be similar to Brain View Register 19
You must write your own Brains for the rest of the Registers
-
Please be carefull.
The program was not tested on a real machine!
Modbus must not be used for critical inputs or outputs.
See Mach3 manual.
-
I will try this,thank to Ben
But i do not see ModbusRtu.h include
-
You must downdoad it form https://github.com/smarmengol/Modbus-Master-Slave-for-Arduino
Download it as a Zip file.
Install it using the menus in the Arduino IDE: Sketch, Include Library, Add.ZIP Library
Also download the other Libraries from the Arduino Site or from Git Hub and install them.
#include <ModbusRtu.h> // Ensure that the ModbusRtu library is included (under libraries)
#include <Wire.h> // Ensure that the Wire library is included (under libraries)
#include <LiquidCrystal_I2C.h> // Ensure that the LiquidCrystal_I2C library is included (under libraries)
#include <Encoder.h> // Ensure that the Encoder library is included (under libraries)
-
Hi Ben,the project is very interesting, which arduino is better?
Do not know well brain mach3, have file brn of the project?
-
I do not have the Brain file for the project. You can do it yourself using the info above.
-
Hi, I'm using this Sketch to interface it to Mach4, it works but I need to configure some Pin as Input for "Read coils (0x01)" or "Read input Discreats (0x02)" but they don't work. What changes should I make?
I apologize for my English but I am Italian. Thank you
-
Hi
I have no way of helping you.
I am not a profesional programer.
I hope you find a way to make it work fully for you.
Ben