step 7

harrydeharry

Member
Join Date
May 2008
Location
Delhi
Posts
237
I have 100 inputs and want to plce them into 100 words and at every new puls i want to shift their data. what is the best and short way . please help. I m using 318-2dp step7
 
More details....

Are the inputs sequential from say I0.0 ?

Are the words MW or DBW and are they sequential ?

Assuming yes to both of the above, source code below assuming the data is stored in DB99
Call the block only when you want to perform the shifting.

Code:
FUNCTION FC 3 : VOID
TITLE =
VERSION : 0.1


VAR_TEMP
  iLoopCount : INT ;    
END_VAR
BEGIN
NETWORK
TITLE =

      LAR1  P#I 0.0; //start of inputs
      LAR2  P#DBX 0.0; //start of data words
      OPN   DB    99; 
      L     100; 
L:    T     #iLoopCount; 
      L     W [AR2,P#0.0]; 
      SLW   1; 
      T     W [AR2,P#0.0]; 
      A      [AR1,P#0.0]; 
      =      [AR2,P#0.0]; 
      +AR1  P#0.1; 
      +AR2  P#2.0; 
      L     #iLoopCount; 
      LOOP  L; 

END_FUNCTION
 
Last edited:
I think i could not clear my probelm perfactly.
Situation is I have a four bit data which is coming after every 3 sec so I want to save the last 100 results into a db and want to show them on wincc.
 
Code:
FUNCTION FC 100 : VOID
TITLE = 
VERSION : 0.1

VAR_INPUT
    bLaddr : BYTE ;
    dbDest : BLOCK_DB ;
END_VAR
    
VAR_TEMP
      iLoopCount : INT;   
END_VAR

BEGIN
NETWORK
TITLE =
(*
Name: FC100
Function: First move data in buffer data block dbDest one byte up
discarding 100th (last) value then move four bits of data located
at byte bLaddr to buffer data block dbDest lowest byte.
*)

//Move old data one up, discard last data.
    LAR1 P#DBX95.0;
    OPN dbDest;
    L 25;
L:  T #iLoopCount;
    L DBD[AR1,P#0.0];
    T DBD[AR1,P#1.0];
    TAR1;
    L P#4.0;
    -D;
    LAR1;
    L #iLoopCount;
    LOOP L;

//Move new value to buffer
    L #bLaddr;
    L B#16#000F; //data assumed to be four lowest bits
    AW;
    T DBB 0;

    SET; //Set ENO
    SAVE;

END_FUNCTION

Trigger for trigging once in three second you need to do yourself outside this function.
 

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
132
Good Morning, Hoping someone with some Siemens experience can give me a hand with this one. Customer has a S7-200 cpu, which has a 6GK7...
Replies
0
Views
215
HI! HOW COULD I OBTAIN THE NAMES OF THE STEPS OF A ROUTINE IN SFC LANGUAGE IN STUDIO5000? Or is there a system variable that gives me those...
Replies
0
Views
333
I'm just trying to figure out the right method of adding a DO card to an existing rack. It's not the *next* open slot, but I have to move the AO...
Replies
5
Views
528
Hi Siemens Experts, I am hoping someone can shed some light on my issue. I have uploaded the code from a S7-300 (317-2PN/DP) using Step 7...
Replies
9
Views
593
Back
Top Bottom