S7 code explanation

arocon

Member
Join Date
Oct 2006
Location
Dubai
Posts
171
Could anyone please explain me what is doing the following code:

// set BR =1
SET
SAVE

// check for a valid DB number
L 0
L #DB_Number
==I
JC DNE
T #DB_To_Open
// open block and wrtie what we need
OPN DB[#DB_To_Open]

// offset for pallet data
L #DB_Offset
SLW 3
LAR1
// the data
L #Data
T DBW[AR1,P#0.0]

DNE:BE

Thank you.
 
Hi I am no expert on stl but here goes my understanding, in red
Basically it checks a datablock number is not 0, opens it and stores data at an offset

SET
SAVE

Check that the parameter for the data block number is not 0
// check for a valid DB number
L 0
L #DB_Number
==I
If 0 the jump to done
JC DNE
not 0 so copy to variable DB_To_Open
T #DB_To_Open
// open block and wrtie what we need
Open the DB number from the parameter above
OPN DB[#DB_To_Open]

make a pointer to the given off set and store the information #data
// offset for pallet data
L #DB_Offset
SLW 3
LAR1
// the data
L #Data
T DBW[AR1,P#0.0]

DNE:BE
 
It transfers what is in #Data to word defined by #DB_Offset in DB defined by #DB_Number.

Example:

If DB_Number is 3, DB_Offset is 12 and data is 456. After execution, DB3.DBW12 = 456.

You need to show whole block & how it is called for more detailed analysis.
 
hi,arocon
1.force ENO:=1 for your FC or fB result.
2.DB0 means no DB existing,i.e. S7 has no DB0.
3#DB_Offset occupies byte ADRRESS for **** right 3 bit.
The right 3 bits are bit address .
In Siemens S7 world bit is from 0 to 7 .Example M1.0~M1.7 for AR1/AR2 addressing.
 

Similar Topics

Dear Experts, Need help understanding this SCL code . IF (#SimOn = 0) THEN IF (#DI_In <> #Mem) AND (#Mem1 = 0) THEN #RemTime := #Tf...
Replies
4
Views
1,577
Could anyoone explain the following S7 statement code: // table ID will be zero if none are found CALL "MinLoadingNumber"...
Replies
1
Views
1,884
in allen bradley kinetix 300 drive first E31 error shows after resting drive E11 error occurs need solution to reset E11 fault code
Replies
3
Views
93
Hello, I am trying to read a barcode scanner input using a cognex dataman 280 barcode reader, store it another string, the compare with another...
Replies
1
Views
81
Hi there, I'm new to plc programming and was wondering why I get this error code when I run my simulation for these temperature sensors? What I'm...
Replies
2
Views
87
Back
Top Bottom