there is another problem when I use the Function below:
there are 100 step in the DB200 there are 12 items for each step:
Step 1------------
Item 1 is a DB200.DBD0
Item 2 is a DB200.DBD4
Item 3 is a DB200.DBD8
Item 4 is a DB200.DBD12
Item 5 is a DB200.DBD16
Item 6 is a DB200.DBW20
Item 7 is a DB200.DBW22
Item 8 is a DB200.DBW24
Item 9 is a DB200.DBW26
Item 10 is a DB200.DBW28
Item 11 is a DB200.DBW30
Item 12 is a DB200.DBW32
When I use the Function (which is below) , it's fine from Item 1 to Item 5
however, when I put the item 6 into the "item no"and enter a value (20) into the "rFillValue",
Item no = 6
rFillValue = 20
the DB200.DBW20 should become 20,
however the value ( 20 ) went into Item 7 (DB200.DBW22 become 20 )
So what can I need to fix the code below ??
Thank you~~~
----------------------------------------------------------------------
However I wanna to ask about:
If I receive a initial step figure 10 and end step figure 20 from a HMI,
how can I point these step into my DB200's step (100 steps in DB200)
I got 12 different items in each step, step one is from DB200.DBD0 TO DB200.DBW30
I also will get the Item No (1~12) from HMI, when operator enter 1 that means the first Item which will be at DB200.DBD0,DB200.DBD32...DB200.DBD3200
Item 2 is in DB200.DBD4, DB200.DBD36..... and so on
then the operator will enter the Initial step and end step, if the item is 1, from initial step 10 to end step 20, then the fillvalue will automatic put the value into DB address
Because the HMI input is a decimal value ( like 1~100), this won't automaticlly put the value into the DB address,
So Do I need to define the initial step and end step to point to the DB address
also the Item no (1~12)
it's something like this :
when item no = 2;
initial step =1
end step=10
move rFillValue into DB200.DBD4, DB200.DBD36....DB200.DBD324
if item no= 1;
move rFillValue into DBD200.DBD0, DB200.DBD32....DB200.320
....
how can I do the Above code
FUNCTION FC 3 : VOID
TITLE =
VERSION : 0.1
VAR_INPUT
rFillValue : REAL ;
iStartStep : INT ;
iEndStep : INT ;
iItemNo : INT ;
iBytesBetweenEntries : INT ;
dbDB : BLOCK_DB ;
END_VAR
VAR_TEMP
iDBNumber : INT ;
iLoopCount : INT ;
dwOffset : DWORD ;
END_VAR
BEGIN
NETWORK
TITLE =
L #iBytesBetweenEntries;
SLD 3;
T #dwOffset;
OPN #dbDB;
LAR1 P#DBX 0.0;
L #iStartStep;
+ -1;
L #dwOffset;
*D ;
+AR1 ;
L #iItemNo; //make item zero based
+ -1;
SLD 5;
+AR1 ;
L #iEndStep;
L #iStartStep;
-I ;
+ 1;
L: T #iLoopCount;
L #rFillValue;
T D [AR1,P#0.0];
L #dwOffset;
+AR1 ;
L #iLoopCount;
LOOP L;
SET ;
SAVE ;
END_FUNCTION
there are 100 step in the DB200 there are 12 items for each step:
Step 1------------
Item 1 is a DB200.DBD0
Item 2 is a DB200.DBD4
Item 3 is a DB200.DBD8
Item 4 is a DB200.DBD12
Item 5 is a DB200.DBD16
Item 6 is a DB200.DBW20
Item 7 is a DB200.DBW22
Item 8 is a DB200.DBW24
Item 9 is a DB200.DBW26
Item 10 is a DB200.DBW28
Item 11 is a DB200.DBW30
Item 12 is a DB200.DBW32
When I use the Function (which is below) , it's fine from Item 1 to Item 5
however, when I put the item 6 into the "item no"and enter a value (20) into the "rFillValue",
Item no = 6
rFillValue = 20
the DB200.DBW20 should become 20,
however the value ( 20 ) went into Item 7 (DB200.DBW22 become 20 )
So what can I need to fix the code below ??
Thank you~~~
----------------------------------------------------------------------
However I wanna to ask about:
If I receive a initial step figure 10 and end step figure 20 from a HMI,
how can I point these step into my DB200's step (100 steps in DB200)
I got 12 different items in each step, step one is from DB200.DBD0 TO DB200.DBW30
I also will get the Item No (1~12) from HMI, when operator enter 1 that means the first Item which will be at DB200.DBD0,DB200.DBD32...DB200.DBD3200
Item 2 is in DB200.DBD4, DB200.DBD36..... and so on
then the operator will enter the Initial step and end step, if the item is 1, from initial step 10 to end step 20, then the fillvalue will automatic put the value into DB address
Because the HMI input is a decimal value ( like 1~100), this won't automaticlly put the value into the DB address,
So Do I need to define the initial step and end step to point to the DB address
also the Item no (1~12)
it's something like this :
when item no = 2;
initial step =1
end step=10
move rFillValue into DB200.DBD4, DB200.DBD36....DB200.DBD324
if item no= 1;
move rFillValue into DBD200.DBD0, DB200.DBD32....DB200.320
....
how can I do the Above code
FUNCTION FC 3 : VOID
TITLE =
VERSION : 0.1
VAR_INPUT
rFillValue : REAL ;
iStartStep : INT ;
iEndStep : INT ;
iItemNo : INT ;
iBytesBetweenEntries : INT ;
dbDB : BLOCK_DB ;
END_VAR
VAR_TEMP
iDBNumber : INT ;
iLoopCount : INT ;
dwOffset : DWORD ;
END_VAR
BEGIN
NETWORK
TITLE =
L #iBytesBetweenEntries;
SLD 3;
T #dwOffset;
OPN #dbDB;
LAR1 P#DBX 0.0;
L #iStartStep;
+ -1;
L #dwOffset;
*D ;
+AR1 ;
L #iItemNo; //make item zero based
+ -1;
SLD 5;
+AR1 ;
L #iEndStep;
L #iStartStep;
-I ;
+ 1;
L: T #iLoopCount;
L #rFillValue;
T D [AR1,P#0.0];
L #dwOffset;
+AR1 ;
L #iLoopCount;
LOOP L;
SET ;
SAVE ;
END_FUNCTION