Step 7 block search

Mad_Poet

Member
Join Date
Feb 2017
Location
Virginia
Posts
375
How can I do a search for a text string within a currently running PLC program?

Our machine has keypads which display what the station is currently running, and I would like to find where in the code the display is stored. I think if I reload the PLC's the displays will be blank but when running the displays get data (from the job the machine is running).

There are a LOT of blocks in the project.

MadPoet.
 
If it is V5.5, right-click your Blocks folder, and do Generate Source. Choose the Sources folder in your project to save it to, open it, and do Ctrl F for Find.

This procedure will put all your program blocks (in STL language) and data blocks in a searchable text document.
 
You dont happen to have the source code for the HMI ?

I dont think that the method that sigmadelta suggest will work.
The source code will be generated by the definitions in the offline project.

Copying DBs from online to offline and generating the source from that will also be a bit tricky.

If you dont have the source code for the HMIs, and it is a non-trivial program ("There are a LOT of blocks in the project") I would be carefull about poking around in someone else program.
I would go through all the UDTs and shared DBs to go and see if there are any STRING variables. And then try to monitor said STRINGs online to see if the content matches what the operator inputs on the touchscreen.
 
THe display may be getting the string from the PLC, but it is also fairly common to map an INT in the PLC to a string stored in the HMI. For status, it might be 0 -> Stopped, 1 -> error, 2 -> manual, 3 -> auto, etc.

In a Siemens HMI, this is called a text list.
 
@mk42.
That is true, but you will know if that is the case, because you then do not have an input-field to type a string, but a drop-down box to chose from a list predefined selections.
 
SigmaDelta> Which version of STEP 7?

I need to check that.

JesperMP> You dont happen to have the source code for the HMI ?

I think I have the source code for the PLC. (There are a lot of comments). I have the Project that I can download into the PLC's.

SigmaDelta> If it is V5.5, right-click your Blocks folder, and do Generate Source.

Am I right in thinking that this will give me the source blocks? The text strings I will be looking for are not in the source - they get into the system from a Server computer which downloads 'Jobs' into the computer which 'manages' the PLC's. This computer then (apparently) moves the text strings on down into the PLC which in turn displays the text on these little operator panels.

I'm not sure about 'UDT's . . but I'm pretty sure there are a lot of DB's.

I'll check the version number and get back.
Thanks guys.
MadPoet.
 
Example search implementation attached. FB1 will search through all the DB's in your plc (one DB per scan of OB1) for a 4 char string and report the DB number and DBB address for the string. If not found then the DB will be set to 0

You can set the max limit for the DB number searched.
 
Dear L D[AR2,P#0.0] ,
Many thanks.
I'm not sure I know how to use this . . . And, at the moment, I'd be afraid
to run it on the running machine. But I've pulled it down and I'll study it
some tomorrow.

My Step 7 version number is 5.4.
The program I'm looking at has some 219 UDT blocks, and 71 db blocks.
And some of those blocks are pretty big . . . and there seems to be
at least two different types of db blocks . . .

Thanks.
MadPoet.
 
Dear L D[AR2,P#0.0] ,
I do not have access to PLCSim.

There are a LOT of DB's . . and UDT's . . and, if Jesper is right the string might be in either one (or possibly something else altogether . . . ) I would not ask anybody to manually search through them. And then the search would be on the blocks from the project - which would tell me that I have lots of text strings but the particular string, say "Kohls", would not be in there. That gets there as part of the production run.

The Operator gave me another clue this morning. It seems 'they' changed their modes of operation a couple of months ago. And I suspect because the night shift runs one way, and the day shift runs another, and the 'main program' may not clear out the previous shifts datums the way it used to (when they both ran the same way) . . . I think I will be exploring things along those lines this afternoon - seeing what REALLY happens when the operators do this and that in different modes.

Thanks, Guys.
MadPoet.
 
How to find the access to most STRING variables.

Generate the source for all the DBs:
Save the project under a new name.
Open the LAD/FBD/STL editor.
Chose file .. Generate Source.
Specify a source file name, "UDTs"
A dialog will appear where you can select what is to be added to the source file. Select all the UDTs. Then generate the source file.
Browse to the source folder, and open the newly generated "UDTs" file.
Search for STRING. Hopefully there are not so many usage of STRING.
Make a not of all the UDTs with STRINGs.
Search for the names of these UDTs (because there may be UDTs dereived from UDTs). In the end you will know all the UDTs that have STRING declarations.

Now repeat the source generation, but this time of all the shared DBs.
In the source file of the shared DBs, search for STRING as well as the names of the UDTs with STRING declarations.

When you then know all the DBs addresses that have STRING declarations, you can investigate the x-ref for these STRING addresses.

Hopefully it wont be too much.

It is also possible that there are STRING variables that are accessed entirely via pointers, or are part of instance DBs. But that is less likely, so start with the above.
 
There are a LOT of DB's . . and UDT's . . and, if Jesper is right the string might be in either one (or possibly something else altogether . . . ) I would not ask anybody to manually search through them. And then the search would be on the blocks from the project - which would tell me that I have lots of text strings but the particular string, say "Kohls", would not be in there. That gets there as part of the production run.
MadPoet.

Here are the steps I propose:
1. Wait until the machine displays the string your are interested in. Let us know what it is.
2. Copy the DB's from online to offline.
3. Create a library and copy the DB's/UDTs from your project to the library.
4. Archive the library and post on here.
5. I will copy your DB's/UDT's into my test project and I will run my search block. No manual searching involved.
 
Dear Jesper,
It will have to wait till next week to try what you suggest. (Equipment repair needs and I have to remove a PLC card from a spare and put it back in my test computer.)

L D[AR2,P#0.0] ,
I'm not brave enough to copy the blocks 'from online to offline'.
I tried creating a library, but was unable to copy the blocks from
online into the library.

So I created a new project, I had to add an 'S7 program' . . .
And I was able to copy all the DB's into it. I think I was able to upload it
here, DBs_n__1 zip. The text to search for is "zTJF".
(Ignore the quotes - they are not part of the message.)

There were no UDT's in the Online blocks.

Many Thanks in advance.
MadPoet.
 

Similar Topics

I am having a step7 v5.4 program where the blocks are encrypted and locked. And the manufacturer is stopped the support. Is there any ways to...
Replies
2
Views
177
In TIA portal v13 where is in project file information about data block, function code block are stored ? Thanks
Replies
3
Views
1,757
Just a quick question I can't find an answer on yet. I have created my own recipe structure using a Global DB and when I came in this morning...
Replies
2
Views
2,017
Hello, I am trying to find an easy way to create data blocks in Step 7 with ~100K tags other than manually defining each tag in the LAD/STL/FDB...
Replies
8
Views
14,197
Hello All, Is there a way in Step 7 5.5 SIMATIC Manager to export a data block so that it can be imported into another project with all...
Replies
11
Views
3,724
Back
Top Bottom