rick-brinkman
Member
Hello all,
I am using in Step7 a FC that searches through a database. I am doing this with address registers. Running through the database and finding values works fine. But when the database is to big the searching takes too long (i.e. running through the loop “Lus” takes longer than the cycle time). With as result that my PLC jump into stop with error “Stop caused by time error” (event ID: 16#4568), cycle time exceeded. See my program code below:
---------------------------------------------------------------------------------
// Search DB for stamnumber
OPN #DB_NR_Stamnumbers //Open DB
LAR1 P#0.0 //Load AR1 with pointer value
L DBLG //Load Length of DataBase
Lus: T #LV_loopcount // times to run through loop
L DBW [AR1,P#0.0]
L #StamNr //Load ACCU_2 with #StamNr
==I
JC M001 // Value Found? Jump to m001
+AR1 P#2.0 // Plus an offset of 2.0
L #LV_loopcount //Function Loop does:LV_loopcount - 1
LOOP Lus // Run again through loop
JU M002 //Value not found
//Stamnumber found
M001: NOP 0
// Do here something if “stamnumber” is found
JU END
//Stamnumber NOT found
M002: NOP 0
// Do here something if “stamnumber” is NOT found
JU END
// End of function
END: NOP 0
---------------------------------------------------------------------
To solve this problem I guess I should remove the Loop and call the FC not once but every PLC cycle (i.e. Checking one DBW per cycle time). In my opinion, to accomplish that, I have to store the value that is in AR1 but I have no idea how.
Or is there a better/easier solution?
Thanks in advance!
I am using in Step7 a FC that searches through a database. I am doing this with address registers. Running through the database and finding values works fine. But when the database is to big the searching takes too long (i.e. running through the loop “Lus” takes longer than the cycle time). With as result that my PLC jump into stop with error “Stop caused by time error” (event ID: 16#4568), cycle time exceeded. See my program code below:
---------------------------------------------------------------------------------
// Search DB for stamnumber
OPN #DB_NR_Stamnumbers //Open DB
LAR1 P#0.0 //Load AR1 with pointer value
L DBLG //Load Length of DataBase
Lus: T #LV_loopcount // times to run through loop
L DBW [AR1,P#0.0]
L #StamNr //Load ACCU_2 with #StamNr
==I
JC M001 // Value Found? Jump to m001
+AR1 P#2.0 // Plus an offset of 2.0
L #LV_loopcount //Function Loop does:LV_loopcount - 1
LOOP Lus // Run again through loop
JU M002 //Value not found
//Stamnumber found
M001: NOP 0
// Do here something if “stamnumber” is found
JU END
//Stamnumber NOT found
M002: NOP 0
// Do here something if “stamnumber” is NOT found
JU END
// End of function
END: NOP 0
---------------------------------------------------------------------
To solve this problem I guess I should remove the Loop and call the FC not once but every PLC cycle (i.e. Checking one DBW per cycle time). In my opinion, to accomplish that, I have to store the value that is in AR1 but I have no idea how.
Or is there a better/easier solution?
Thanks in advance!