Hello I wrote this piece of code to do indirect adressing for a DB using both AR1 and AR2. When I run this code in a FB for situation #Drive_No = 2,3,4 (2 or 3 or 4) the CPU goes to stop. If #Drive_No input of block is other than 2,3,4 no problem occurs.
When I use the same code in a FC no problem works correctly. What am I missing here? It would be better for me to use a FB because there are alot of IO of FB/FC which I am not sure to fill but if I have to use a FC I have to fill them all which I dont want.
Thanks very much.
The Code:
OPN "Sinamics"
L #Drive_No
JL MA
JU SFR
JU BIR
JU IKI
JU UC
JU DORT
MA: JU ATLA
SFR: JU ATLA
BIR: L P#28.0
LAR1
L P#4.0
LAR2
JU ATLA
IKI: L P#66.0
LAR1
L P#42.0
LAR2
JU ATLA
UC: L P#104.0
LAR1
L P#80.0
LAR2
JU ATLA
DORT: L P#142.0
LAR1
L P#118.0
LAR2
ATLA: NOP 0
//Drivedan okunan dataları drive numarasına göre DB1'den okuma
A DBX [AR1,P#0.0]
= #Ready_For_Switching_ON
A DBX [AR1,P#0.1]
= #Ready_For_Operation
A DBX [AR1,P#0.2]
= #Operation_Enabled
A DBX [AR1,P#0.3]
= #Fault_Present
A DBX [AR1,P#0.4]
= #No_Coasting_Active
A DBX [AR1,P#0.5]
= #No_Quick_Stop_Active
A DBX [AR1,P#9.3]
= #Controller_Enable
A DBX [AR1,P#9.4]
= #Drive_Ready
L DBD [AR1,P#10.0]
T #Position_Actual_Value
// FCnin inputlarına gelen dataları drive noya göre drive gönderme
A #OFF1
= DBX [AR2,P#0.0]
A #OFF2
= DBX [AR2,P#0.1]
A #OFF3
= DBX [AR2,P#0.2]
A #Operation_Enable
= DBX [AR2,P#0.3]
A #Reject_Traversing_Task
= DBX [AR2,P#0.4]
A #Intermediate_Stop
= DBX [AR2,P#0.5]
A #Acknowledge_Faults
= DBX [AR2,P#0.7]
A #Master_Cont_by_PLC
= DBX [AR2,P#1.2]
... goes on like that
When I use the same code in a FC no problem works correctly. What am I missing here? It would be better for me to use a FB because there are alot of IO of FB/FC which I am not sure to fill but if I have to use a FC I have to fill them all which I dont want.
Thanks very much.
The Code:
OPN "Sinamics"
L #Drive_No
JL MA
JU SFR
JU BIR
JU IKI
JU UC
JU DORT
MA: JU ATLA
SFR: JU ATLA
BIR: L P#28.0
LAR1
L P#4.0
LAR2
JU ATLA
IKI: L P#66.0
LAR1
L P#42.0
LAR2
JU ATLA
UC: L P#104.0
LAR1
L P#80.0
LAR2
JU ATLA
DORT: L P#142.0
LAR1
L P#118.0
LAR2
ATLA: NOP 0
//Drivedan okunan dataları drive numarasına göre DB1'den okuma
A DBX [AR1,P#0.0]
= #Ready_For_Switching_ON
A DBX [AR1,P#0.1]
= #Ready_For_Operation
A DBX [AR1,P#0.2]
= #Operation_Enabled
A DBX [AR1,P#0.3]
= #Fault_Present
A DBX [AR1,P#0.4]
= #No_Coasting_Active
A DBX [AR1,P#0.5]
= #No_Quick_Stop_Active
A DBX [AR1,P#9.3]
= #Controller_Enable
A DBX [AR1,P#9.4]
= #Drive_Ready
L DBD [AR1,P#10.0]
T #Position_Actual_Value
// FCnin inputlarına gelen dataları drive noya göre drive gönderme
A #OFF1
= DBX [AR2,P#0.0]
A #OFF2
= DBX [AR2,P#0.1]
A #OFF3
= DBX [AR2,P#0.2]
A #Operation_Enable
= DBX [AR2,P#0.3]
A #Reject_Traversing_Task
= DBX [AR2,P#0.4]
A #Intermediate_Stop
= DBX [AR2,P#0.5]
A #Acknowledge_Faults
= DBX [AR2,P#0.7]
A #Master_Cont_by_PLC
= DBX [AR2,P#1.2]
... goes on like that
Last edited: