-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do you specify what local network resource is used to connect to a PLC? #147
Comments
The short answer is no. Might be possible in the future though, I've never encountered a situation where I had to do this. Looks like the socket module has an option SO_BINDTODEVICE, which might allow this. I'll have to do some homework, I don't immediately have the right hardware at my disposal to test this. |
I'd recommend looking into ip routes, in theory it should work, but don't quote me on it, I'm not a networking guy. From my basic understanding of routes you setup a destination ip in this case your plc identical ip, and a gateway ip for the usb-ethernet. You then use pylogix to communicate through this gateway and the route should send packets back and forth between the gateway and the plc. I'll see if I can test my theory if I have some time this weekend. The other option would be to use a web server. Put a raspberry on each plc to pull your data, and send it to a server. Below was a quick example I wrote a while ago for simple rest requests, so you could run that simple server on each identical plc raspberry pi and the server ip needs to be different. And then you can request data from that server by doing simple rest requests, but you'll need one raspberry pi on each plc + one to converge your data. |
I think you can do what you want if you use a couple of Rockwell Stratix switches: |
@evaldes2015, yeah this sort of thing is typically done with hardware as you suggest. We often supply multiple machines with the same addresses, each with a 1783-NATR or something like that to get them on the facility network. |
Nice solutions. I've never seen this setup, but I guess is more for identical machines on production lines which I haven't worked with before. Btw the 5700 on the picture might be an overkill if you only need those two plc's, you can get a netgear 4 port managed switch. I think it might be cheaper with the NATR module, than buying 2 stratix switches + a layer 3 switch if you don't already have one. |
Hey guys, |
Pi's are cheap indeed and very powerful too. If you're going that route a pi on each plc, you can just add another usb ethernet adapter to each pi so for example if your machine is on the 192.168.1.10, the pi eth0 can be 192.168.1.50, and your usb ethernet eth1 on 10.10.10.50. Your second pi on 10.51, 1.51... and so on. Then add a switch so that your main data retrieval machine can communicate with all the 10.10.10.X devices. Or even another pi, if is only two plc's. If you take a look at the simple flask server I posted earlier you can then setup each server on eth1 for each plc. I've only created 3 routes, but if you need more, PRs are welcomed. I think retrieving data this way trumps spi/i2c all day every day. 😃 https://github.com/TheFern2/pylogix-api |
Maybe you should try doing the port forwarding in Linux. |
@evaldes2015 Yup that would be the easiest thing to do with minimal hardware. If routes are too difficult or just don't work then next option would be the web api. Interested to see if routes works though. We usually have a bunch of routes on our stations but I've never dug too deep into how they work together with stratix. |
Hello,
I have an application where I need to connect to two machines that have the same IP address. My plan was to use a raspberrypi and two usb-ethernet adapters to connect to the two machines and the main ethernet port of the pi to connect to a data collection/distribution plc. I would like to use pylogix to move data between all three plc's connected to three different network interfaces. Is this possible with pylogix? Can you specify what local network resource you want to use when connecting to a PLC?
Thanks
The text was updated successfully, but these errors were encountered: