Prabhakar Jadhav

How to increase STRING length in Data Block in S7 300 PLC program

6 posts in this topic

Hello Guys,
I have old Siemens program. In that DB952 is used for 2D barcode scanner data. Previously Barcode was only 10 letters but as per Customer requirement new Barcode is 12 letters. Now if we scan new Barcode with existing program it gives #####error on HMI. When I checked it I found in PLC program in DB952 STRING for barcode scanner data is defined as [10]. So now I want to increase that STRING Length so that I can scan my new Barcode with 12 letters without any error.
Please help me.....
Please see attached picture of my DB952 where STRING is declared.

STRING.jpg

Share this post


Link to post
Share on other sites

Hi Prabhakar

have you tried changing string[10] to string[12] in the data block? I know in TIA portal it's editable.

Share this post


Link to post
Share on other sites

You should be able to directly edit the length of the "SerialNumber" string in the data block (DB). Please keep in mind that if you change the length of the string you might find it necessary to change a step or offset (pointer) value elsewhere in the logic because the MCR string will no longer begin at 12.0.

Share this post


Link to post
Share on other sites

So it means I need to change DB address for MCR?  Is it okay If I give address 18 to MCR?  then will it work or not?

Share this post


Link to post
Share on other sites
16 hours ago, pop29684 said:

You should be able to directly edit the length of the "SerialNumber" string in the data block (DB). Please keep in mind that if you change the length of the string you might find it necessary to change a step or offset (pointer) value elsewhere in the logic because the MCR string will no longer begin at 12.0.

So it means I need to change DB address for MCR?  Is it okay If I give address 18 to MCR?  then will it work or not?

Share this post


Link to post
Share on other sites

Currently in the data block shown, "SerialNumber" is type "string" with a specified length of [10] and "MCR" is type "string" with a specified length of [10]. The address of "SerialNumber" is 0. The address of "MCR" is 12.

If you wish to increase the length of the "SerialNumber" string to 12 characters then edit the length in the "Type" column: String[12]. When you do this, the address of "MCR" will change automatically. It will no longer begin at address 12. It will begin at address 14. This is important because you will have to trace this address throughout the entire program logic and verify that the logic queries the correct address for "MCR" (direct addressing).

You also need to verify that if any pointers are used in the current program to point to "MCR", these pointer offsets will need to be changed to reflect the new address of "MCR".

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now