Communicating a string - RSLogix 5000

bernie_carlton

Lifetime Supporting Member + Moderator
Join Date
Apr 2002
Location
Yakima, Washington
Posts
6,413
I'm working with a CompactLogix system and RSLogix 5000.

I used a condition on a rung to copy a string from itself to another string when the length (LEN) changed from zero. This was run through a one-shot to only do this once.

While monitoring the program from RSLogix 5000 I cleared the first string and the target string. Then I entered a 5 character string into the first one. Checking the result the target string got the length of 5 but its characters were 5 hex zeroes.

I think I've seen this before with an HMI and another external device when I tried to trigger on the LEN changing to non-zero and didn't think much but worked my way around it. I'm guessing that RSLogix 5000 and other external devices send the LEN in one messge then the array of SINTs in another, leaving a condition for a moment of the string with a length but not valid characters.

Maybe I need to use the 'handshake' bit available with controls on the HMI.

Any observations? Maybe everyone else already knew this and never triggerr just off the LEN.

[Edit - using Ethernet, just in case it matters.]
 
Last edited:
COPy will normally work just fine. The point is, I'm doing the copy when the LEN changes from zero and apparently the SINT character array hasn't arrived yet. In previous programs I ended up initiating a delay after the LEN changes before doing the copy and that seems to work.

Actually I can't think of any non-atomic pieces of information which get sent by an HMI other than a STRING.
 
I hope I follow OK, but I just tried this rung and the COP works fine on an L36..

NEQ String1.LEN 0 COP String1 String2 1

I did initialize the LEN to 0 and it still works.
 
y2kmfic - place a one shot after the NEQ of the string length. Then set the string1 using RSLogix5000 or an HMI. That way there is only one copy. Your line would continously copy after the LEN changes to non-zero.

The system I am using has many things going on with the Ethernet port. Perhaps that is causing a very small delay between the writing of the length and that of the SINT array of characters.
 
Last edited:
The ONS might have a lot to do with it

Had to put a timer in there, as you had to do in the past. The code below doesn't work until you take the PRE up to 100. It also helped to remind the Dest string what its LEN is supposed to be.

lLraUah.png


DelayTONR.PRE := 100;

IF SourceString.LEN > 0 THEN DelayTONR.TimerEnable := 1; ELSE DelayTONR.TimerEnable := 0; END_IF;

IF DelayTONR.TT THEN COP(SourceString.DATA[0],DestString.DATA[0],83); DestString.LEN := SourceString.LEN; END_IF;

IF DelayTONR.DN THEN DelayTONR.Reset := 1; END_IF;

DelayTONR.Reset := 0;

TONR(DelayTONR);
 
Last edited:
This all started for me when using a Real Time Automation Ethernet/IP to ASCII gateway. It communicates both ways by using strings.

I needed to take action as soon as a new string arrived. But I soon found that the LEN changing to non-zero was not a sufficient indication. Thus I had to use the timer offset similar to what dan_bob suggests.
 
I think you've put your finger right on it, Bernie: the HMI has to do two writes to get the String datatype across.

If you look in the Data Types folder for the default String, you'll see that the LEN element (4 bytes) comes first, followed by the 82-byte SINT[82] array.

RTA's code could have chosen either one to do first, but it probably just does them in the order they appear in the datatype definition.

dan_bob's method looks simple and straightforward.

If you wanted to extend that, I suppose you could clear out the Data[x] array that's being written to, and check the first byte for a nonzero value before copying the incoming String to another place.
 

Similar Topics

Dear All Please help me about Below picture problem.PLC not communicating proper.
Replies
4
Views
180
I need to recommend a PC to replace a customer's old Windows 7 computer. The only thing I need to think through is the serial com port to...
Replies
21
Views
688
Hello Friends, We have a powerflex that stopped working sometime last week. It doesn't communicate over the network, or use CCW directly from my...
Replies
1
Views
452
Hi All I'm trying to connect two zebra printers to th PLC through Ethernet. I can ping the Printer through my laptop connected to the private...
Replies
0
Views
361
Have a customer that has a running 1756-l83es, communicating to redundant ABCIP IO servers for Wonderware 2020. This configuration has been...
Replies
7
Views
876
Back
Top Bottom