This PLC code can handle any number of recipes with any number of ingredients, limited only by the PLC memory. It allows the user to enter the recipe number to work with using a C-More panel.
It works just fine from PLC 05 to PLC 260. After performing quite a testing on the code I notice the following:
Once you enter 10 recipes, for example, and decide to go back to recipe #3 and change the values on each of the ingredient then and push “SAVE”, the next recipe that follows, in this case, recipe #4 all the ingredient values changes to “0”. I have no idea why it does that.
Can anyone see where the BUG in this code is?
Here is the code:
It works just fine from PLC 05 to PLC 260. After performing quite a testing on the code I notice the following:
Once you enter 10 recipes, for example, and decide to go back to recipe #3 and change the values on each of the ingredient then and push “SAVE”, the next recipe that follows, in this case, recipe #4 all the ingredient values changes to “0”. I have no idea why it does that.
Can anyone see where the BUG in this code is?
Here is the code:
PLC 260
// Rung 1
// Address 0
#BEGIN COMMENT
""
"Recipe data area start: V10000"
"Notepad area start: V4000"
"Process variable area start: V3500"
""
""
#END
STR C1
OR X1
GTS K3
// Rung 2
// Address 4
STR C0
OR X0
GTS K1
// Rung 3
// Address 8
STR C2
OR X2
GTS K2
// Rung 4
// Address 12
END
// Rung 5
// Address 13
#BEGIN COMMENT
""
"Transfer data from Recipe area to Notepad"
""
#END
SBR K1
// Rung 6
// Address 15
#BEGIN COMMENT
"Load recipe area pointer and offset value"
"Initialize notepad pointer to beginning of area"
#END
STR SP1
LD V1402
SUBD K1
MUL V1401
BIN
OUT V1403
LDA O10000
ADDB V1403
OUT V1400
LDA O4000
OUT V1405
// Rung 7
// Address 27
STR SP1
FOR V1401
// Rung 8
// Address 30
STR SP1
LD P1400
OUT P1405
INCB V1400
INCB V1405
// Rung 9
// Address 37
NEXT
// Rung 10
// Address 38
RT
// Rung 11
// Address 39
#BEGIN COMMENT
""
"Transfer data from Recipe area to Process area"
""
#END
SBR K2
// Rung 12
// Address 41
#BEGIN COMMENT
"Load recipe area pointer and offset value"
"Initialize process area pointer to beginning of area"
#END
STR SP1
LD V1402
SUBD K1
MUL V1401
BIN
OUT V1403
LDA O10000
ADDB V1403
OUT V1400
LDA O3500
OUT V1406
// Rung 13
// Address 53
STR SP1
FOR V1401
// Rung 14
// Address 56
STR SP1
LD P1400
OUT P1406
INCB V1400
INCB V1406
// Rung 15
// Address 63
NEXT
// Rung 16
// Address 64
RT
// Rung 17
// Address 65
SBR K3
// Rung 18
// Address 67
#BEGIN COMMENT
""
"Write recipe from notepad to recipe data"
""
""
#END
STR SP1
LD V1402
SUBD K1
MUL V1401
BIN
OUT V1403
LDA O10000
OUT V1400
ADDB V1403
OUT V1400
LD Ka
LDA O4000
MOV P1400
// Rung 19
// Address 82
RT
// Rung 20
// Address 83
NOP
#BEGIN ELEMENT_DOC
"C0","Data to NPad","",""
"C1","NPad to Data","",""
"C2","Data to Process","RUN","RUN THIS RECIPE"
"C4","Clear","",""
"C777","DUMMY RELAY","",""
"V1400","Pointer Location","",""
"V1401","#RECIPE INGREDIE","","The number of ingredients in the recipes"
"V1402","RECIPE NUMBER","C-MORE","Selected Recipe Number to:Run, Create or Edit"
"V1403","Recipe Offset","",""
"V1405","NotePad Pointer","",""
"V3500","Process Recipe","",""
"V4000","R_BRAKE PSI","ANALOG OUTPUT","RECIPE:SIGNAL TO VFD TO CONTROL MOTOR FREQUENCY"
"V4001","R_WINDING SPEED","ANALOG OUTPUT","RECIPE:SIGNAL TO VFD TO CONTROL MOTOR FREQUENCY"
"V4002","R_WINDING TURNS","PROXIMITY","RECIPE:TURNS TO FINISH A WINDING JOB"
"V4003","R_CARRIAGE SPEED","STEP MOTOR","RECIPE:"
"V4004","R_CARRIAGE STROK","STEP MOTOR","RECIPE:"
"V4005","NotePad_7","",""
"V4006","NotePad_8","",""
"V4007","NotePad_9","",""
"V4010","NotePad_10","",""
"V5000","Notepad","",""
"V10000","Recipe Data Area","",""
#END