Siemens Step 7 - FC for profibus comm

ason

Member
Join Date
Oct 2005
Location
Home
Posts
317
Hi, i need to communicate with a profibus device

input 24 byte
output 6 byte

i want to use my PID adress and not a INT so i can use crossref to find it.
so i have this,
now i want to read 24bytes from that adress and store that in L4.0 that i have a 24 bytes struct

and how do i write in stl code with that struct, i have done it in a FC
but think to learn to make source file for this fc

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

VAR_INPUT
  HW_Addr : POINTER ; 
END_VAR
VAR_OUTPUT
  i_Addr : INT ; 
END_VAR
BEGIN
NETWORK
TITLE =return integer address of Peripheral variable
	  L	 P##HW_Addr; 
	  LAR1  ; 
	  L	 D [AR1,P#2.0]; 
	  SRD   3; 
	  T	 #i_Addr; 
	  SET   ; 
	  SAVE  ; 
END_FUNCTION

Best regards,
Ason
 
Here's a few methods:

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


VAR_INPUT
  HW_addr : POINTER ;    
END_VAR
VAR_OUTPUT
  i_Addr : INT ;    
END_VAR
VAR_TEMP
  Rcv : ARRAY  [1 .. 24 ] OF BYTE ;    
  iSFC14RetVal : INT ;    
  wAddr : WORD ;    
  iCount : INT ;    
END_VAR
BEGIN
NETWORK
TITLE =

      L     P##HW_addr; 
      LAR1  ; 
      L     D [AR1,P#2.0]; 
      LAR1  ; 
      SRD   3; 
      T     #i_Addr; 
      T     #wAddr; 

//method 1
      CALL "DPRD_DAT" (
           LADDR                    := #wAddr,
           RET_VAL                  := #iSFC14RetVal,
           RECORD                   := #Rcv);

//method 2
      LAR2  P##Rcv; 
      L     PID [AR1,P#0.0]; 
      T     D [AR2,P#0.0]; 
      L     PID [AR1,P#4.0]; 
      T     D [AR2,P#4.0]; 
      L     PID [AR1,P#8.0]; 
      T     D [AR2,P#8.0]; 
      L     PID [AR1,P#12.0]; 
      T     D [AR2,P#12.0]; 
      L     PID [AR1,P#16.0]; 
      T     D [AR2,P#16.0]; 
      L     PID [AR1,P#20.0]; 
      T     D [AR2,P#20.0]; 

//method 3
      LAR2  P##Rcv; 
      L     6; 
PD:   T     #iCount; 
      L     PID [AR1,P#0.0]; 
      T     D [AR1,P#0.0]; 
      +AR1  P#4.0; 
      +AR2  P#4.0; 
      L     #iCount; 
      LOOP  PD; 

      SET   ; 
      SAVE  ; 
END_FUNCTION
 

Similar Topics

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
557
I'm trying to figure out how to read the actual speed reference value from the move blocks, writing to a DB that is being sent to the VFD. For...
Replies
5
Views
2,642
Hi guys! Ive got a problem with my Siemens Plc 300 station! This is a my setup: PS307 2A 307-IBA00-0AA0 CPU314 IFM...
Replies
8
Views
4,537
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
254
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
690
Back
Top Bottom