String tag only shows one character

brstilson

Member
Join Date
Jul 2012
Location
Michigan
Posts
246
I'm setting up a Sensopart code reader. Followed the Ethernet/IP instructions to the letter. Got everything working. I can read a bar code and get the number into my program.

Only problem is, the AOI that Sensopart set up seems to have a strange problem. There is a String Tag for the actual bar code, and their AOI uses structured text to transmit a portion of the input buffer one character at a time. They seem to be doing it the way Rockwell's ASCII Manual says to. here is the portion of their code:

Code:
 for intx:=0 TO 81 DO 
    DetectorResult_STR.DATA[intx] := strValueChar_implicit.DATA[intx];
  end_for;

Fairly simple and straightforward. Only problem is I get the following result:
uTUbEvM.png


The numbers are all there, but the main string is only showing the first character. By the way, this is running on a Softlogix Processor v.21
 
When you look at the String tag using the String browser/editor, it only shows the first character because the .LEN element is set to 1.

What length do you want the string to be ?
 
In the example you posted above the first NULL character is at DetectorString.Data[13]. So your string length should be set to 13.

If the barcodes are always going to be 13 characters long then set the .LEN at 13. Also the for loop only needs to run 0 to 12.

If the barcodes are variable length then try this:

Code:
for intx:=0 TO 81 DO      
    DetectorResult_STR.DATA[intx] := strValueChar_implicit.DATA[intx];
    If strValuChar_implicit.Data[intx] = 0 then
       exit
    end_if;
end_for;
DetectorResult_Str.Len := intx;
 
Last edited:
When you look at the String tag using the String browser/editor, it only shows the first character because the .LEN element is set to 1.

What length do you want the string to be ?

I've tried setting the string to something other than 1, but it always reverts back. My guess is the AOI is writing a 1 to this on every scan. The crazy thing is their documentation shows this problem in their example as normal. I think I'll have to look at their code and see where that LEN value is being set. Otherwise I could write the result to another STRING variable as a one-shot basis whenever it changes and then update the LEN for THAT string.
 
Well, that was the right track. The code right above the code I posted was where they set the string length, and they mistakenly pointed it to a variable that is always 1. I corrected this by pointing it to the address in the input buffer that corresponds to the string length, and now the output is the entire string.
 

Similar Topics

Hello all. I have a feeling I am going to shame myself with this question but I can't resolve it and can't figure it out......probably making it...
Replies
13
Views
1,038
Hi I am trying to Write into a PLC Tag using the Inger v7 , the Plc is a Micrologix 850 2080-LC50-48QWB , I can write bool , interger , but when...
Replies
1
Views
398
Action On Release command Set(ConveyorPopup,ConveyorPop_1) rejected w/ string tags. SetStringTag(index, data) wants an index. How does one pass...
Replies
8
Views
959
Hello all, I have a FactoryTalk View SE HMI where I am using a macro to display an appropriate display based upon a value that's passed into the...
Replies
0
Views
1,244
Long story short, I am creating a display to display an array of Strings from PLC [topic]VarStrA_RPHD.Desc[VarStrB] totally 100 strings...
Replies
1
Views
1,403
Back
Top Bottom