PIB, PID, PQB, PQW and indirect adressing

userxyz

Member
Join Date
May 2002
Location
any
Posts
2,768
I have a function with in/out parameters.

The connected parameters for motor 1 are:

PIB304
PID308
PQB304
PQB305
PQW306


The connected parameters for motor 2 are:

PIB288
PID292
PQB288
PQB289
PQW290


etc..


How can I indirect these with integers or other ways... ?

Else I need to call the function to many times...
 
Its quite a major rewrite to convert the function from the current in/out parameter list.

I take it you just want to specify a Start address, and have all the other values follow on eg. last parameter would be PQW(Start + 2).

You need to read up on indirect addressing in S7, as one way or another you would end up creating a series of pointer from the specified atart address.

How many times is the function called? Is it worth a rewrite to save entering a few parameters, or are you worried about typo's etc.
 
Here's one possibility, pass in a pointer to the base address of the peripheral area and then use indirect address to access the areas you require.

pib009009.jpg
 
hey

2 things...

first I don't really understand what you're doing with the w#16#FFFFFFFF ?

Second, I tried to implement you're code, but I'm seeing some probs. I use the read or the write block, check my code. Not really easy to do this.


Code:
[SIZE=2]
FUNCTION_BLOCK "LENZE_PKW"
TITLE =LENZE
VERSION : 0.1
 
VAR
READ_REQ : BOOL ; 
WRITE_REQ : BOOL ; 
MEMBIT_1 : BOOL ; 
END_VAR
BEGIN
NETWORK
TITLE =LENZE PKW READ
A "DB M201 PKW".WRITE.REQ; 
ON "DB M201 PKW".READ.REQ; 
JC NEX1; 
A "DB M201 PKW".READ.REQ; 
A "Puls_Clk"; 
= #READ_REQ; 
CALL "LENZE_PKW_READ" , "IDB_LENZE_PKW_READ" (
READ_REQ := #READ_REQ,
PAR := "DB M201 PKW".PARAMETER,
IND := "DB M201 PKW".INDEX,
Byte_1_Status := PIB 304,
Byte_5_6_7_8 := PID 308,
Byte_1 := PQB 304,
Byte_2 := PQB 305,
Byte_3_4 := PQW 306,
READ_VALID := "DB M201 PKW".READ.VALID,
READ_VALUE := "DB M201 PKW".READ.VALUE);
NEX1: NOP 0; 
NETWORK
TITLE =LENZE PKW WRITE
A "DB M201 PKW".READ.REQ; 
ON "DB M201 PKW".WRITE.REQ; 
JC NEX2; 
A "DB M201 PKW".WRITE.REQ; 
A "Puls_Clk"; 
= #WRITE_REQ; 
CALL "LENZE_PKW_WRITE" , "IDB_LENZE_PKW_WRITE" (
WRITE_REQ := #WRITE_REQ,
PAR := "DB M201 PKW".PARAMETER,
IND := "DB M201 PKW".INDEX,
Byte_1_Status := PIB 288,
WRITE_VALUE := "DB M201 PKW".WRITE.VALUE,
Byte_1 := PQB 304,
Byte_2 := PQB 305,
Byte_3_4 := PQW 306,
Byte_5_6_7_8 := PQD 308,
WRITE_VALID := "DB M201 PKW".WRITE.VALID);
NEX2: NOP 0; 
NETWORK
TITLE =PROGRESS READ / WRITE
A "DB M201 PKW".READ.REQ; 
A "DB M201 PKW".WRITE.REQ; 
JC NEX4; 
A "DB M201 PKW".READ.REQ; 
A "DB M201 PKW".READ.VALID; 
O ; 
A "DB M201 PKW".WRITE.REQ; 
A "DB M201 PKW".WRITE.VALID; 
JCN NEX3; 
A "Puls_Clk"; 
FP #MEMBIT_1; 
JCN NEX3; 
L "DB M201 PKW".PROGRESS_BAR; 
L 10; 
+I ; 
T "DB M201 PKW".PROGRESS_BAR; 
NEX3: L "DB M201 PKW".PROGRESS_BAR; 
L 100; 
>I ; 
JCN NEX4; 
L 0; 
T "DB M201 PKW".PROGRESS_BAR; 
NEX4: A "DB M201 PKW".READ.REQ; 
O "DB M201 PKW".WRITE.REQ; 
BEC ; 
L 0; 
T "DB M201 PKW".PROGRESS_BAR; 
END_FUNCTION_BLOCK
 
