Hello Guest it is October 06, 2024, 09:52:46 PM

Author Topic: Arduino Uno that works with Modbus  (Read 20676 times)

0 Members and 1 Guest are viewing this topic.

Arduino Uno that works with Modbus
« 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

Re: Arduino Uno that works with Modbus
« Reply #1 on: January 31, 2018, 07:14:06 AM »
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.
We never have the time or money to do it right the first time, but we somehow manage to do it twice and then spend the money to get it right.
Re: Arduino Uno that works with Modbus
« Reply #2 on: February 01, 2018, 12:41:10 AM »
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
Re: Arduino Uno that works with Modbus
« Reply #3 on: February 01, 2018, 12:46:58 AM »
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.
Re: Arduino Uno that works with Modbus
« Reply #4 on: February 10, 2018, 05:13:35 AM »
 I will try this,thank to Ben
But i do not see ModbusRtu.h include
« Last Edit: February 10, 2018, 05:20:06 AM by duongfx »
Re: Arduino Uno that works with Modbus
« Reply #5 on: February 12, 2018, 06:58:14 AM »
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)
Re: Arduino Uno that works with Modbus
« Reply #6 on: March 21, 2018, 04:36:26 AM »
Hi Ben,the project is very interesting, which arduino is better?
Do not know well brain mach3, have file brn of the project?
Re: Arduino Uno that works with Modbus
« Reply #7 on: April 23, 2018, 07:06:47 AM »
I do not have the Brain file for the project. You can do it yourself using the info above.
Re: Arduino Uno that works with Modbus
« Reply #8 on: April 20, 2019, 03:01:07 PM »

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
Re: Arduino Uno that works with Modbus
« Reply #9 on: April 24, 2019, 01:50:03 AM »
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