Step 7 Indirect Addressing

aqayyum

Member
Join Date
Oct 2004
Location
LAHORE
Posts
21
Need the explaination of the code given below...
Wgy not adding more than 8 real values....

L P##Measuring_values //Address of ANY-Pointer
LAR1 //Load the pointer in AR1
L B [AR1,P#1.0] //Check the type of data
L 8 //Load the code of REAL (16#08)
==I
JC calc //Jump, if the type of data = REAL
NOP 0 //Instructions, if type data <> REAL
CLR //VKE = 0
SAVE //BIE = 0
L L#-1 //Load the value, which is not apply
T #Sum
// T #Average_value
BEU //Interrupt, if the REAL-value is not apply
calc: NOP 0 //Instructions if type of data = REAL
L W [AR1,P#2.0] //Load the repeat factor in accu 1
T #quantity //Transfer to TEMP-variable for count of looping
L W [AR1,P#4.0] //Load the DB-No.
T #DB_No //Transfer to TEMP-variable
OPN DB [#DB_No] //Run time error, if the DB is not exist
L D [AR1,P#6.0] //Load the area pointer in accu 1
LAR1
L 0.000000e+000 //Load 0 in accu 1
L #quantity //Load the count value in accu 1
turn: T #Loop_count //Transfer to counter of looping (TEMP-variable)
TAK //Sum in accu 1
L D [AR1,P#0.0] //Load the field component in accu 1
+R //REAL-Addition to Sum in accu 1
+AR1 P#4.0 //Incrementation of 4 bytes in AR1
L #Loop_count //Count of looping in accu 1, and sum in accu 2
LOOP turn //Decrementation of count of looping
TAK //Change sum to accu 1
T #Sum //Transfer to output of sum
//Transfer to output of average value
SET //Set BIE-Bit to 1
SAVE
o_Oo_Oo_Oo_Oo_O
 
The comments for each line of code are correct. I've run this code in the simulator with a DB containing 16 numbers and the correct sum is produced. As you have not shown the block interface, I've used SUM as an OUT variable.

db1.jpg
 

Similar Topics

I get a weekly email from Siemens Tech Support. It has Tech notes updates etc. This week they have the following example of indirect addressing...
Replies
0
Views
2,455
I am trying to modify an assembly machine that is capable of making several part types. I am adding an lvdt and want to be able to store different...
Replies
28
Views
15,829
C
Does anyone know how I can indirectly address data in a datablock in step 7? EG. I have a DB containing multiple 'records'. I would like to...
Replies
1
Views
4,124
I have a question regarding the use of indirect addressing and pointers. Is there a difference between using the SLW3 and multiplying the original...
Replies
9
Views
19,639
Hi, What I need is: I'm writing a function. At the outside of the block I just want the parameter P_OFFSET_BYTE. PIB256 PIB257 PIB258 ...
Replies
2
Views
1,660
Back
Top Bottom