Step 7 Indirect SLW versus * Multiply

Galaniz

Member
Join Date
Feb 2012
Location
Corpus Christi
Posts
34
I have a question regarding the use of indirect addressing and pointers. Is there a difference between using the SLW3 and multiplying the original value by 8. For my example I am indexing tank Volumes. "INDEX_VOLUMES" DBW48 has an integer 0-44 in multiples of four that reflects the desired starting byte in the "INDEX_VOLUMES" DB(selected on HMI).


OPN "INDEX_VOLUMES" //OPEN INDEX DB
L DBW 48 //LOAD INDEX NUMBER
SLW 3 // CONVERT INDEX NUMBER TO POINTER
LAR1 // LOAD POINTER TO ACCUM 1
L DBD [AR1,P#0.0] // LOAD VALUE IN DB210.DBD[DBW48]
T "HEADER A AUTO TRANS DB".HA_BARLS_DEST_TANK // STORE LOADED VALUE AS CURRENT BARRELS IN DESTINATION TANK

Can I replace the SLW 3 with the following:

L 4
*I
LAR1

?

I am learning that the AR1 part of the pointer [AR1, P#0.0] is like a bit starting point? It tells the program which bit number to start at?

Thanks,
 
I am still confused. I will explain my program a little more.

For example when my DBW48 contains the integer 12, the SLW 3 results in a 96. Then I do the LAR1 and L DBD [AR1,P#0.0]. What I get is the value of "INDEX_VOLUMES".DBD12. When DBW48 us 13, I get the value of "INDEX_VOLUMES".DBD13. THis part is working correctly.

When I changed it SLD just now nothing changed.



But my question is can I replace the SLW with I *8 ?
 
When DBW48 us 13, I get the value of "INDEX_VOLUMES".DBD13. THis part is working correctly.

It doesn't sound like it is as DBD13 will contain jibberish. What data is stored in DB210 - floating point numbers or double integers and how does it get there?
 
For example, here is an array of reals,

Barrel[0] is accessed using DBD0
Barrel[1] is accessed using DBD4
Barrel[2] is accessed using DBD8
etc....

and DBW48 is part of the storage used for Barrel[12]

bar1.JPG
 
Here is the code that is currently working exactly as it is without symbolic representation:

L DB107.DBW 4
L 4
*I
T DB210.DBW 48
OPN DB 210
L DBW 48
SLW 3
LAR1
L DBD [AR1,P#0.0]
T DB107.DBD 32

DB107.DBW4 is an integer value 0-11 selected by selecting tank on the HMI screen.
The whole purpose of the code is not to write the values, but to select which value to read. The values are populated through 12 independent scaling functions so I am just deciding which value to read with the code above.

I Initially multiply by 4 and store it to DB210.DBW48. The result is the actual index number that will be refer the address in DB210. So when the user selects tank 3, DB107.DBW4 is a 2 since I begin with 0, then it is multiplied by 4 to yield an 8 that is stored in DB210.DBW48. The number 8 will be used as a pointer to access DB210.DBD8 which cotains the real value of the tank volume.

I am very new to indirect addressing in Siemens. I am very familiar with how it works using Allen Bradley products, so my concept comes from that background.

I think I am still confused regarding the SLW and SLD commands, but I think since my value that gets the SLW is always less than 16 bits (it can only be integer 0-11) that I could use either since the high byte is always all zeros?

I really appreciate everyones input on this.

Gabriel

Untitled.jpg
 
If I understand it, you have an HMI page with parameters of the tank's and many real tank, yes?
Do you want to write and read the current value of the tank selected from the HMI?
Right?
 
I think I am still confused regarding the SLW and SLD commands, but I think since my value that gets the SLW is always less than 16 bits (it can only be integer 0-11) that I could use either since the high byte is always all zeros?

In this example SLW 3 will do the job, but SLD 3 should be used as a matter of course to ensure the correct address is generated for larger data areas.
 
Any particular reason for storing the index*4 in DBW48?

Code:
L     DB107.DBW    4            
L     4                         
*I                                
T     DB210.DBW   48              
OPN   DB   210                    
L     DBW   48                    
SLW   3                            
LAR1                              
L     DBD [AR1,P#0.0]             
T     DB107.DBD   32
My implementation:
Code:
L     DB107.DBW    4              //barrel index
SLD 5           //calc pointer to real values
LAR1
OPN   DB   210                    
L     DBD [AR1,P#0.0]             
T     DB107.DBD   32
 
Last edited:
There is no real reason for storing index*4 in DBW48. When I developed the code I was copying examples till i made something work and now i have had a little time I am trying to understand it before I have to commision the project so that I can actually make changes to it if required.

Your version looks a lot easier now that I understand the concept a little better. Thanks.
 

Similar Topics

Need the explaination of the code given below... Wgy not adding more than 8 real values.... L P##Measuring_values //Address of...
Replies
3
Views
2,057
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,637
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,439
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,790
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,114
Back
Top Bottom