PLC-PC communication and control

Thread Starter

YAndy

Joined May 16, 2022
6
Hi,

I have an application where I need to control a PLC's IO with a PC running self made code.
There seems to be very little information on this on the web. I know an industrial network will have to be set up between the two.
Can anybody inform me with all the information necessary and how to best go about this?

Thanks in advance!
 

Thread Starter

YAndy

Joined May 16, 2022
6
The method generally used is Modbus, There should be plenty of info out there, including setting one up.
Also, what if I wanted to have a low level code running on the PLC and still be able to access the IO with a PC.
I know this is possible. I have worked with a ABB robotic arm before that could do this. A network was established between the robot controller and the PLC and would send buffers of several bytes to eachother.
I don't find any information on this online.
 

strantor

Joined Oct 3, 2010
6,875
What about connecting a remote IO/coupler directly to a PC with for example Modbus. Could the IO be accessed that way?
It depends on what protocol the I/O uses. Some use modbus or other open protocols so you could access them the same way as a PLC. Some use proprietary protocols intended only to communicate with that brand of PLC.

Modbus is easy. Use it if you can. What PLC and what I/O are we talking about?

Also, what if I wanted to have a low level code running on the PLC and still be able to access the IO with a PC.
I know this is possible.
Yep. Is possible. Depending on protocol you can either get all the data from the PLC (which is getting some of its data from the I/O) or you can talk both to PLC and I/O separately. I would do it the first way.
 

Thread Starter

YAndy

Joined May 16, 2022
6
It depends on what protocol the I/O uses. Some use modbus or other open protocols so you could access them the same way as a PLC. Some use proprietary protocols intended only to communicate with that brand of PLC.

Modbus is easy. Use it if you can. What PLC and what I/O are we talking about?
I don't know yet. That's what I'm trying to figure out. So far Wago seems like a pretty good option.

Yep. Is possible. Depending on protocol you can either get all the data from the PLC (which is getting some of its data from the I/O) or you can talk both to PLC and I/O separately. I would do it the first way.
Would you have any sources that could help me with this? Or personally know how?
 

Thread Starter

YAndy

Joined May 16, 2022
6
It depends on what protocol the I/O uses. Some use modbus or other open protocols so you could access them the same way as a PLC. Some use proprietary protocols intended only to communicate with that brand of PLC.

Modbus is easy. Use it if you can. What PLC and what I/O are we talking about?
Also, how usefull and easy is Modbus when dealing with special modules like PWM output modules and communication modules for RS-232 or RS-485 connections.
 

jiggermole

Joined Jul 29, 2016
185
You are asking a lot of high level questions and expecting bit level answers.
What brand of PLC?
What kind of communication adapter are you using on the pc to do the talking?
Allen Bradley and other high level plc manufacturers have the capability to integrate with a variety of pc based databases and files.
Hell at one point I was using a specialized excel spreadsheet to download data from a plc.
There are SO MANY different ways of doing what you want to do its impossible to help you because there is no way to start.
There are cheap options like using a remote IO pci card in the pc and directly wiring the outputs from the computer to the plc. And there are expensive options like installing an EthernetIP driver on the computer and using regular ethernet to communicate to the plc. There are dedicated cards for many plc brands that specifically allow communication on just about any communication protocol you want to use.
Like I said, there are just too many options for what you want to do. Way too many. The specifics of the application may help. Are there speed or bandwith requirements? Are there space constraints that limit what you have available for use?
And the big question, why? Beckhoff is one, but there are a few companies that run plcs off a regular windows machine. You're custom code would run and interface with the IO directly on the same computer without needing a separate computer and plc. Do you even need a plc? If not than why not use the pci slot IO card and control it directly from the computer?
 

Thread Starter

YAndy

