I have a question regarding an old PLC X20CP0291. Due to our firm wanting to expand our data collection i was task with accesing data from our powerplant (Right now its done by an external firm and its being save in some sort of SQL database).
What I was trying to do was to make an OPC UA Server on the PLC but the PLC doesn´t have support for this kind of aplication. So I was thinking about using a Raspberry pi to collect data from PLC and make it an OPC UA Server.
Unfortunately I wasn’t able to find any solution about this topic.
Do you think its a possible way of data aqusition or am I far off?
Create a little TCP or UDP program on the PLC and send the data you needs to your Rpi, you can then store it more easily on the Rpi side. AsTcp example AsUdp example
I think its about time i give some update. Sorry for the delay but I am a part-timer so I don´t have as much time for this project but here is what i came to.
So I have make some progres regarding the communication and some mistake regarding the hardware.
Firstly the mistake, I gave you the wrong PLC. The plc the powerplant is using is HMI panel 4PP420.1505-75. My thought is that the other PLC i found in the network is used on the other side as a collector of data from the HMI panel.
About the communication i found out that there is AsUDP binary object on bouth PLCs so my thinking is that they are communicating via UDP.
So my thinking is this. I would like to connect raspberry pi via UDP. I found out that you need the IP adress (that I have) and UDP port (i should be able to get it soon).
So now i have one more question:
Does B&R sends the data Unicast or Broadcast? Or does it entirely depends on how you program it?
I tried looking on internet and help and didnt find much. So I decided to write here.
it’s both possible: unicast and broadcast.
As default it’s an unicast as you send to a dedicated IP address, but when opening the UDP socket by using UdpOpen(), you can set an option to use broadcast (.options := udpOPT_BROADCAST).
Just to be concrete: when using broadcasting, you have not only to enable the broadcast option, additionally you have to send the packet not to a dedicated IP address, but to the networks broadcast address which is the highest IP address in your network segment.
If the broadcast address is not known, it can be determined by using CfgGetBroadcastAddr() from library AsArCfg.
I have a follow-up question regarding the security risks associated with broadcasting data. Would it be feasible to establish a Unicast communication setup involving two Masters (the old PLC and the Raspberry Pi) and a single Slave (the HMI)? Or is this architecture impossible and you have to do Multicast?
you can use more then one instance of UDP communication by using AsUdp, so yes it’s possible to communicate to multiple remote hosts by direct addressing their IP addresses/hostnames.
As Udp is a protocol without flow-control, it should be even possible to communicate via the same socket / port on the receiver, but this would make the data assignment maybe a bit more complex. So if there’s no mandatory reason to do so, I would prefer to use different sockets/ports at the receiver to have a direct 1:1 assignment between the communication partners.