Trailing zeros in twincat 3

johale

Member
Join Date
Apr 2024
Location
Norway
Posts
1
I am using twincat 3 to send some strings over TCP/IP. Where the server is a sensor and my PLC is the client. I noticed that the sensor didnt react to my commands, so i set up a server in Python to see how the sent strings looked like. I noticed that there were trailing zeros after the string was printed in Python. When i loopback the sent data that python recieved to twincat, there is not any trailing zeros.

Does anybody know how to remove the trailing zeros before the string is sent in twincat? I have tried to do this sLRTrim := F_RTrim( F_LTrim('string'));
But it dosent work. Have also defined the variable as a String(22), but whenever i do that, it just replace my last string with a trailing zero.
 
You could brute force it: if the last character of the string is a zero, then reduce the string length by 1; do that in a loop "while length(string) > 1"

I assume twincat has some string-handling functions like MID and LENGTH and such.
 

Similar Topics

I thought I'd mention this errant thought since we have a number of fiscally-oriented people here. The worst thing that can happen to a stock is...
Replies
91
Views
16,752
I need to trigger a process off the trailing edge of an item passing in front of an eye. Could someone offer some quick simple logic that will...
Replies
4
Views
4,099
1st post here, but have been lurking for months. I have found the threads here extremely helpful. I've been struggling with this issue for the...
Replies
8
Views
2,989
Hi, I have successfully got my system to do the following: 1. write the RTC hours, minutes and seconds to 3 integer files every 250 mS. 2...
Replies
7
Views
2,122
Hello, I am responsible for implementation of Vijeo Citect 7.4 SCADA in my company. I want to connect to Beckhoff PLCs by using Twincat OPC...
Replies
0
Views
1,991
Back
Top Bottom