S7 AR1 AR2 Indirect Adressing Problem

erdemsvri

Member
Join Date
Jul 2009
Location
Germany
Posts
172
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
 
Last edited:
In function blocks AR2 is used to access the FB's interface variables (IN,OUT, IN_OUT,and STAT). If you modify AR2 you cannot refer to an interface variable (because AR2 is now not pointing to the instance data of the FB)

One alternative in your example is to create a dwTemp and use that instead of AR2, then just before you copy the OFF1 status etc to the DB load the dwTemp into AR1 and use AR1 instead of AR2.
 
Thanks for your answer. I was guessing something like this...
I changed the code according to your advice and it worked thanks.
The cases SFR and MA are not supposed to change the ARs.
 
Sorry forgot to add I also changed the code that in cases SFR and MA I jump staight to the end of the block so no problem... Thanks
 

Similar Topics

I am looking for some advice on this FC I just wrote. I have trace numbers that are constantly moved and want to verify that they match. They are...
Replies
7
Views
5,098
Hi, last week I posted a thread about indirect addressing http://www.plctalk.net/qanda/showthread.php?t=17023. I still don't know some things...
Replies
5
Views
6,039
I have a word in some DB which I want to load to AR1 and use as a pointer. In order to do this I need to write L DBxy.DBW xy SLD 3 LAR1 I...
Replies
3
Views
527
I am checking codes for transferring a double word in an array based on an index. STL codes are mostly ended with DBD[AR1, P#0,0] or D[AR1...
Replies
1
Views
2,312
Back
Top Bottom