[/SIZE]

Here's one possibility, pass in a pointer to the base address of the peripheral area and then use indirect address to access the areas you require.
 
There is a certain hazzle with having to enter the adresses by hand to each of the FB's/FC's. However, one shall consider carefully if going 100% indirect just to save the typing time is a good idea.

In my projects I typically have 50-100 "objects" for which I must go through the boredom of writing symbols, defining alarm texts, generating IDB's, and entering the right symbols on the right I/O pins of the FB's. It is one or two days of boring typing, and I really hate this part.
However, the end result is code that is easy to read and troubleshoot.
 
:)

I agree with what you're saying, I think I will copy the code 15 times (15 motors) and adjust the adresses in each copy, then jump to the code that I need to run, if it wasn't connected to a faceplate in WinCC Flex, It wouldn't be such problem, but I don't like to change very much.


There is a certain hazzle with having to enter the adresses by hand to each of the FB's/FC's. However, one shall consider carefully if going 100% indirect just to save the typing time is a good idea.

In my projects I typically have 50-100 "objects" for which I must go through the boredom of writing symbols, defining alarm texts, generating IDB's, and entering the right symbols on the right I/O pins of the FB's. It is one or two days of boring typing, and I really hate this part.
However, the end result is code that is easy to read and troubleshoot.
 
2 things...

first I don't really understand what you're doing with the w#16#FFFFFFFF ?


You should notice that it is W#16#FFFFFF and not W#16#FFFFFFFF.

The first one will result in changing from Area-Crossing indirect adressing to Area-Internal indirect adressing.
While the second doesn't do anything.

Area-Crossing is:

Code:
L P#IW304
LAR1
A [AR1,P#0.0]
= "some_bit"
Area-internal is:

Code:
L P#304.0
LAR1
A I [AR1,P#0.0]
= "some_bit"
Look at the screenshot from L D, look at the contents of ACCU1 and AR1.


Edit: Seems those puzzles are starting to pay off.......lol
 
How I understood this:
L P##pBaseAddress
-->load acc1 with memory location where this pointer begins, here V21.0

LAR1
-->point ar1 to this address, V21.0

L D[AR1,P#2.0]
--> Now load acc1 where this pointer store, start of the memory area passed to FC1, here PIW304 or 80000980 (thats why p#2.0)

AD DW#16#FFFFFF
-->Remove 80000 and keep only 980 or 304(304 is pointer equivalent in decimal format)

LAR1
-->load ar1 with 980 or 304 (use this number to refer different part of which ever memory area)

p.JPG
 
Last edited:
thanks

Thanks...

I still will avoid indirect stuff where I can, this makes the program less readable.
 

Similar Topics

anyone know of any manufactures that would have such a device. I am building a test system that is both PLC and LabView based and I need a Megger...
Replies
2
Views
465
I have a few old HP programmable power supplies - HP 6033A's. I'd like to control them from a CompactLogix 1769-L33ER. The power supplies have a...
Replies
2
Views
2,593
Hello all, I'm hoping someone out there can help me. I have 2 plcs where I work which communicate with each other. In one of them it transfers...
Replies
7
Views
5,015
Not sure if this is the right place to post this, but wanted to see if this software was still worth anything to anyone. My father recently...
Replies
1
Views
3,600
Hi there! Does any of you have a program available for copying PIB data to a DB. What I need is: L PIB 512 T DB201.DBB0 L PIB 513 T...
Replies
10
Views
5,527
Back
Top Bottom