Siemens S7: STL - LAR1 P#Stat.Stat.Stat

Cobonweb

Member
Join Date
Jun 2009
Location
Holland
Posts
17
Hello,

I have a question about something that has been bugging me for a while:

For indirect addressing data in an FB stat(using pointers), you can only point to the top-struct. Example:

I can do:
LAR1 P##STAT

However I cannot do:
LAR1 P##STAT.STAT


I wonder (without using hardcoded offsets or FC's using POINTER inputs) if there is a standard way to do this?
 
For SCL you can write:

DB1.DX[index1,index2] := TRUE;
M[index1,index2] := M0.0;

The index should be int format. The same code generated by my compiler in STL is:

SET
SAVE
= L 0.1
L #index2
ITD
L L#0
+D
JO I007
JU I008
I007: CLR
= L 0.1
I008: L L#8
*D
JO I009
JU I00a
I009: CLR
= L 0.1
I00a: L #index3
ITD
+D
JO I00b
JU I00c
I00b: CLR
= L 0.1
I00c: L L#0
-D
JO I00d
JU I00e
I00d: CLR
= L 0.1
I00e: L L#1
*D
JO I00f
JU I010
I00f: CLR
= L 0.1
I010: CLR
A M 0.0
LAR1
= M [AR1,P#0.0]
A L 0.1
SAVE
BE

So I dont think there would be an esay way but might be...

NOTE: The index must be >=0 or if you dont have PROG_ERR (OB121) your CPU will go to stop
 
You have to use an FC with pointer parameters, here's my implementation of:

LAR1 p#Data.ix
LAR1 p#Data.ik

Code:
      LAR1  P##Data
      CALL  FC     3
       pBaseData:=#Data
       pSubData :=#Data.ix


      LAR1  P##Data
      CALL  FC     3
       pBaseData:=#Data
       pSubData :=#Data.iK

Here's the code for FC3

Code:
FUNCTION FC 3 : VOID
TITLE =
VERSION : 0.1


VAR_INPUT
  pBaseData : POINTER ;    
  pSubData : POINTER ;    
END_VAR
VAR_TEMP
  dwData : DWORD ;    
END_VAR
BEGIN
NETWORK
TITLE =

      TAR1  #dwData; 
      L     P##pBaseData; 
      LAR1  ; 
      L     P##pSubData; 
      LAR2  ; 
      L     D [AR2,P#2.0]; 
      L     D [AR1,P#2.0]; 
      -D    ; 
      L     #dwData; 
      +D    ; 
      LAR1  ; 
END_FUNCTION
 
Thanks for the replies!

Yeah, at the moment I already use an FC with pointer type input. I was just wondering if there was an easier (and non-FC dependant) way to do it.
 

Similar Topics

Hi Siemens Experts, I am hoping someone can shed some light on my issue. I have uploaded the code from a S7-300 (317-2PN/DP) using Step 7...
Replies
9
Views
666
I'm having trouble trying to convert this code to ladder, anyone able to help me? A M4.0 A M4.1 A M117.0 AN M17.7 A ( A I38.6 AN I3.7 O ( A M4.5...
Replies
8
Views
1,206
Hello, I am still new to STL. But from what I understand is the JC mnemonic should jump if RLO = 1. If we review both pictures the M0bf RLO = 1...
Replies
5
Views
1,051
Hello, I am working on a project to upgrade some old S5-100U processors. The programs are all uploaded and I don't have descriptors...ugh. Be that...
Replies
4
Views
1,163
I really struggle with STL in Siemens Step 7 Classic. I'll learn chunks, but then I don't use it enough to retain and build on the knowledge. When...
Replies
17
Views
3,212
Back
Top Bottom