S7 Area Error

JayD

Member
Join Date
Aug 2009
Location
Australia
Posts
53
Hi All,

I am trying to access an indexed UDT from an array of UDTs within a shared DB. I have seen an example of this done in SCL. The method used an IN_OUT UDT of a FB and it didn't have any data
assocciated to in at the call of the FB.

When I attempt to implement this in STL and load an element of the blank IN_OUT UDT I get an "Area Error when Reading". Is there an option to turn off this checking?

For background this is the code I am using within the FB to reference the indexed UDT.

Code:
L P##IN_OUT_UDT
LAR1
 
L DB_Num //Int of shared DB
T W [AR1, P#0.0] //UDT DB Number
 
L Index //Index of UDT
+ -1
L UDT_Length //Length in bytes of UDT
*I
SLD3 
L P#DBX0.0
+D
T D [AR1, P#2.0] //UDT Area Ptr

Also I don't want to implement the BLKMOV method.

Any suggestions would be appreciated.

Cheers
JD
 
...
When I attempt to implement this in STL and load an element of the blank IN_OUT UDT I get an "Area Error when Reading". Is there an option to turn off this checking?

You are attempting to access data which is outside the range of the curently open DB and you want to turn this checking off :unsure:

Create a library with a S7 program in it and copy the relevant blocks (UDT,DB,FB and a call to the FB) and post as a zipped archive. Indicate which UDT element you are attempting to access. The code you have posted is as much use as a chocolate teapot.
 
Hi,

could you post also the FB call so we can see what you have connected to the inputs. I dont know what you mean by blank.

But it looks like you are constructing a pointer. You also have to set the area type for the pointer.

M
 
I am very sorry for wasting your time - I got it to work. The error was correct and there is no need to switch off this checking. (Noob Request!)

My code was using an index of -1 and the area pointer was outside the DB, hence the error.

The call to the FB has no assignment to the IN_OUT UDT parameter. I am constructing a pointer but not an ANY pointer, there is no need to define the area type or length.

PS - Next time I'll try a bit better than a chocolate teapot.
 
Now you have said that you are constructing a (DB) pointer your code makes perfect sense and the phrase chocolate teapot does not apply - sorry.
 
The essential information you need to note is that AR2 points to the base address of the instance data. When you load AR1 with a pointer to an FB interface variable (IN, IN_OUT, OUT, STAT) you must add the offset contained in AR2 to AR1. With non multiple instances (i.e. a DB per FB call), the offset in AR2 is always zero,
 
So to permit mulit instance I would use the following code?


Code:
[/FONT]
[FONT=Arial][SIZE=2]L P##IN_OUT_UDT[/SIZE][/FONT]
[FONT=Arial]LAR1[/FONT]
[FONT=Arial]TAR2                              //add AR2 to allow this to work as multiple instance[/FONT]
[FONT=Arial]+AR1 [/FONT]
[FONT=Arial]

Thanks again for the advice!
 
I have used this in the past, however, I now use a mask and use the +D instruction as the +AR1 fails with large DBs.
I'll find an example to post.
 
Here's code:

Code:
      TAR2                              //AR2 to ACCU
      AD    DW#16#0FFFFFF               //Mask off area type to leave offset from start of instance DB
      L     P##IN_OUT_UDT               //pointer to interface variable for this instance
      +D                                //add base address for this instancebase address
      LAR1                              //Ar1 now points to absolute address of IN_OUT_UDT in instance DB
 
I have used this in the past, however, I now use a mask and use the +D instruction as the +AR1 fails with large DBs.
Could you elaborate a bit more LD? how does +AR1 instruction fail?
 

Similar Topics

Dear All, I work on a project with 1218F CPU. I have FC 163 written in SCL which process data from DB 165. In the diagnostic I got this error...
Replies
2
Views
1,108
Kindly , in Siemens PCS7 , has anyone seen and solved this problem ? " Maximum length of code area reached (max. 64 Kbytes) "
Replies
3
Views
2,269
System is an IPC547D running GRAPH in WinAC RTX. Six S7-1200 (CPU 1215C) running a little code for manual operations, but mostly running as...
Replies
16
Views
7,992
I have some error about RJ area on Regular PID code S5->S7 FUNCTION FC 30 : VOID AUTHOR: _48021 NAME: HAU_KREG // HAU:KREG VAR_INPUT...
Replies
2
Views
2,085
Hi Anyone who can explain why i get this error 8F24H Area error reading a parameter. when i am using FC50 Regards Berra
Replies
10
Views
2,825
Back
Top Bottom