Peripherial I/O Step 7, indirect adressing ?

userxyz

Member
Join Date
May 2002
Location
any
Posts
2,768
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
...

These adresses are the ones that I wanna read.


So, on the P_OFFSET_BYTE parameter I will enter 256 (INT).
The rest has to be done in the function.

But how can I call PIB256, PIB257, etc... when I only have an integer offsetbyte ?

Thanks
 
Here's an example FC

Code:
FUNCTION FC 1 : VOID
TITLE =
VERSION : 0.1

VAR_INPUT
  iOffset : INT ; 
END_VAR
VAR_TEMP
  abBytes : ARRAY  [1 .. 11 ] OF BYTE ; 
  iLoopCount : INT ; 
END_VAR
BEGIN
NETWORK
TITLE =for i=1 to 11 abBytes[i]=PIB[iOffset+i] 

	  LAR1  P#P  0.0; 
	  L	 #iOffset; 
	  SLD   3; 
	  +AR1  ; 
	  LAR2  P##abBytes; 
	  L	 11; 
Loop: T	 #iLoopCount; 
	  L	 B [AR1,P#0.0]; 
	  T	 B [AR2,P#0.0]; 
	  +AR1  P#1.0; 
	  +AR2  P#1.0; 
	  L	 #iLoopCount; 
	  LOOP  Loop; 

END_FUNCTION
 
Hi

The SCL version that I see in the title is a little more understandable:
for i=1 to 11 abBytes=PIB[iOffset+i]

I think I'll use SCL to do the job.

About your code, can you explain it a little please ?

L D[AR2 said:
Here's an example FC

Code:
FUNCTION FC 1 : VOID
TITLE =
VERSION : 0.1
 
VAR_INPUT
iOffset : INT ; 
END_VAR
VAR_TEMP
abBytes : ARRAY [1 .. 11 ] OF BYTE ; 
iLoopCount : INT ; 
END_VAR
BEGIN
NETWORK
TITLE =for i=1 to 11 abBytes[i]=PIB[iOffset+i] 
 
	 LAR1 P#P 0.0; 
	 L	 #iOffset; 
	 SLD 3; 
	 +AR1 ; 
	 LAR2 P##abBytes; 
	 L	 11; 
Loop: T	 #iLoopCount; 
	 L	 B [AR1,P#0.0]; 
	 T	 B [AR2,P#0.0]; 
	 +AR1 P#1.0; 
	 +AR2 P#1.0; 
	 L	 #iLoopCount; 
	 LOOP Loop; 
 
END_FUNCTION
 

Similar Topics

I am having a step7 v5.4 program where the blocks are encrypted and locked. And the manufacturer is stopped the support. Is there any ways to...
Replies
2
Views
177
Good Morning, Hoping someone with some Siemens experience can give me a hand with this one. Customer has a S7-200 cpu, which has a 6GK7...
Replies
0
Views
248
HI! HOW COULD I OBTAIN THE NAMES OF THE STEPS OF A ROUTINE IN SFC LANGUAGE IN STUDIO5000? Or is there a system variable that gives me those...
Replies
0
Views
339
I'm just trying to figure out the right method of adding a DO card to an existing rack. It's not the *next* open slot, but I have to move the AO...
Replies
5
Views
547
Hi Siemens Experts, I am hoping someone can shed some light on my issue. I have uploaded the code from a S7-300 (317-2PN/DP) using Step 7...
Replies
9
Views
674
Back
Top Bottom