Join us today!

Notifications
Clear all

How to send UDP in a TwinCAT project without using PLC logic?

1 Posts
1 Users
0 Reactions
77 Views
(@ylahdili)
Posts: 2
Active Member
Topic starter
 

Hi. We are using TwinCAT 3 Interface for Simulink to convert a Simulink model into a TwinCAT object. The object has inputs/outputs that are linked to actual Beckhoff I/O terminals which in turn control a motor and sense its angular position. Concurrently, we want to read this position information, and send it as UDP packets (18 integers, i.e. 18 bytes) to the engineering PC (where TwinCAT is running). That's because on that PC, we also have a Unity game running, which will listen to that UDP packet, and use it to update the position of a sprite on the screen.

Before we migrated from Simulink-only solutions, to the Beckhoff ecosystem, the way we use to achieve UDP transmission was to go into our Simulink model workspace, drop a built-in "UDP Sender" block there:

image

... then connect its data input to "position" data. This block will take care of converting that data into UDP packets, and broadcasting them to the desired IP address (in this case to itself, hence "localhost" address).

But now, when we build that Simulink model into a Beckhoff TwinCAT object, the "UDP Sender" do not get code generated (as a C instance), and therefore it doesn't activate once that TC object is added into TwinCAT.

Essentially our question is: do you have any solution or suggestion for how we can realize a "UDP Sender" replacement in our Simulink model, that will still be streaming UDP packets when the model is running as an object in TwinCAT?

PS: We are not very comfortable programming PLC using IEC61131-3 languages like ST and FBD (we know TwinCAT provides a UDP FB_PeerToPeer and FB_SocketUdpSendTo Function Blocks). Rather, we prefer a bare-bone solution using only our "position" I/O output being read on an ADS channel for example (even if it comes to tweaking the Unity game itself). That being said, if there is absolutely no alternative but to code PLC logic, then we will have to jump into that exercise (in this project we have always managed to dodge coding in PLC languages thanks to Simulink TC Interface, but I guess there is a beginning for everything).

 
Posted : 07/10/2024 4:55 am
Topic Tags
Share: