manmeetvirdi
Member
Hi there
Iam unable to understand as to why PLC gives "Area Length error when reading" if I add "A#call_fwd_I" at the very end of the block.
What on?
regards
Iam unable to understand as to why PLC gives "Area Length error when reading" if I add "A#call_fwd_I" at the very end of the block.
Code:
FUNCTION_BLOCK FB 100
TITLE =
//1)check if station is enabled.
//2)if enabled then wait for the demand of that station.
//3)iF demand of all the active stations comes then generate the sequence
//number orderly.
VERSION : 0.1
VAR_INPUT
stn1_ena_hmi : BOOL ;
stn2_ena_hmi : BOOL ;
stn3_ena_hmi : BOOL ;
stn4_ena_hmi : BOOL ;
END_VAR
VAR_IN_OUT
stn4_call_I : BOOL ;
stn3_call_I : BOOL ;
stn2_call_I : BOOL ;
stn1_call_I : BOOL ;
call_fwd_I : BOOL ;
END_VAR
VAR
stn1_active : BOOL ;
stn2_active : BOOL ;
stn3_Active : BOOL ;
stn4_active : BOOL ;
call_fwd : BOOL ;
fp_st1 : BOOL ;
fp_st2 : BOOL ;
fp_st3 : BOOL ;
fp_st4 : BOOL ;
ena_inc : INT ;
fn_st1 : BOOL ;
fn_st2 : BOOL ;
fn_st3 : BOOL ;
fn_st4 : BOOL ;
fwd_demand : INT ;
fp_st1_f : BOOL ;
fp_st2_f : BOOL ;
fp_st3_f : BOOL ;
fp_st4_f : BOOL ;
fn_st1_f : BOOL ;
fn_st2_f : BOOL ;
fn_st3_f : BOOL ;
fn_st4_f : BOOL ;
stn4 : INT ;
stn3 : INT ;
stn2 : INT ;
stn1 : INT ;
fp_reset : BOOL ;
END_VAR
VAR_TEMP
count : INT ;
count1 : INT ;
END_VAR
BEGIN
NETWORK
TITLE =to know number of the active stuffing station
//increment the counter
A #stn1_ena_hmi;
FP #fp_st1;
JCN st2;
L #ena_inc;
L 1;
+I ;
T #ena_inc;
st2: A #stn2_ena_hmi;
FP #fp_st2;
JCN st3;
L #ena_inc;
L 1;
+I ;
T #ena_inc;
st3: A #stn3_ena_hmi;
FP #fp_st3;
JCN st4;
L #ena_inc;
L 1;
+I ;
T #ena_inc;
st4: A #stn4_ena_hmi;
FP #fp_st4;
JCN end1;
L #ena_inc;
L 1;
+I ;
T #ena_inc;
end1: NOP 0;
//decrement the counter
A #stn1_ena_hmi;
FN #fn_st1;
JCN st2n;
L #ena_inc;
L -1;
+I ;
T #ena_inc;
st2n: A #stn2_ena_hmi;
FN #fn_st2;
JCN st3n;
L #ena_inc;
L -1;
+I ;
T #ena_inc;
st3n: A #stn3_ena_hmi;
FN #fn_st3;
JCN st4n;
L #ena_inc;
L -1;
+I ;
T #ena_inc;
st4n: A #stn4_ena_hmi;
FN #fn_st4;
JCN end2;
L #ena_inc;
L -1;
+I ;
T #ena_inc;
end2: NOP 0;
NETWORK
TITLE =to know number of the call forward demands
//increment the counter
A #stn4_ena_hmi;
A #stn4_call_I;
FP #fp_st1_f;
JCN st2f;
L #fwd_demand;
L 1;
+I ;
T #fwd_demand;
st2f: A #stn3_call_I;
A #stn3_ena_hmi;
FP #fp_st2_f;
JCN st3f;
L #fwd_demand;
L 1;
+I ;
T #fwd_demand;
st3f: A #stn2_call_I;
A #stn2_ena_hmi;
FP #fp_st3_f;
JCN st4f;
L #fwd_demand;
L 1;
+I ;
T #fwd_demand;
st4f: A #stn1_call_I;
A #stn1_ena_hmi;
FP #fp_st4_f;
JCN end3;
L #fwd_demand;
L 1;
+I ;
T #fwd_demand;
end3: NOP 0;
//decrement the counter
A #stn4_call_I;
A #stn4_ena_hmi;
FN #fn_st1_f;
JCN st2r;
L #fwd_demand;
L -1;
+I ;
T #fwd_demand;
st2r: A #stn3_call_I;
A #stn3_ena_hmi;
FN #fn_st2_f;
JCN st3r;
L #fwd_demand;
L -1;
+I ;
T #fwd_demand;
st3r: A #stn2_call_I;
A #stn2_ena_hmi;
FN #fn_st3_f;
JCN st4r;
L #fwd_demand;
L -1;
+I ;
T #fwd_demand;
st4r: A #stn1_call_I;
A #stn1_ena_hmi;
FN #fn_st4_f;
JCN end4;
L #fwd_demand;
L -1;
+I ;
T #fwd_demand;
end4: NOP 0;
NETWORK
TITLE =
//to check is number of active stations are equal to call fwd demand
O( ;
L #fwd_demand;
L 0;
==I ;
) ;
O #call_fwd;
JC end5;
L #fwd_demand;
L #ena_inc;
==I ;
JCN end5;
S #call_fwd_I;
end5: NOP 0;
////reset the set bit after the acknowledgement is received
A #call_fwd_I;
FN #fp_reset;
JCN end6;
R #call_fwd;
R #stn1_call_I;
R #stn2_call_I;
R #stn3_call_I;
R #stn4_call_I;
L 0;
T #stn4;
T #stn3;
T #stn2;
T #stn1;
end6: NOP 0;
NETWORK
TITLE =
//once the call_fwd is set now name the stations according to priority basis
A #call_fwd_I;
AN #call_fwd;
JCN fin;
SET ;
S #call_fwd;
LAR1 P##stn4_call_I;
LAR2 P##stn4;
L 5;
T #count1;
L 4;
c2: T #count;
A [AR1,P#0.0];
JCN c1;
L #count1;
L #count;
-I ;
T W [AR2,P#0.0];
JU c3;
c1: L #count1;
L -1;
+I ;
T #count1;
c3: +AR1 P#0.1;
+AR2 P#2.0;
L #count;
LOOP c2;
fin: NOP 0;
[COLOR=Red] A #call_fwd_I[/COLOR];
END_FUNCTION_BLOCK
regards