Siemens S7 indexing db's

CharlesM

Member
Join Date
Aug 2005
Location
Arkansas
Posts
1,129
I have a new project that I am working on that is a little different than what I normally do. The machine has 16 stations and the part moves through the machine from station to station. At each station I am doing something to the part or checking the part. So when done each part will have some data collected from each station. I am thinking of doing a UDT that will have all the data that I collect for each part then make an array of 16 for each station. I see the part starting at the top of the array and moving down taking the data with it. Is there an easy way to index the data down the DB? I know I can do it with a bunch of move blocks but there should be another way to do it. When the part is at the end of the cycle I want to log all the data to a file and reset all values. I can do the logs I am just not sure how to index all the values.

Suggestions
 
Normally you don't move the data

In this case you don't have much memory to move so a BLKMOV would work. If you have lots of data to move you use a circular queue where the beginning and end of the queue is accessed using indexes. This is more efficient but harder to debug so there must be a real need to use a circular queue.

If you decide to go the circular queue route then I would write FCs that enter, access and remove data from the queue so once these FCs work you can access the data using these FCs.
 
Here is some SCL code I mixed together in a hurry,
The only what is missing is adding values to each station, and the reading of the values from the last station.
The station values are indexed one position by the variable "Stations".biPushStations.

Code:
TYPE "UDT_StationData"
    STRUCT
    bi00, bi01 : BOOL ;
    i00, i01: INT ;
    r00, r01: REAL ;
    END_STRUCT
END_TYPE

DATA_BLOCK "Stations"
    STRUCT
    biPushStations : BOOL ;  
    defaultData : UDT_stationData ;  
    arData : ARRAY[1..16] OF UDT_StationData ;
    END_STRUCT
BEGIN
    defaultData.bi00 := FALSE ;
    defaultData.bi01 := TRUE ;
    defaultData.i00 := 1 ;
    defaultData.i01 := 0 ;
    defaultData.r00 := 1.0 ;
    defaultData.r01 := 0.0 ;
END_DATA_BLOCK

FUNCTION "FC_Update" : VOID

VAR_TEMP
    i : INT ;
END_VAR

IF "Stations".biPushStations THEN
    FOR i := 16 TO 2 BY -1 DO
        "Stations".arData[i] := "Stations".arData[i-1] ;
    END_FOR ;
    "Stations".arData[1] := "Stations".defaultData ;
    "Stations".biPushStations := FALSE ;    
END_IF ;

END_FUNCTION
 
Allocate a DB for each station. When at a particular station, enter data it's DB. No need to move data.
 
Thanks for the suggestions. I like what Jesper has. I do have SCL so that will work. Making a DB for each staion sounds good however if you don't move the data then you must change where you put the data.
 

Similar Topics

Hi guys! Imagine you got taks someting like this: You got 6 motors and under some conditions you have to start one of them. That "one of them" has...
Replies
19
Views
5,891
HI everyone, i am new to Siemens plc programming and i am in need of some help. yesterday we had an S7-1200 CPU 1214C fail to turn on an output to...
Replies
4
Views
52
Hi PLC people, think about this scenario: The PLC is somehow connected to the same network with the facilities` network. Then someone connects to...
Replies
2
Views
33
Hello everyone, I've had this issue for the last 2 days where I try to assign the profisafe address to an IO block (6ES7 146-6FF00-0AB0) but when...
Replies
5
Views
139
Hello, good morning, I have been having two problems with the Tia Portal software. The first is that I have installed it on my computer and...
Replies
5
Views
171
Back
Top Bottom