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
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
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.
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.