S7 string challenge.

Join Date
Dec 2010
Location
Toronto
Posts
8
Hey Guys.

I am creating a FB which has a STRING (254) in the STAT. I was able to create the string without seeing red in STAT. However I cannot Load it to Memory.

I can:
// I can move 4 Bytes into MD.
L ‘MIKE’
T MD0

But I CANNOT:
Local symbol in STAT: First_Ch | String(254) | 48.0 | ‘THIS IS MY STRING. HELP!!!’
L #First_Ch
T ??????

S7 Help tells me: “If a temporary variable of the data type STRING was defined, the byte "max. length" must be written with the defined length before using the variable in the user program.”

1. 1) What does this help mean?
2. 2) Is it possible to put a string larger than a Double Word into a Memory Adddress?
3. 3) If possible can you please show me how?


Huge thanks in advance!!!
 
Coding STRINGs in STL is a real pain.
For copying STRINGs from adresses to adresses you should use SFC20 BLKMOV. For other tasks there are lots of STRING functions in the IEC library.

The
L 'Mike'
doesnt really load a STRING. It really just loads 4 CHARs into a doubleword address. Thats why it cannot be longer than 4 bytes / 4 CHARs.

In STL it is not possible to directly write
L 'hi there'
T #MyString

You can only copy STRING values that already exist, predefined in a DB.
To modify STRING values in STL will require that you write each CHAR in the STRING, and set the second byte to the actually used number of CHARs.
It is really a chore.

The bit about the STRING TEMP is because the 1st byte MUST be the max length of the STRING. And since TEMPs dont have memory or initial values, you have to do it manually in code.

If you have SCL, it is dead easy.
You can really write something like
MyString := 'Hi there' ;
MyString2 :=MyString ;
 
Just as an example, here is how you would have to load a fixed text value into a STRING:

Code:
      L     B#16#20                     // max length
      T     #str1[1]
      L     B#16#5                      // actual length
      T     #str1[2]
      L     'h'                         // 'hello'
      T     #str1[3]
      L     'e'
      T     #str1[4]
      L     'l'
      T     #str1[5]
      L     'l'
      T     #str1[6]
      L     'o'
      T     #str1[7]
 

Similar Topics

I am creating a global object in FTView SE 13. I want to have a string read from the PLC and display (in this case the tagname). So lets say...
Replies
4
Views
140
So I had an odd request from a customer for the above. I have written the logic and tested it all in one PLC with only using 7 outputs and 7...
Replies
15
Views
406
Hello Inside a FB, I´m trying to transfer a string from a DB to a IN_OUT var that was define as a UDT. The problem is that i can´t determine the...
Replies
4
Views
121
As the title says, I'm using CCW with a PV800 (and Micro850). I've made a scheduler in which a user can choose a month, day (1-31), hour (0-23)...
Replies
15
Views
494
Hello, So i managed to read the string coming from control logix and put a string display in PanelView 800. Now I am struggling to do the other...
Replies
1
Views
133
Back
Top Bottom