Copying Strings in Siemens S7 FB

IanRobo75

Member
Join Date
Jan 2012
Location
Christchurch
Posts
15
I have a Function Block, FB10, with IN_OUT variables of type string called MyString1 and MyString2.

I want to copy MyString1 to MyString2 and then delete(wipe) MyString1. BLKMOV doesn't like strings so how is this done?
 
I take it you tried SFC20 BLKMOV.

Are your strings in a DB? Are they the same length?

What error do you get? How do you know it didnt work

Sorry for all the questions but it may help to get to the answer
 
Last edited:
Yes SFC20 BLKMOV doesn't accept Strings as valid inputs/outputs, I guess because strings are really arrays of characters (well arrays of character codes anyway).

The strings are in instance DBs and my FB is called more than once.
Actually it will be a pallet station FB called for each pallet conveyor, the relevant info passed in and written out. One part of that block will include copying a string from the previous station to this station as the pallet arrives. For simplicity here I called them MyString1 and MyString 2. So I cannot deal with the DB directly since it will be different depending on which instance is calling it.

The string are both a known fixed length.

"What error do you get?" - It won't accept #mystring1 as input to SFC20.

I'm afraid I come from the ControlLogix world where I would just use the COP or CPS functions which like simple and complex data types and structures.

Maybe I need to point to the start address of the source and destination strings and copy a number of bytes. I'm not sure how Siemens works in this regard.
 
Hi See attached. Have you named your DB? If you have just address it as dbname.string1

string1.png string2.png
 
Just read more... You will have a DB for each instance FB i take it to keep track of your string data so simply use the station1.string2 and move into station1.string1.
String length is important... make sure they are the same.
 
Remember that the BLKMOV will be in my function block FC10 and I cannot look at "dbname.string1" because inside the block I don't know what "dbname" it is, the block being called multiple times for different pallet conveyors.

see attached for FC10, where #mystring1 is invalid.

FB10.JPG
 
SFC20 will accept string variables as parameters, but not in_out parameters of a FB/FC that are of type string as the string address is passed, not the string contents. You will have to determine the absolute addresses of the strings and then either build your own Anypointers to pass to SFC20, or, copy the string contents byte by byte in a loop. The example below uses the latter method.

sp1.jpg
 
Last edited:
thanks again guys...

i get lot of things in this forum, i download the code and copy-paste with small changing to suit my requirement.And it works, thanks to LD [AR2,P#0.0]

regards
bin mulyadin
 

Similar Topics

Hiya, For a machine im using a recipe that has 20 lines. Each line contains a free enter field for the customer to enter whatever into (String)...
Replies
3
Views
6,587
Cant use a move command, so how does one move as string is rslogix 500. I cant seem to find and string related commands for copying.. I can...
Replies
6
Views
12,552
I'm not super familiar with the Micrologix line of processors, but I am pretty familiar with RSLogix 500. I'm trying to simply copy a string to...
Replies
4
Views
310
Hi All, I am looking to copy and paste a routine. I know this has to be done offline. My question is, when I go back online, these tags are...
Replies
6
Views
564
Hello everyone, friends. I need help with something related to SCL. In a FB, I need to copy the value in the DB to the DB at another address. I...
Replies
3
Views
1,388
Back
Top Bottom