S7-300 String handling

cjd1965

Lifetime Supporting Member
Join Date
Apr 2007
Location
UK
Posts
1,659
Hi
I am looking to read 2 strings of 25 characters from a DB (say DB1). Lets assume DB1 is empty apart from

'Hello This is string1'
'Hello This is string2'

I wish to write these to DB2, at slots (say 11,12 or whatever the DB usage will be)

How do I get this to work? If I go online to the DB1 it shows the initial values but the actual values are shown as ''

Do I need to use FB20.?

I have cheated and used the HMI to do this (move a consant into an HMI internal string) but would prefer to do it in the PLC

I have looked on here and the manual but is is a bit vague on string handling. I was cosidring using the concatenate function (concatenate '', 'My String 1')

Thanks
 
Your first problem is that you have only edited the initial values, not the actual values. Either "initialise" the DB, or set the offline actual values manually. Then download the DB.

With SCL you can easily manipulate strings to you hearts content.

With LAD, FBD or STL it is much harder. Specifically you just cannot write the string content in code and copy it to the desired destination.
You can copy strings from one address to another address, and BLKMOV is the way to do that.
If you want to edit strings in STL code, then you can do it character by character. But it is most cumbersome. You also have to keep track of the string length and update byte 1 of the reserved string address accordingly.
 
Hi thanks for the reply... how ridiculous it has been made so complicated.

So if I find a colleague or local integrator with SCL I could simply do something like




DB1.String1 := DB2.String1
DB2.String2 := DB2.String2

In a compiled block.. obviously beter to make it with IN and OUT parameters.

Cheers
 
When using strings in S7 I have found it better to use data type 'Char' making an array of Characters allows you to look at each character individually. This can then be manipulated within LAD, FDB and STL. O.K it's not as quick as with SCL but doesnt have the source code draw backs.

In the HMI (Only tested on Siemens OP) you can then call a 'StringChar' of how many characters you want. And also input the data as a string not as individual characters.

M.W (www.ac-sys.co.uk)
 
You cannot monitor a string in a db. Do they have to be strings or would an array of chars suffice - you can monitor chars.

As you have two strings at fixed locations then you could use the following coding method:

Code:
L DB1.DBB0
T DB2.DBB12
...etc
 
All interesting. An array of chars may do but I need to display it on an HMI so would need to play around with that to see if it would read the whole array of chars as a single string

I will experiment

L D[AR2,P#0.0], Also found your example code at this post

http://www.plctalk.net/qanda/showthread.php?t=46427

Basically what I have is a text field which represents the software versions for the PLC and HMI which are usualy just numbers but are changing to alphanumeric,, and the idea is that a DB will store the info and can be updated by programmers in future as and when changes are made.
 
So if I find a colleague or local integrator with SCL I could simply do something like

DB1.String1 := DB2.String1
DB2.String2 := DB2.String2
As long as the STRING variables are the same length, then you can easily do the same in STL, LAD or FBD. Just use BLKMOV.

What SCL can do in addition is
StringDB.String1 := 'Hi there' ;
 

Similar Topics

I feel like I'm going crazy, new to Siemens, coming from AB, and I cannot get a dang string copied in SCL. This is a S7-300, V16 PLC. I have a...
Replies
10
Views
3,495
Hi Guys. I hav an general question about data traffic between CPU and CP on K-Bus backplane. We got an issue where a vendor has an S7-300 cpu...
Replies
4
Views
2,311
I am trying to take several individual CHAR bytes and turn them into a string. The CHAR bytes are located in a DB. I am trying to figure out the...
Replies
4
Views
3,499
Dear Sir, I try to write a function use SCL to read the string from a DB and convert it to real and transfer to another DB. But the simple...
Replies
34
Views
24,998
I have a string that I need to remove six numbers out of and move to an Array. I can't seem to find anything that will work for me. I tried a...
Replies
4
Views
3,098
Back
Top Bottom