Hello Guest it is March 28, 2024, 08:44:29 AM

Author Topic: Interface with Industrial PLC (Ethernet or other options)  (Read 2847 times)

0 Members and 1 Guest are viewing this topic.

Interface with Industrial PLC (Ethernet or other options)
« on: April 29, 2020, 08:29:45 AM »
Hi All,

I'm not actively trying to make this work this second, but I'm interested in learning about trying to interface Mach 4 to an industrial PLC. I had a lot of success implementing a serial communication function within LUA so that got me thinking about other methods.

I have an Allen Bradley ControlLogix PLC. It can talk on almost any industrial communication protocol, but the most common is Ethernet/IP. The quick and dirty way to get this to work would to be to add a Modbus TCP module to the PLC and connect that to the PC, however is Mach 4 capable of Ethernet messaging? Is this functionality built into LUA natively?

I'm thinking mostly about just generic I/O consumption from the inputs on the PLC, but perhaps more involved schemes could be created that would allow Mach 4 to instruct the PLC to do things (not coordinated to the motion planner). Ethernet is wicked fast so I think this would be pretty successful.
Re: Interface with Industrial PLC (Ethernet or other options)
« Reply #1 on: April 29, 2020, 08:44:51 AM »
Mach4 has TCP Modbus.  You just set it up in the modubs configuration.   I have 5 or 6 machines here in the shop that I'm using the Click PLC from Automation Direct and communicating with TCP Modbus.  I use it to handle most  of my IO. 
Chad Byrd
Re: Interface with Industrial PLC (Ethernet or other options)
« Reply #2 on: April 29, 2020, 09:07:47 AM »
Yup that would definitely work I would think. My PC that runs Mach 4 has 2 Ethernet ports, so one for ESS and one could be for Modbus TCP.

Was just curious if it was a fools errand to try to communicate through Ethernet unsolicited socket messaging or any other method over pure Ethernet (not Modbus)?

Offline bcoop

*
  •  61 61
    • View Profile
Re: Interface with Industrial PLC (Ethernet or other options)
« Reply #3 on: April 29, 2020, 10:31:51 AM »
For Compact/control logix  you can quite easily setup modbus/TCP communications and talk to Mach. Rockwell as an example program on their website that you can download and make minor mods to get working.   

Bob
Bob
Re: Interface with Industrial PLC (Ethernet or other options)
« Reply #4 on: April 29, 2020, 10:56:54 AM »
Oh perfect. I was actually just researching this. I knew there were Modbus expansion cards, but direct socket messaging to a Modbus TCP master would be much cleaner. I need to play around with this!

I'm assuming that if my goal is to consume digital and analog values into Mach 4 and perhaps use digital bits to sequence logic in the PLC, Mach 4 would be the master and the PLC would be the slave.
Re: Interface with Industrial PLC (Ethernet or other options)
« Reply #5 on: April 29, 2020, 01:38:13 PM »
Holy crap! I poked at the Modbus configuration and code in the PLC. Had everything working in 15 minutes! It is so much more simple than setting up Modbus in Mach 3.

So far the only thing that isn't working is if I power on my slave (PLC) after Mach 4 is opened up, the Modbus won't connect automatically. I have to go into the Diagnostic -> Modbus then click STOP and START. After that, everything is working. Any idea how to get it to connect automatically?

Re: Interface with Industrial PLC (Ethernet or other options)
« Reply #6 on: April 29, 2020, 02:35:30 PM »
So I'm getting a pretty good feel for this! I do notice that Mach is likely to crash or respond slowly when I setup very high counts of read registers (0x4, qty 1000). Another thing I notice is that each Modbus function takes about 40ms to execute pretty much regardless of the quantity of registers being read. This discourages the user from setting up lots of individual Read Coil (0x1) functions in favor of 1 function with a large quantity of coils.

Where would I find the LUA API calls for the Modbus? I don't see them in the Mach4API.chm file.



Offline jbuehn

*
  •  101 101
    • View Profile
Re: Interface with Industrial PLC (Ethernet or other options)
« Reply #7 on: April 29, 2020, 03:06:46 PM »
In some of the newer development versions, the change log has some items about changing the scan time.

Offline bcoop

*
  •  61 61
    • View Profile
Re: Interface with Industrial PLC (Ethernet or other options)
« Reply #8 on: April 29, 2020, 04:32:52 PM »
Glad to hear you got the PLC portion going,  I had some issues with reading data from my VFD for the spindle, seems Mach would read all integers as signed, and my VFD was using some unsigned such as frequency 0-40,000 for for 0-400hz. so when reading that into Mach, anything over 32767 would turn into a negative value, anyway long story short, worked with tech support and they had their programmer add the ability to set the word as unsigned, its now working fine, and in the prerelease FTP site, along with the scan rate denominator to change scan rate for each topic

Bob
Bob
Re: Interface with Industrial PLC (Ethernet or other options)
« Reply #9 on: April 29, 2020, 05:07:41 PM »
Wow! Glad you're familiar with this! So does the scan denominator slow down the rate of update? Like only update every 4 scans if the denominator is "4"?

Any idea how to add the modbus signals to LUA? Like lets say I wanted to read the value on one register and write it to another...