SFC14 + 15 In Function Block Question

hein123

Member
Join Date
Aug 2010
Location
Uitenhage
Posts
93
Hi again

I am currently ready inputs through SFC14 and then I am using the DB nr as input to a FB. Within the FB I use indirect addressing to access the DB Values.
When I am done with the FB I use the DB manipulated values as outputs using SFC15.

Now my question is can I use indirect address to write a value like this: P#DB27.DBX0.0 BYTE 14 which is the 'RECORD' any value using just the '27' DB value? Thus would reduce my program somewhat.

I hope my question makes sense :)
 
Sounds like your making life way more complicated than it really needs to be, especially if you only have 14 bytes of I/O.

In the bad old days, PLC i/O was directly addressed so people made their own process images in data blocks so they could ensure that the I/O state remained contstant for an entire scan. Most modern PLCs, have a built in process image so that you don't need to make your own but some people still think it's a good idea. There can be legitimate reasons for doing this but generally, the term Ludite springs to mind.

Nick

P.S. sorry if i'm rambling a bit, it was a very nice bottle of wine.
 
I am actually writing to a rexroth servo motor and want to send all the information via SFC14 0 inputs and SFC15 - outputs.

For controlling the servo I have 3 Network Rows, one for ready the inputs, one with a FB for the control of the servo and then the I write to the outputs via SFC15.
What I basically do inside the FB is manupulate the Inputs and control outputs, but I do this by reading / writing to DB values. As inputs to the FB I have the numbers of the Input DB and the Output DB. I then use these numbers via indirect addressing to access the DB values:

L #S_InputDB_NR //Input DB Nr
T #iDB //Temp Holder
OPN DB [#iDB]
L 0
SLD 3
LAR1

A DBX [AR1,P#0.0] // Write Values To STAT
= #Q_OperationMode0
etc ...

The FB works right so I am not worried about operation, but I would like to control the drive within one FB which would make future projects a bit easier.

SFC14:
CALL "DPRD_DAT"
LADDR :=W#16#B4
RET_VAL:=MW62
RECORD :=P#DB27.DBX0.0 BYTE 14

Now what I want to do is place SFC14 code (ABOVE) on top of the FB. But the 27 of the P#DB27.DBX0.0 BYTE 14 needs to be an input as I won't always use DB27 as the Inputs DB. I want to access it via indirect addressing if possible like in the code above.

I know I can write to the outputs directly, however a tech working at Siemens told me it's better practice to use SFC14 and 15.


I hope this makes my question more clear :)
 
Call the following FC instead of SFC14

Code:
FUNCTION FC 914 : INT
TITLE =
VERSION : 0.1

VAR_INPUT
  LADDR : WORD ; 
  wDBNumber : WORD ; 
END_VAR
VAR_TEMP
  pDB : ANY ; 
END_VAR
BEGIN
NETWORK
TITLE =SFC14 read from LADDR and stored in wDBNumber.DBX0.0 byte 14
      LAR1  P##pDB; 
      L     W#16#1002; 
      T     W [AR1,P#0.0]; 
      L     14; 
      T     W [AR1,P#2.0]; 
      L     #wDBNumber; 
      T     W [AR1,P#4.0]; 
      L     P#DBX 0.0; 
      T     D [AR1,P#6.0]; 
      CALL SFC14 (
           LADDR                    := #LADDR,
           RET_VAL                  := #RET_VAL,
           RECORD                   := #pDB);
END_FUNCTION
 
I'm glad you got it working. In future you may wish to considder putting your drive data into two UDTs, one for READ and one for WRITE. You can then pass a pointer to your UDTs into the FC which can be deconstructed and used to build anypointers for SFC14/15. In this way, if you change the size of the data that is transferred, simply update your UDTs, do a block Consistency Check and thats it - job done.

Nick
 

Similar Topics

Hello I am trying to open SFC14 and SFC15 but these blocks are protected. I tried to unprotect them using Microsoft Access but when I opened DBF...
Replies
3
Views
2,236
Hello, I have an S7-300 CPU 315/2DP and wants to send data to a Profibus controller. The problem is that this CPU the SFC14 and SFC15 not...
Replies
3
Views
2,187
Hi guys, I'm finding some difficulties to understand or meaning where the Siemens Profibus Encoder type 6FX2001-5FP24 write the data (feedback...
Replies
11
Views
12,736
Hey, Is there a way to read the diagnostics of a DP slave through the process image table of S7 315-DP-2? I have the diagnostics address of 2044...
Replies
2
Views
3,601
Hello, I have a profibus network with the CPU 315-2dp and an inverter as slave from Lenze. In the hardware configuration I have the adresses...
Replies
2
Views
2,824
Back
Top Bottom