Mach3 Serial Port Plugin Check

I will describe here how to connect arduino directly to mach3 without any additional hardware. This will not use any modbus library it is just proof of working. You will end up with ability of mach3 to read input pin on arduino. But if this will work for you then adding full modbus library for proper comunications shouldnt be any problem. Small think about modbus Modbus is software protocol not hardware, so you can use it not only ower rs232 or rs485 but also let say uart usart. Doesnt matter the amount of connections the hardware protocol uses, basicaly it boils down to one comunication line for half duplpex and two for full duplex.

Everything you need to know to interface Mach3 with your programmable logic. After your PLC is programmed with the communication check (as described. To open the serial modbus control, select Function Cfg's from the menu bar. By-pass the MachMotion plugin and do the data processing directly in Mach3. Apr 20, 2011 - Fortunately the Cypress Enable scripting engine built into Mach3 allows you to. This function is used to check if a port with a certain number is.

The comunication of mach3 with arduino will be done using uart. So rx tx lines. In this case the standard Usb cable connecting pc and arduino will do. But you can buy USB to rs485 adapter and connect to rx tx lines and it should be basicaly the same think. On the image is the whole setup. Arduino connected to PC + one led but you dont need the LED (it is just indicator so i know what information should be send back from arduino) and cable so you can ground a pin on arduino. Led should have resistor in series, i just coudnt be bothered and the led suvived.

On left side of image is the USB to rs485 adapter (you dont need that). I just wanted to add it in case you wanted to know what the one i have looks like. And it works fine. I was trying it with some rs485 hardware. I did my test with arduino mini pro. This was the inspiration for my test and the code is from this page: First software for arduino: The whole think is very simle, arduino recives in this 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. Quick look at the modbus package: let say thisone: 01 04 02 00 00 78 f0 • 01 is addres of slave device • 04 is information that we are going to read input register • 02 00 00 lets simplyfy this for the data information. ( but basicaly it is N*8bits of data in this case so 2 bit containing 00 00) • 78 f0 is just checksum so mach3 will read from thees returned packets 01 04 02 00 00 78 f0 returned ingormation is 0 and from 01 04 02 00 01 b9 30 returned ingormation is 1. 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. • first in red rectangle: when D4 pin is not connected to anything (is sitting at 5v) 0-TX 01 04 00 00 00 01 31 ca is what arduino recieved and replied with the 1-Rx. Returning 0 in the data • then the green rectangle when i connected D4 to ground, my LED is on now and reply is 3-RX.

Returning 1 in data 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.

In Mach 3 go to top menu->setup serial modbus controll and in popup window press test modbus. Mach3 will not add automaticaly any choice for Port Num.: but this will be the same port you have seen in the modbus tester application so if it was showing Com5 write in Port Num.: 5. Set comunication speed for 9600baud As usualy you need to pres OPEN to allow for communication on the com port.

If there will be something wrong Status: message will show you. Otherwise there should be written: No error Now you can basicaly set rest of the data as on the image when you press Read button: in the big data window on the right it should show 0000. One click unbrick lg. Then when you coonect on arduino D4 to ground and pres Read button in mach3 again it should display 0001. Now you have succesfully established comunication with mach. I am using a software called free-serial-analyser. This will show you what is sent or recieved on given comport.