indirect adress problem

Juanolo

Member
Join Date
Nov 2009
Location
Valencia
Posts
5
Hello, im new using s7-300 and i want to do an indirect adressing:

program in AWL that reads its DB1 content through indirect adressing. This suppose that in the DB is logged contents into 10 words of a table and you want access to any position in that table by EB124 with a 1 sec pulse, and that AB124 is represents the contents of the table.

First i need to Open DB1 by OPN DB1 no?
then load ar1 with LAR1 P#DB1.DBW 0 an then i dont know how to continue with it...

thx for u helping

regards
 
Here's the source code using two methods....(Where's Sapin ?)

Code:
FUNCTION FC 1 : VOID
TITLE =L DB1[EB1234] assume zero based table i.e. array[0..9] of int
VERSION : 0.1


VAR_INPUT
  EB1234 : INT ;    
END_VAR
VAR_OUTPUT
  AB1234 : INT ;    
  CD1234 : INT ;    
END_VAR
BEGIN
NETWORK
TITLE =method 1 - use case statement (JL)

      OPN   db1; 
      LAR1  P#DBX 0.0; 
      L     #EB1234; 
      JL    GET; 
      JU    L0; 
      JU    L1; 
      JU    L2; 
      JU    L3; 
      JU    L4; 
      JU    L5; 
      JU    L6; 
      JU    L7; 
      JU    L8; 
      JU    L9; 
GET:  JU    L0; 
L0:   L     W [AR1,P#0.0]; 
      JU    out; 
L1:   L     W [AR1,P#2.0]; 
      JU    out; 
L2:   L     W [AR1,P#4.0]; 
      JU    out; 
L3:   L     W [AR1,P#6.0]; 
      JU    out; 
L4:   L     W [AR1,P#8.0]; 
      JU    out; 
L5:   L     W [AR1,P#10.0]; 
      JU    out; 
L6:   L     W [AR1,P#12.0]; 
      JU    out; 
L7:   L     W [AR1,P#14.0]; 
      JU    out; 
L8:   L     W [AR1,P#16.0]; 
      JU    out; 
L9:   L     W [AR1,P#18.0]; 
      JU    out; 

out:  T     #AB1234; 


NETWORK
TITLE =method 2 - calculate address

      OPN   db1; 
      LAR1  P#DBX 0.0; 
      L     #EB1234; 
      SLD   4; 
      +AR1  ; 
      L     W [AR1,P#0.0]; 
      T     #CD1234; 

END_FUNCTION
 
lol is Spain i will change it heheh

i changed it...

thx for the code what is the diference into code 1 and 2?

why u use SLD 4 if is a WORD?

i dont understand the JL function, i think is the same than select case but... how i can select it?

if i read second method:

Open DB1
Load in AR1 pointer P#DBX 0.0 // if i want to work with words it can be P#DBW 0 ??
Load EB
Shift 4 // why 4?
Increment 1 in AR1
Load word in AR1 of pointer 0.0
Transfer it to #CD...

i dont understand between shift 4 to T #CD... what is it doing?

two questions more:
if i want to select each DB1 position in 10 Secs?
compare pointer with INT value thats stop the reading of DB when pointer value and comparation condition are equal:

want to stop reading in DB1.DW5 but before i need to output in EB DB1.DW0 to DB1.DW5...

how to do it... using FC with AWL and then in ladder?

thx for helping i apreciatte so much
 
Last edited:
If you don't understand the JL stuff then delete it. Call this block with some valid data. Monitor the FC showing the accumulators and AR1. Post a screen shot showing the block being monitored.
 
well part by part...

i have created a oscillator in awl

Code:
 U     E    124.0
      UN    T      1
      L     S5T#1S
      SE    T      0
      U     T      0
      =     M      1.0
      U     T      0
      L     S5T#1S
      SE    T      1
      U     T      1

and then por indirect adress this:

Code:
 AUF   DB     1
      LAR1  P#DBX 0.0
      L     MD    10
      SLD   3
      +AR1  
      L     W [AR1,P#0.0]
      T     MD    50

i understand what to the program, open db1 load in ar1 in format pointer the first byte of db, load md10 convert in into pointer, sum accu1 (pointer md10) with ar1 and then load it into word with sum of ar1 and p#0.0, transfer it to md 50.

if we suppose md10 is 2 in md50 will have content of p#2.0 in db.

well... now if i want each second add 2 at md10 for increment it by 2... (first second dbx 2.0, second sec dbx 4.0...) how i can do it in awl?

regards
 

Similar Topics

Howdy folks, I am an Allen Bradley guy currently living in an Emerson world. Working with Rx3i on PacSystems Machine Edition v. 9.6? i think...
Replies
3
Views
624
Hey, I'm trying to do the following, I have some experience with Citect but can't seem to figure this out. I/O Tag: BoxPos1_ProdNum (Data Type...
Replies
0
Views
583
Hello, I'm very new to programming with absolutely zero schooling in this field and pretty hands off training in my new role, it's been fun...
Replies
4
Views
670
Hi, I have this code: LAR1 P##structy L 0 T LW [AR1,P#0.0] which resets all the bits in this struct called structy...
Replies
1
Views
643
I have upgraded an old RS500 project to Studio 5000, it has thrown multiple errors which I am currently working through. I have looked through...
Replies
8
Views
1,728
Back
Top Bottom