Siemens S7 Pointer question.

genesisfm

Member
Join Date
Apr 2008
Location
Europe
Posts
23
Hi,

I'm programming a piece of software to scan the inputs of the PLC.
But i got a problem... First the code:

A #START_TEL <-- Enable BIT to start the LOOP
JC LP
JU END
LP: L P#1.7 <-- OFFSET start counting at ADRESS 1.7 (I 1.7)
T MD 205 <-- The problem (but it only works with a MD)
L 16 <- Scan for 1 word 16bits
NEXT: T #T_MEM1 <-- LOOP
A I [MD 205] <-- Check input
AN #B_MEM1 <- BLOCK when i see a input
JC WRT
JU EXT
WRT: S #B_MEM1 <-- Set BLOCK
L #T_MEM1 <-- LOAD LOOP COUNT
T #OUTPUT <-- TRANSFER the loop count into VAR
EXT: NOP 0
L MD 205
L P#0.1
-D (min 0.1)
T MD 205
L #T_MEM1
LOOP NEXT (LOOP not ended? goto....)
END: NOP 0 (END LOOP)
R #B_MEM1 (Reset BIT mem)

Whats the problem? I want to:
T MD 205 <-- The problem
Transfer that into a local var example: #A_NAME
Like:
L P#1.7
T #A_NAME
L 16 <- Scan for 1 word 16bits
NEXT: T #T_MEM1 <-- LOOP
A I [#A_NAME] <-- Check input
AN #B_MEM1 <- BLOCK when i see a input

But that doesn't work :(

Ps. #A_NAME = a DWORD
Can some one help me? I want to use a local input to give my function a variable adress.

Thank you!

Best regards Rob
 
I took your code and replaced all MD205's with a_name and it worked for me:

ar1009.JPG
 
L D[AR2 said:
NB: a_name is a temporary dword variable.

I forgot something... I want to use a local variable INPUT. And not a TEMP var.
Because i want to made a function that you can use a variable.

CALL FB 10, DB10
INPUT = P#1.0 (and here the offset)

Thank you.
 
If the parameter you are passing is a pointer, you must use indirect addressing to retrieve the pointer. Here's the source code of an example FB. (I've commented out the first few lines so the block runs all the time)

Code:
FUNCTION_BLOCK FB 1
TITLE =
VERSION : 0.1

VAR_INPUT
  INPUT : POINTER ; 
END_VAR
VAR_TEMP
  start_tel : BOOL ; 
  T_mem1 : INT ; 
  output : INT ; 
  b_mem1 : BOOL ; 
  a_name : DWORD ; 
END_VAR
BEGIN
NETWORK
TITLE =
//	  A	 #start_tel				  //<-- Enable BIT to start the LOOP
//	  JC	LP
//	  JU	END
	  TAR2  ; 
	  LAR1  P##INPUT; 
	  +AR1  ; 
	  L	 D [AR1,P#2.0]; 
	  T	 #a_name; //<-- The problem (but it only works with a MD)
	  L	 16; //<- Scan for 1 word 16bits
NEXT: T	 #T_mem1; //<-- LOOP
	  A	 I [#a_name]; //<-- Check input
	  AN	#b_mem1; //<- BLOCK when i see a input
	  JC	WRT; 
	  JU	EXT; 
WRT:  S	 #b_mem1; //<-- Set BLOCK
	  L	 #T_mem1; //<-- LOAD LOOP COUNT
	  T	 #output; //<-- TRANSFER the loop count into VAR
EXT:  NOP   0; 
	  L	 #a_name; 
	  L	 P#0.1; 
	  -D	; //(min 0.1)
	  T	 #a_name; 
	  L	 #T_mem1; 
	  LOOP  NEXT; //(LOOP not ended? goto....)
	  NOP   0; //(END LOOP)
	  R	 #b_mem1; //(Reset BIT mem)
END_FUNCTION_BLOCK

Here's the code being monitored:

poi009.JPG
 

Similar Topics

program : L #measurement + -1 SLD 4 LAR1 AUF "DB72" L DBW [ar1,P#4.0] question1 : measurment =5 5-1=4 0000 0000 0000 1000 SLD 4 gives 0000 0000...
Replies
3
Views
14,386
I have a word in some DB which I want to load to AR1 and use as a pointer. In order to do this I need to write L DBxy.DBW xy SLD 3 LAR1 I...
Replies
3
Views
555
Hi people. I am having some trouble with siemens Step7, i'm not expert on it by any stretch. I'm more of a Bradley person with some TIA portal...
Replies
31
Views
11,123
Is it possible to make I/O filed on HMI of POINTER data type? Pointer data type can be either temp, IN or IN_OUT variable inside FB. it would be...
Replies
1
Views
1,802
Hi All, I have a system where there are parameters loaded into a DB from a DCS system. When I check the address's I find no locations in...
Replies
4
Views
2,912
Back
Top Bottom