Clement Prelot Ebrignetti Posted February 3, 2022 Report Share Posted February 3, 2022 Hello guys&girls, I'm new to Unitronics PLC programming and I'm facing some problems. I'm working with a USC-B5-T24 which needs to receive through UDP protocol some datas from a C++ program. I hadn't find in the unitronics examples programs doing this. Can someone give me the guidelines to set my PLC to receive datas from my C++ program ? Thanks in advance ! Quote Link to comment Share on other sites More sharing options...
MVP 2022 Joe Tauser Posted February 3, 2022 MVP 2022 Report Share Posted February 3, 2022 You are correct - there is very little in UniStream documentation regarding UDP. It's not common in our world. I'm guessing you have a reason for choosing this. I could not find a UniStream example either and UDP Tx and Rx are mentioned in the Help but not further documented. You'll be rolling your own protocol here in your C++ program. UDP is just the carrier. I've used it in the Unitronics Vision series on local networks as it is very fast. Unfortunately with no handshaking, you don't know that the message was received. First you set up a UDP socket and assign a port under the PLC Communications tree- The UDP function blocks are very logically located (not!) in the COM: CPU TCP/IP group: After that it's pretty simple. You just drop a UDP Rx block and wait for your blob of data to land in the Buffer array you define. What you do with it from there is up to you. If you create a program an upload it we can have a look. You can also contact Official Unitronics Support at support@unitronics.com. You may want to consider including a Modbus TCP library in your C++ code and go that route instead. What sort of "datas" are you transferring? There is quite of bit of Modbus experience on the forum. Joe T. Quote Link to comment Share on other sites More sharing options...
Clement Prelot Ebrignetti Posted February 7, 2022 Author Report Share Posted February 7, 2022 Hi Joe, thanks for the advice. I prefer use this protocol because I transfer few datas as vector of int16 and I need the minimum of latency (it's for a live monitoring on a robot). I will do a feed back Quote Link to comment Share on other sites More sharing options...
Clement Prelot Ebrignetti Posted February 9, 2022 Author Report Share Posted February 9, 2022 Hi guys&girls, Thanks to Joe's advices, I achieve to make my PLC and my C++ code exchanging data's through UDP protocol. So I've written my C++ program on VScode through an Ubuntu20.03 VMWare. For those who wanna do it, follow Joe's advices to set your UDP socket on PLC. After this, I write my C++ code that open a socket and can send and receive data (I've follow this tutorial on UDP C++ programming : https://bousk.developpez.com/cours/reseau-c++/UDP/01-introduction-premiers-pas/). On VMWare, I've set my network adaptater on "Bridged" with the option "Replicate physical network connection state" (users on forums say this option should be activate for those who work on a laptop like me) and in Ubuntu I've set my ethernet connection manual in the network settings>>IPV4>>manual>>xxx.xxx.xxx.xxx. When I execute my code, I've just to write my local port, the IP of the UDP on PLC and the port defined in and it works ! Best regards ! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.