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,848
I have established an online connection to a machine using an S314 processor. I am using an mpi connector and simatic manager. The online...
Replies
2
Views
37
Hi everyone, i have a Siemens S7-300 Cpu 314C-2 DP with several cards of i/o and servos my laptop has TIA version 16 and 17 loaded and...
Replies
4
Views
132
Hi all, Currently having trouble getting a speed reference to write over modbus to an Omron M1... I can successfully write a run command and...
Replies
6
Views
212
Good morning fellow sea captains and wizards, I am being asked to do the above and obtain 4 values from each slave, I know about the MRX and MWX...
Replies
27
Views
561
Back
Top Bottom