Technical Forum

Process Control Systems SIMATIC PCS 7

How to enter an any pointer for the parameter Send for the AG_Send block in CFC

Thread Starter: Mark999   Started: 6/20/2012 2:56 PM   Replies: 2

« Previous thread Next thread »
Page 1 of 1 (3 items)
  6/20/2012, 2:56 PM
Joined 1/5/2009
Last visit: 11/8/2012
Posts: 1
Rating:
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Hi,

I am trying to use AG_Send but am having problems entering in an Any Pointer to the parameter for SEND.
It is not possible to just type in P#DB1.DBX0.0 BYTE 10 as you would for Step 7. I have tried creating a structure containing the any pointer format in a DB and then addressed it as DBNumber.StructureAddress but this then tries to send that DB not the DB in the Pointer. Any idea's how this is achieved.
Top
  7/13/2012, 7:23 PM
Joined 3/24/2009
Last visit: 4/30/2013
Posts: 2
Rating:
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 

Hi:
Use this application to let a ANY-pointer (#TEMP_ANY) take the AG-SEND parameters.
Connect the #TEMP_ANY to the AG-SEND "SEND" input.

Application example:
-----------------------
   LAR1  P##TEMP_ANY        // Indirect Address -> AR1

      L     B#16#10                   // 10= Syntax "DataBlock ID"
      T     LB [AR1,P#0.0]

      L     B#16#2                     // 2= Syntax "BYTE"
      T     LB [AR1,P#1.0]

      L     #LEN                         // IN: INT No of Bytes to send
      T     LW [AR1,P#2.0]

      L     #DB_Nr                     // IN: INT DB-nr Source-data
      T     LW [AR1,P#4.0]

      L     #Start_Adr
      SLD   3                           // Shift 3 for PTR format
      PUSH                              // Copy ACCU x -> ACCU X+1
      L     2#1000010000000000          // MASK : Use "Operand-type" och "DBX" !
      SLD   16                          // Delete old bits from ACCU1
      OD                                  // Sum ACCU1 och ACCU2
      T     LD [AR1,P#6.0]       // Byte address

After this the TMP_ANY is adressed for sending data from DB("DB_Nr") starting with DBW("Start_Adr
") and with the length "LEN" . These parameters must of course be initialized in advance.

Hope this will solve Your problem. 

Top
  7/17/2012, 10:42 AM
Joined 10/3/2007
Last visit: 5/21/2013
Posts: 120
Rating:
Rated: Outstanding [3.6 out of 5 / rated 20 time(s)]. (20) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 

Hi Mark,

Here is an SCL example on how to use ANY pointers for the call of the BLOCKMOVE function, the same is possible for AG_SEND and AG_RECEIVE. Make sure to check out the correct format of the specific pointer you want to use. Alternatively if you don't want to do any programming, you can create the correct sized DB and link the CFC input directly with the DB, in this case no offset is possible but appart from that it should work just fine.

FUNCTION DB_COPY : INT
TITLE = 'DB_COPY'
KNOW_HOW_PROTECT
VERSION: '1.1'
AUTHOR: EIT_ES11
NAME: DB_COPY
FAMILY: ES11_LIB

VAR_INPUT
SRC_DB_NUMBER : INT;
DES_DB_NUMBER : INT;
SRC_OFFSET : INT;
DES_OFFSET : INT;
NBR_BYTES : INT;
END_VAR

VAR_TEMP
TEMP_DW : DWORD;
TEMP_BYTE AT TEMP_DW : ARRAY[0..3] OF BYTE;
SOURCE  : STRUCT
    BYTE0 : BYTE;
    DATA_TYPE : BYTE;
    REPETITION_FACTOR : WORD;
    DB_NUMBER : WORD;
    MEMORY_AREA : DWORD;
END_STRUCT;
TEMP_SOURCE AT SOURCE : ARRAY[0..9] OF BYTE;
DESTINATION  : STRUCT
    BYTE0 : BYTE;
    DATA_TYPE : BYTE;
    REPETITION_FACTOR : WORD;
    DB_NUMBER : WORD;
    MEMORY_AREA : DWORD;
END_STRUCT;
TEMP_DEST AT DESTINATION : ARRAY[0..9] OF BYTE;
SRC_POINTER AT SOURCE : ANY;
DST_POINTER AT DESTINATION : ANY;
END_VAR

BEGIN
SOURCE.BYTE0 := 16#10;
SOURCE.DATA_TYPE := 16#02;
SOURCE.REPETITION_FACTOR := INT_TO_WORD(NBR_BYTES);
SOURCE.DB_NUMBER := INT_TO_WORD(SRC_DB_NUMBER);
TEMP_DW := INT_TO_WORD(SRC_OFFSET);
TEMP_DW := SHL(IN := TEMP_DW,N := 3);
TEMP_BYTE[0] := 16#84;
SOURCE.MEMORY_AREA := TEMP_DW;
DESTINATION.BYTE0 := 16#10;
DESTINATION.DATA_TYPE := 16#02;
DESTINATION.REPETITION_FACTOR := INT_TO_WORD(NBR_BYTES);
DESTINATION.DB_NUMBER := INT_TO_WORD(DES_DB_NUMBER);
TEMP_DW := INT_TO_WORD(DES_OFFSET);
TEMP_DW := SHL(IN := TEMP_DW,N := 3);
TEMP_BYTE[0] := 16#84;
DESTINATION.MEMORY_AREA := TEMP_DW;
DB_COPY := BLKMOV(SRCBLK := SRC_POINTER,DSTBLK := DST_POINTER);
END_FUNCTION

Top
Page 1 of 1 (3 items)
Actions