Modbus Mach3 To Arduinono Additional Hardware Brai
Modbus Mach3 To Arduinono Additional Hardware Brai
by VladoM
I will describe here how to connect arduino directly to In this case the standard Usb cable connecting pc
mach3 without any additional hardware. and arduino will do.
This will not use any modbus library it is just proof of But you can buy USB to rs485 adapter and connect
working. You will end up with ability of mach3 to read to rx tx lines and it should be basicaly the same think.
input pin on arduino. But if this will work for you then
adding full modbus library for proper comunications On the image is the whole setup. Arduino connected
shouldnt be any problem. to PC + one led but you dont need the LED (it is just
indicator so i know what information should be send
Small think about modbus back from arduino) and cable so you can ground a pin
on arduino. Led should have resistor in series, i just
Modbus is software protocol not hardware, so you coudnt be bothered and the led suvived.
can use it not only ower rs232 or rs485 but also let
say uart usart. Doesnt matter the amount of On left side of image is the USB to rs485 adapter
connections the hardware protocol uses, basicaly it (you dont need that). i just wanted to add it in case
boils down to one comunication line for half duplpex you wanted to know what the one i have looks like.
and two for full duplex. and it works fine. i was trying it with some rs485
hardware.
The comunication of mach3 with arduino will be done
using uart. so rx tx lines.
This was the inspiration for my test and the code is from this page:
http://www.machsupport.com/forum/index.php/topic,2...
The whole think is very simle, arduino recives int his case any 8 bites and replies with
01 04 02 00 00 78 f0
or
01 04 02 00 01 b9 30
In real comunication these packets are modbus reply for "01 04 00 00 00 01 31 ca" question. which is read input
register question.
So we will send request from mach3 to read input register and arduino replyes with data containing 1 or 0. So
thisway we can read state of inputpin on arduino.
01 04 02 00 00 78 f0 returned ingormation is 0
We will need some Modbus tester : Attached image is from the tester it will automaticaly
KMtronic_ModBus_Tester show you port on which is arduino connected if you
have more ports connect and disconnect arduino you
http://info.kmtronic.com/kmtronic-modbus-relays.ht... will see which port dissapear and then appeard in the
list again.
We upload the code at the bottom of this page to the
arduino. set comminication speed for 9600 as this is what we
use at the mmnt in the serial comunication in arduino //just an led information if input for which we test is
program. high or low
This code is basicaly copy form the page i used as digitalWrite(pinLED, LOW);
inspiration. i just added the LED. because i needed
small help with testing. and changed pins. }
Now we send request command to arduino 01 04 00 00 00 01 this is what mach3 will do.
We could send any 8 bytes to arduino as you can see from program , it is just to properly answer so arduino
doesnt care for question in this case.
also note that we send this : 01 04 00 00 00 01. tha last 2 bytes which is checksum will be automaticaly added by
the Mddbus tester program.
On the image is possible to see that i sent twice the 01 04 00 00 00 01 command to arduino.
if this works for you, then the arduino side is done. as we can see arduino replying to questions sent from the
tester.
the last two images are the arduino setup when set to reply 0 and then set to reply 1.
First in your modbus tester press CLOSE button. Otherwise Mach3 will be unable to communicate with arduino (it
will not be able comunicate on already OPEN COM port).
set comunication speed for 9600baud then when you coonect on arduino D4 to ground and
pres Read button in mach3 again it should display
As usualy you need to pres OPEN to allow for 0001.
communication on the com port.
now you have succesfully established comunication
if there will be something wrong Status: message will with mach.
show you. otherwise there should be written : No
this will show you what is sent or recieved on given you can see arduino replying by 0 and then 1. that is
comport. what you should see if you done the test in previous
step.
look at the images to see how i set the viewer.
if you are missing some data you can quickly here
The last image shows you the window where you can identyfiy if mach is sending something or if arduino is
check the communication. replying.
you can see what data are sent from mach and what
Set the proper com port (i am bit messy on the arduino to read the input register.
images sometimes i have 4 sometimes 5 but if you
dont unplug and plug in other devices the port will be if all is set correctly and you pressed apply button the
the same) on which your arduino is connected and fill arduino rx tx led should be constantly blinking as
the data as per image. mach is sennding the requests in 50ms intervals
(refresh column)
this config will set CFG #0 be sending request to
it will asks you for the bain name so give it some. in the window press modbus and do the setup as per
then it will open the editor. image.
on my image it is all filed in already but: you are just setting for the fact that you are using
modbus plugin and and the CFG #0 which we set in
you will press + previous step.
Now select the second added rectangle and press the upside down T this will add the functionality what should
happend when the signal recieved is 1.
and now when 1 is recieved from arduino it will start your program.
then come back here again select your brain and press view brain.
You should be able to see the response of the brain when D4 on ardino is connected to ground or not.
TADAAAA functional mach3 comunication which acts as remote Cycle Start button.