S7:Local Memory/Pointer question

STL???

Member
Join Date
Sep 2005
Location
UK
Posts
879
Hi again,
I'm trying to understand whats going on in code below but i've never worked directly with Local memory and have been warned to be careful when doing so!!

One thing i'm not clear on is this part:
M001: LAR1  P##Matrix; 
L 0;
T LB [AR1,P#0.0]; // Matrix loeschen



is #Matrix used to store the result of the Compares of #IN_1 to #IN_8, but initialised first in the above snippet?

Not speaking any German doesn't help the cause to much either!!:unsure:

Thanks again!

STL

FUNCTION "Enter Program Mask" : VOID
TITLE = Programmmaske Einlesen
// PRG-MASK
NAME : PRG_MASK
VERSION : 0.0


VAR_INPUT
ERST : BOOL ; // ERST
IN_1 : BOOL ; // IN-1
IN_2 : BOOL ; // IN-2
IN_3 : BOOL ; // IN-3
IN_4 : BOOL ; // IN-4
IN_5 : BOOL ; // IN-5
IN_6 : BOOL ; // IN-6
IN_7 : BOOL ; // IN-7
IN_8 : BOOL ; // IN-8
END_VAR
VAR_TEMP
Adresse : DWORD ;
Matrix : BYTE ;
ZW_Speicher : DWORD ;
END_VAR
BEGIN
NETWORK
TITLE = Init Adressdaten

AN #ERST; // 1. FB Aufruf
JC M001; // nein, dann weiter
L 0;
T DBB 82; // Zeiger Datenablage auf 0
T DBB 1000;
M001: LAR1 P##Matrix;
L 0;
T LB [AR1,P#0.0]; // Matrix loeschen
NETWORK
TITLE =Kontrolle Anzahl Eintraege

L DBB 1000;
L 40;
>I ;
JCN ok;
CALL "STP" ;
ok: NOP 0;
NETWORK
TITLE =Matrix einlesen

A #IN_1;
= L [AR1,P#0.0];
A #IN_2;
= L [AR1,P#0.1];
A #IN_3;
= L [AR1,P#0.2];
A #IN_4;
= L [AR1,P#0.3];
A #IN_5;
= L [AR1,P#0.4];
A #IN_6;
= L [AR1,P#0.5];
A #IN_7;
= L [AR1,P#0.6];
A #IN_8;
= L [AR1,P#0.7];
NETWORK
TITLE = Maske speichern

L DBB 82; // 1. Zieladresse + Offset
SLW 3;
T #Adresse;
LAR2 ;
L LB [AR1,P#0.0]; // 83.0
T DBB [AR2,P#83.0]; // Adresse
L DBB 82;
INC 1;
T DBB 82;
NETWORK
TITLE =Abfrage 1 einlesen

L DBB 1000;
INC 1;
T DBB 1000;
SLW 4;
LAR2 ;

L P##IN_1;
T #ZW_Speicher;
LAR1 P##ZW_Speicher;
L LW [AR1,P#2.0];
T DBW [AR2,P#1000.0];
NETWORK
TITLE =Abfrage 2 einlesen

L DBB 1000;
INC 1;
T DBB 1000;
SLW 4;
LAR2 ;

L P##IN_2;
T #ZW_Speicher;
LAR1 P##ZW_Speicher;
L LW [AR1,P#2.0];
T DBW [AR2,P#1000.0];
NETWORK
TITLE =Abfrage 3 einlesen

L DBB 1000;
INC 1;
T DBB 1000;
SLW 4;
LAR2 ;

L P##IN_3;
T #ZW_Speicher;
LAR1 P##ZW_Speicher;
L LW [AR1,P#2.0];
T DBW [AR2,P#1000.0];
NETWORK
TITLE =Abfrage 4 einlesen

L DBB 1000;
INC 1;
T DBB 1000;
SLW 4;
LAR2 ;

L P##IN_4;
T #ZW_Speicher;
LAR1 P##ZW_Speicher;
L LW [AR1,P#2.0];
T DBW [AR2,P#1000.0];
NETWORK
TITLE =Abfrage 5 einlesen

L DBB 1000;
INC 1;
T DBB 1000;
SLW 4;
LAR2 ;

L P##IN_5;
T #ZW_Speicher;
LAR1 P##ZW_Speicher;
L LW [AR1,P#2.0];
T DBW [AR2,P#1000.0];
NETWORK
TITLE =Abfrage 6 einlesen

L DBB 1000;
INC 1;
T DBB 1000;
SLW 4;
LAR2 ;

L P##IN_6;
T #ZW_Speicher;
LAR1 P##ZW_Speicher;
L LW [AR1,P#2.0];
T DBW [AR2,P#1000.0];
NETWORK
TITLE =Abfrage 7 einlesen

L DBB 1000;
INC 1;
T DBB 1000;
SLW 4;
LAR2 ;

L P##IN_7;
T #ZW_Speicher;
LAR1 P##ZW_Speicher;
L LW [AR1,P#2.0];
T DBW [AR2,P#1000.0];
NETWORK
TITLE =Abfrage 8 einlesen

L DBB 1000;
INC 1;
T DBB 1000;
SLW 4;
LAR2 ;

L P##IN_8;
T #ZW_Speicher;
LAR1 P##ZW_Speicher;
L LW [AR1,P#2.0];
T DBW [AR2,P#1000.0];
END_FUNCTION



 
Yes you are correct. The initialisation to zero is redundant really as each bit of the variable #matrix is assigned later on. The only time the assignments will not be executed is if DBB1000 gets greater than 40 in which case the plc is put into stop anyway.
 
Hi Simon,
Thanks for confirming that, This FC is part of the same program as my previous thread, Funny thing is in this particular program it doesnt look like it does a great deal and nothing is executed using the DB addresses that are being pointed to!

I've been tasked with stripping out all the redundant code from this OEM (one program caters all) Project for our Maint crew.

Thanks again
 

Similar Topics

Hello Guys! Another S7 question.... I've been having som strange problems for time to time with local memory in the S7 plc's. Especially with...
Replies
28
Views
12,092
Is there a way to add a local message display to Studio 5000 View Designer? If its there, I’m not finding it. I have used them in older versions...
Replies
11
Views
395
Hi, I'm trying to export data from a DataGrid to Excel using VBA, but I'm getting an error "Object doesn't support this property or method". The...
Replies
0
Views
71
So our Powerflex 525's are set up to allow REMOTE operation from PLC through network. But if network is lost we want to be able to run in LOCAL...
Replies
5
Views
557
Migrating v8 FT View SE to v13, had to export tags because after v10 the configuration is no longer supported. Imported tags to new Tag Alarm...
Replies
1
Views
503
Back
Top Bottom