S7-300 STL array

mass89

Member
Join Date
Oct 2017
Location
England
Posts
77
Hi,
I am useless at STL and not fortunate enough to have SCL.
I am trying to do the following;
MW1 := 6
MW2 := 400
DB100.DBW[MW1] := MW2

So store value in MW2 in a dynamic location, example above would be DB100.DBW6 = 400

Many Thanks,
 
MW1 and MW2 overlap so don't use them as an example. Here's the source code for an FC that will write data to a DB


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


VAR_INPUT
  iOffsetinBytes : INT ;    
  iValue : INT ;    
  iDB : INT ;    
END_VAR
VAR_TEMP
  DataBlock : INT ;    
END_VAR
BEGIN
NETWORK
TITLE =

      L     #iOffsetinBytes; 
      SLD   3; 
      L     P#DBX 0.0; 
      +D    ; 
      LAR1  ; 
      L     #iDB; 
      T     #DataBlock; 
      OPN   DB [#DataBlock]; 
      L     #iValue; 
      T     W [AR1,P#0.0]; 


END_FUNCTION
 

Similar Topics

As a relative newcomer to the S7-300 its driving me crazy. Can anyone tell me how I simply address an array item in the form: Array[index] where...
Replies
4
Views
8,882
First off thank you in advance. Second I am very new to STL. I am trying to build a counter that has one count up and 23 count down options. Am...
Replies
6
Views
365
Hi.Can I convert the block written in stl mode below to ladder mode? L #InOctet SLD 3 L #InBit OW T...
Replies
2
Views
552
Another STL question. In the attached screen shot the line with = #sf.S01_Dryer_ON dose not have the RLO on. But if we look lower in the logic...
Replies
4
Views
1,214
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,049
Back
Top Bottom