It's addressing again...(step 7)

kennyb

Member
Join Date
Mar 2004
Location
Perth
Posts
144
Hi folks,

ok here's one... can I use indirect addressing with a function block call? And can I do it within a loop. I don't think the loop is a problem but not sure about the FB. Basically I was thinking of including the call in an existing loop to save typing, it may have made performance a bit better too, but I therefore need to indirectly address the parameters of the function. Here's the gist of it.

Code:
OPN "Vacuum values" DB7
L 0
LAR1
LAR2
L 17
strt: T #COUNT
L PIW [AR1,P#512.0]
T DBW [AR2,P#2.0]
CALL "Vacuum controller" , "Vacuum parameters" FB1 / DB8
setpoint := DBW [AR2,P#0.0]
actual := DBW [AR2,P#2.0]
gain := DBD [AR2,P#6.0]
integral := DBD [AR2,P#10.0]
diff := DBD [AR2,P#14.0]
signal_out:= DBD [AR2,P#4.0]
L DBW [AR2,P#4.0]
T PQW [AR1,P#514.0]
+AR1 P#4.0
+AR2 P#20.0
L #COUNT
LOOP strt
NOP 0

Thanks in advance

Kenny

ps: all the parameters after the call statement are coming up invalid
 
Last edited:
Kenny
I think you can employ a method recently discussed in JesperMP's thread about UDTs. One of S7Guy's ideas.

If I understand, you have 17 Vac pumps?

Can you create a DB with an array of 17 UDTs. Each UDT being the setpoint, gain, actual etc.

Open this as an instance DB (OPN DI 7) then use UC rather than CALL to call the FB. This doesn't prompt you for the input/output parameters.

After calling the block, increment AR2 by the length of the UDT and call it again, testing for reaching 17.

I think there's an implicit link between an instance data block and AR2.

In your example, Is DB8 only there because Step7 needed one when using CALL FB??.

pp

ps. Step forward S7Guy!

Edit: Not sure how to tie each instance up with the real-world I/O yet.
 
Last edited:
It can be done almost as you described it. The only thig is that you cant use adressregister values as paramters you have to load and store them in the Temp stack (local data). Your FB call could probably look somthing like this

OPN "Vacuum values" DB7

//Use TAR2 if multi instans capability is used for the FB
//Ar2 is used to keep track off the offset in the multi instans DB
//Saves Ar2 in tempstack so it can be restored later with LAR2
TAR2 #TempAr2 //Temp Dword

L 0
LAR1
LAR2

L 17
strt: T #COUNT

L PIW [AR1,P#512.0]
T DBW [AR2,P#2.0]

L DBW [AR2,P#0.0]
T #Setpoint //Temp Word

L DBW [AR2,P#2.0]
T #Actual //Temp Word

L DBD [AR2,P#6.0]
T #Gain //Temp Dword

L DBD [AR2,P#10.0]
T #Intregral //Temp Dword

L DBD [AR2,P#14.0]
T #Diff //Temp Dword

L DBD [AR2,P#4.0]
T #SignalOut //Temp Dword


CALL "Vacuum controller" , "Vacuum parameters" FB1 / DB8
setpoint := #Setpoint
actual := #Actual
gain := #Gain
integral := #Intregral
diff := #Diff
signal_out:=#SignalOut

L DBW [AR2,P#4.0]
T PQW [AR1,P#514.0]

+AR1 P#4.0
+AR2 P#20.0

L #COUNT
LOOP strt

//Restores Ar2
LAR2 #TempAr2
 
Thanks guys,

the UDT method is a bit of a mystery but I'll get to it eventually. I saw Jesper's thread but it gave me a sore head. I think the main thing is I hadn't considered the interaction with the instance DB. Bratt's method makes sense and is still less trouble than calling the FB 18 times and filling in 18 sets of addresses. Unfortunately by the time I'd seen this that's exactly what I've done!! Doh! I'll revisit it tho as it streamlines the thing somewhat - the original structure was an FC with the loop which transferred the PIWs to DB and DB to PQW, then the next FC called the FB for each vac regulator. I just thought it would be nifty to incorporate the whole thing in a loop.

Cheers

Kenny
 

Similar Topics

Can someone take a look at this and see what I am doing wrong. I am planning on putting this into a loop but I cant get data from one DB to...
Replies
10
Views
10,307
Hi, hope somebody could point me in the right direction. First time using S7300. Have managed to configure hardware, cpu etc, download...
Replies
17
Views
6,897
I am very new to Modbus and the industry, so forgive me if I am missing something obvious. I have known Modbus register addresses coming from a...
Replies
7
Views
227
I have a system using Rx3I CRU320 redundant CPU with Proficy Machine Edition Software. In the hardware configuration of each CPU module, under...
Replies
14
Views
388
See the screenshot of EIP tag list. We are trying to read in a digital input that is hard-wired. It is shown here as I31.1. I believe we cannot...
Replies
7
Views
281
Back
Top Bottom