Hello Guest it is October 10, 2024, 01:11:11 AM

Author Topic: Arduino Modbus, Complete, Documented and free  (Read 240364 times)

0 Members and 2 Guests are viewing this topic.

Arduino Modbus, Complete, Documented and free
« on: March 15, 2012, 03:24:37 AM »
All,
Had a little extra time on my hands so I created a Modbus slave for Mach 3 using an Arduino Uno.  Costs roughly $30 to get and uses completely free software to configure and implement.  Also included is my documentation of all code, settings and building a basic brain for Mach.
Please feel free to use and build upon,
Shilling

Offline NV50

*
  •  53 53
Re: Arduino Modbus, Complete, Documented and free
« Reply #1 on: March 27, 2012, 02:02:25 AM »
Hello,
Great job and very good documentation

Just a few details when I compile the "Modbus Slave.pde"
Arduino IDE identifies four errors.

"Config_IO" was not Declared In This scope
"Kill_IO" was not Declared In This scope
"Updates_Pin_states" was not Declared In This scope
"UpdatesAN_States" was not Declared In This scope

thanks
Re: Arduino Modbus, Complete, Documented and free
« Reply #2 on: March 31, 2012, 08:12:00 AM »
Shilling,

Wonderful job. The documentation is very impressive and detailed too.

I am using arduino with modbus slave sketch by Juan Pablo. It only implements funtions 3,4 and 16 of modbus. I am using it mainly for tool change, auxillary keypads and analog inputs for FRO and spindle override. Programming the chip with Uno and putting it on my BOB with serial port. This way it costs me less than $10.

I have yet to try your sketch on my Uno. Have you tried connecting MPG through it?

Zafar
Re: Arduino Modbus, Complete, Documented and free
« Reply #3 on: April 29, 2012, 12:39:32 PM »
Hello Tim:

Looks very promising for Modbus. I have a Cubloc PLC, and am connecting it up to my back-up computer for testing. The (3)potentiometers for Feedrate override, Jog %, and Rapid override all work fine with my brains written for the Cubloc; just had to change the address in the setup screen.

Are the digital input pins, (1 thru 12) fixed at present state? They are all 5v/High state, and apparently must be pulled to ground to activate a digital signal input.

If it is (or is not) possible to change the pin mode state, please explain.

I loaded the Modbus program on a Mega 1280, and the standard 328p. Both load fine.

However, trying to load with the latest Arduino ver. 1.0 would not compile. Compile and upload worked fine on Arduino IDE 0021, and 0022. I am sure 0023 works also, as that shows in as the version you used for the screen shot pictures in the manual.

Also, when I ran the blinking LED test, the timer interferred with the Cycle Start screen button in my MSM screen set. It blinked the little white triangle rapidly. When I unchecked the enable box for the timer config, the mad blinking stopped.

The MSM screen set is produced by David Bagby at Calypso Inc., and is an excellent replacement for the standard Mach3 screen. It also has an enormous pdf manual, and a very comprehensive probing screen, with many videos to explain everything it does.

Also, thanks for the superb pdf manual.   








Re: Arduino Modbus, Complete, Documented and free
« Reply #4 on: April 29, 2012, 08:49:08 PM »
More info on making input buttons to work:

So far, I am using the pushbutton in pull-down, 0 volts mode. Works fine. It took some time trying different check boxes for the proper function for the brains.

Each button has to be in the Set-up page, under a separate config#'s. The address entered into the Mach3 setup table Address column,for each button is the Arduino pin number you are going to use.

I could not get pins 0, and 1 to work. These are default Rx (pin 0), Tx (pin 1) on the Arduino.

So, my pushbuttons start with pin 2. Pin 13 on my Arduino standard (328p) is internally connected to an LED. I did not use pin 13.

The first part of a brain for each button will look like:  MOD:0 - D0 - P:5 : 1

The MOD:0 is the Register address for the I/O, per Table 4 - Register Map, page 15 of manual. All inputs up to 15 will have this 0.