Joined May 16, 2022
6
You are asking a lot of high level questions and expecting bit level answers.
What brand of PLC?
What kind of communication adapter are you using on the pc to do the talking?
Allen Bradley and other high level plc manufacturers have the capability to integrate with a variety of pc based databases and files.
Hell at one point I was using a specialized excel spreadsheet to download data from a plc.
There are SO MANY different ways of doing what you want to do its impossible to help you because there is no way to start.
There are cheap options like using a remote IO pci card in the pc and directly wiring the outputs from the computer to the plc. And there are expensive options like installing an EthernetIP driver on the computer and using regular ethernet to communicate to the plc. There are dedicated cards for many plc brands that specifically allow communication on just about any communication protocol you want to use.
Like I said, there are just too many options for what you want to do. Way too many. The specifics of the application may help. Are there speed or bandwith requirements? Are there space constraints that limit what you have available for use?
And the big question, why? Beckhoff is one, but there are a few companies that run plcs off a regular windows machine. You're custom code would run and interface with the IO directly on the same computer without needing a separate computer and plc. Do you even need a plc? If not than why not use the pci slot IO card and control it directly from the computer?
I completely get what you mean. But I'm vague because I'm trying to figure out if in theory it's possible. The code is complex and requires a lot of computing power hence the seperate PC. The PC has to do a lot of things that any PLC just can not do (This is a small IPC btw, not expandable by PCIe). I'm realy just looking for the best way to get some IO information into my PC to use in self-made software.
 

Ya’akov

Joined Jan 27, 2019
10,235
Hi,

I have an application where I need to control a PLC's IO with a PC running self made code.
There seems to be very little information on this on the web. I know an industrial network will have to be set up between the two.
Can anybody inform me with all the information necessary and how to best go about this?

Thanks in advance!
Welcome to AAC.

What is the application for the PLC? Does it involve and health and safety risk? Does it have to be rated in any particular way?

It will be a lot easier to help if you can explain what the PLC will be doing.
 

ScottWang

Joined Aug 23, 2012
7,501
When you buy a PLC then you can get an operation manual, whether it is a real paper or a *.pdf download from the website, all the PC ↔ PLC communication commands in the manual.
 

strantor

Joined Oct 3, 2010
6,875
I strongly suggest since you have not already chosen a PLC, choose one which supports modbusTCP. This is a very easy task with ModbusTCP and you can use Python (pyModbusTCP). I am currently using this at a dozen different locations to communicate between onsite computers and AD Click PLCs, AD Productivity PLCs, Mitsubishi TE2 motor starters, Laumas load cell amplifiers, Stellar motor starters, and Advantech remote I/O. The computers act like a DCS, exchanging data between machines on a production line and offsite servers. The computer can shut down a production line if something on the line isn't right or current price of electricity goes too high, and send an email to the site supervisor requiring a specific reply to re-enable the line.

The easiest pyModbusTCP integration i have done is with Productivity PLCs. It is stupid simple. Just assign Modbus addresses to whatever tags you want to access and then send a command from Python to read/write to that address; the PLC automatically complies, you don't have to include any instructions in the PLC to send/receive, it all happens automatically. It doesn't get any easier or simpler than that. Everything is over ethernet, no special cards required, no problematic protocol translator boxes, no nonsense. Check it out.
 
Last edited:

strantor

Joined Oct 3, 2010
6,875
Also, how usefull and easy is Modbus when dealing with special modules like PWM output modules and communication modules for RS-232 or RS-485 connections.
For a PWM output, you will simply write a value to a tag that is copied to PWM the output. No different than writing any other value. If the resolution of the output is higher than 16 bits then you will need to concatenate two 16 bit registers in the PLC to a 32 bit DWORD before copying to the output. Modbus only deals with 16 bit and 1 bit tags.

For comms modules, same story, except you will almost certainly have to do some rearranging in the PLC. IIRC I think ASCII string types are 8-bit arrays (?) and since modbus only does 16 bit types you'll need to pack chars 2 at a time into a 16-bit value, send it over, and split it up in the PLC again. Or just send one char per 16 bit tag; that would be way simpler but you will waste half the data, but if it isn't excessive it shouldn't matter.
 

jiggermole

Joined Jul 29, 2016
185
I'm on board with everything strantor has said.
but if you decide you don't need a plc at all I've seen a similar card to this one. Its a pci digital IO card from national instruments. It sounds like you are already familiar with writing code for the pc so you should be able to just interface with the pci card with NI's drivers. We had an outside agency write the code for that so I'm not at all familiar with how to do it, but I can wire 24vdc inputs to the card.
 
Top