The D0 is from checking the box for bits, and setting bit number to 0. All of the I/O brains had to be like this.

The P:5, is the Config# in the Modbus setup table in Mach3. The pin address (Arduino pin #) is in the Modbus setup table, and is not entered into the brain checkbox's. This number is unique to each button, since each one has it's own config.

The last number above, : 1, is what the brain looks like when viewed in the Brain viewer. When you push the button, this 1 changes to a 0, zero. It does not show up when you make the brain.

So far, all is working well. I have (3) 10k potentiometers working, and they are actually easier than the buttons. The 328p Arduino has 6 analog inputs, which can be either Analog or Digital.

I am sure there are other configurations that will work with this program, but these numbers will get results.

Since an Arduino is about $30, this is a very nice, inexpensive solution for analog and digital I/O. If you need more pushbutton I/O than the small Arduino, the Mega is slightly more money, but has about more than triple the analog and digital I/O.

Hope this is useful.
Re: Arduino Modbus, Complete, Documented and free
« Reply #5 on: May 13, 2012, 11:06:17 AM »
This Modbus program does NOT function above the regular Arduino pin numbers. The Mega has 54 I/O pins available, and only the pins 2>12 work in it's present state. I did not test all of the 16 analog pins on the Mega, only the first 6, which work like the standard 328p cpu Arduino. Also, unlike the standard Arduino, that can use the Analog pins for digital I/O, this program will not allow it.

It seems the author, Shilling, does not monitor this forum.
     
If you want to add some potentiometers for Feed rate, etc., and up to 10 digital I/O panel buttons or LED's it will do that. I would not go out and purchase an Arduino for running Modbus on your machine with this program. :(

Cubloc's smallest CPU, www.cubloc.com, will do far more than this for under 40.00, has a free download program "Cubloc Studio" for programming the various functions, on screen debugging your programs, including ladder logic and Basic, which can run simultaneously, with full Modbus implementation.


Re: Arduino Modbus, Complete, Documented and free
« Reply #6 on: September 18, 2012, 02:49:05 PM »
 I found that you have to edit some files in the libraries refering to  "WProgram.h" to Arduino.h in order to get it to compile
Re: Arduino Modbus, Complete, Documented and free
« Reply #7 on: November 17, 2012, 03:18:55 PM »
can everyone post some tutorial how to program inputs for FRO and spindle override in brain and modbus seting for arduino modbus.thanks
Re: Arduino Modbus, Complete, Documented and free
« Reply #8 on: January 07, 2013, 12:57:07 PM »
To anyone who might be interested, I have created a tutorial of how setup an Arduino as MODBUS slave that covers both the hardware and software configs. I cover a connection with a C-more HMI, but the basics translate while to this.
http://krakllc.wordpress.com/2013/01/04/arduino-modbus-connection-to-a-c-more-hmi/

I, for one, would like to thank Schilling for his efforts. While I could not get his library working, mostly due to the "Wporgram.h" issue. His website was very informative and is a great resource for someone who has little experience working with MODBUS. 

At some point I do plan on revisiting his library with the updated edit to include "Arduino.h"
Re: Arduino Modbus, Complete, Documented and free
« Reply #9 on: January 21, 2013, 04:46:26 PM »
Hi,

For all having some problems with an Arduino  MEGA
In the modbusslave.pde there is line
"#define Digital_IO_Pins  14 "
that line limits the number of inputs to 14 for the MEGA that has to be increased to 64 (64 is the limit of the IO_Config_Register)
further more in the Kill_IO_Register section there is a typo the last line of the AN Digital also does +3 this should be +4

And for safety reasons there should be a section be created like Safety_IO_Register
Here you could state the safety flags some outputs should be OFF other should be ON when COMMS fails

Also the safety bits should be implemented in the Pin_manipulator.

And for those that really wanna go cheap and simple an ATMEGA8 can do but you need to comment out all line that are there for the MEGA only.
It will fit then with a 8Byte margin or so.


« Last Edit: January 21, 2013, 04:47:58 PM by Madart70 »