This is a carrie over from another thread I have going.
Just figured I might get more hits with it being labled as ANY pointer.
Other thread:
http://www.plctalk.net/qanda/showthread.php?t=51999
I'm basicly trying to copy the status of a single bit to another.
This is for monitoring and trending.
Current error is 8128 = Alignment error when reading parameter.
My original try had a REP factor of 1, but then i read that the length of an ANY pointer for BOOLS must be divisible by 8.
Just figured I might get more hits with it being labled as ANY pointer.
Other thread:
http://www.plctalk.net/qanda/showthread.php?t=51999
I'm basicly trying to copy the status of a single bit to another.
This is for monitoring and trending.
Current error is 8128 = Alignment error when reading parameter.
My original try had a REP factor of 1, but then i read that the length of an ANY pointer for BOOLS must be divisible by 8.
Code:
FUNCTION "TrendView" : VOID
TITLE =
VERSION : 0.1
VAR_INPUT
MemType : INT ;
ByteAddress : INT ;
BitAddress : BYTE ;
Dest_Any : ANY ;
END_VAR
VAR_TEMP
Source_ANY : ANY ;
tmpDest_Any : ANY ;
tempRetVal : INT ;
END_VAR
BEGIN
NETWORK
TITLE =
A( ;
L #MemType;
L 3;
>I ;
) ;
A( ;
L #MemType;
L 1;
<I ;
) ;
O ;
A( ;
L #ByteAddress;
L L#65000;
>I ;
) ;
A( ;
L #ByteAddress;
L 0;
<I ;
) ;
O ;
A( ;
L #BitAddress;
L 7;
>I ;
) ;
A( ;
L #BitAddress;
L 0;
<I ;
) ;
JC END;
NETWORK
TITLE =Create ANY pointer
//Byte 0 of ANY pointer is the HEADER which is always B#16#10 for S7
L B#16#10; //Load the Byte Sytax ID B#16#10 into ACUM1
T LB 0; //Transfer ACUM1 to Local Byte 0 of Temp Variable: #SourceAny Local ANY POINTER)
//Byte 1 is for DATA TYPE:
//Types: 01=Bool, 02=Byte, 03=Char, 04=Word, 05=Int, 06=Dword, 07=Dint, 08=Real, 09=Date, 0A=TOD, 0B=Time, 0C=S5Time
L B#16#1; //Load the Byte data type BOOL(hex01)into ACUM1.
T LB 1; //Transfer ACUM1 to Local Byte 1 of Temp Variable: #SourceAny (Type Local ANY POINTER)
//Word 2 is REPETITION FACTOR - how many items to be moved
L W#16#1; //Load the Word Quantity 1(hex01)into ACUM1.
T LW 2; //Transfer ACUM1 to Local Word 2 of Temp Variable: #SourceAny (Type Local ANY POINTER)
//Word 4 is DB NUMBER or 0 for none
L W#16#0; //Load the Word Data Block Number 0 (Hex 0)into ACUM1
T LW 4; //Transfer ACUM1 to Local Word 4 of Temp Variable: #SourceAny (Type Local ANY POINTER)
//Byte 8 and 3LSBs of 7 are BYTE address
L #ByteAddress; //Load ByteAddress from HMI into ACUM1
SLD 3; //Shift Left Double 3 places to make room for bit level
L #BitAddress; //Load BitAddress from HMI int ACUM1
+D ; //Add 2 together to get BYTE.BIT formate
T LD 6; //Transfer ACUM1 to Local Double-Word 6 of Temp Variable: #SourceAny (Type Local ANY POINTER)
//Byte 6 is MEMORY TYPE
// b#16#80=I/O area, 81=Input area, 82=Output area, 83=Bit memory area, 84=Data block, 85=Instance data block, 86=Local data (L stack), 87=Previous local data
//HMI is used to select memory type then adds hex80 to put in correct format
L #MemType; //Load Memory type entered on HMI
L B#16#80; //Load hex 80
+I ; //Add 2 together to be proper format
T LB 6; //Transfer ACUM1 to Local Word 6 of Temp Variable: #SourceAny (Type Local ANY POINTER)
NETWORK
TITLE =Transfer Second ANY Pointer INPUT to Temporary Local ANY Pointer
L P##Dest_Any; //Load a 32 bit Area Pointer pointing at 80 bit ANY pointer (P#DB102.DBX 60.0 INT 30) from Input Variable:
LAR1 ; //Load Address Register One with the contents of ACUM1 (Pointer to 10 byte input variable #Dest_ANY)
L B [AR1,P#0.0]; //Load the Byte Sytax ID B#16#10 into ACUM1.
T LB 10; //Transfer ACUM1 to Local Byte 10 of Temp Variable: #empDest_ANY (Type Local ANY POINTER)
L B [AR1,P#1.0]; //Load the Byte Data Type INT(hex05) into ACUM1.
T LB 11; //Transfer ACUM1 to Local Byte 11 of Temp Variable: #empDest_ANY (Type Local ANY POINTER)
L W [AR1,P#2.0]; //Load the Word Repetition Factor into ACUM1.
T LW 12; //Transfer ACUM1 to Local Word 12 of Temp Variable: #empDest_ANY (Type Local ANY POINTER)
L W [AR1,P#4.0]; //Load the Word Data Block Number into ACUM1
T LW 14; //Transfer ACUM1 to Local Word 14 of Temp Variable: #empDest_ANY (Type Local ANY POINTER)
L D [AR1,P#6.0]; //Load the Double-Word 6 Area Pointer into ACUM1
T LD 16; //Transfer ACUM1 to Local Double-Word 16 of Temp Variable: #tmpDes_ANY_Ptr (Type Local ANY POINTER)
//Note: Dividing 480 by 8 removes the three right bits which specifies the bit address in the area pointer.
//Note:Area Pointer Bit Values = ZZZZ_ZZZZ 0000_0YYY YYYY_YYYY YYYY_YXXX...
//...where Zs = Area Type (80=PI/PQ,81=I,82=Q,83=M,84=DBX,85=DIX,86=L,87=V or 00=None), Ys = Byte Value 0 - 65535...
//...and Xs = Bit Value 0 - 7.
NETWORK
TITLE =Use System Fuction "Block Move" to move data in DB102
CALL "BLKMOV" (//Call the System Function SFC20 BLKMOV (Block Move)
SRCBLK := #Source_ANY,//To move Source Bit Destination Bit
RET_VAL := #tempRetVal,//Error code target address
DSTBLK := #tmpDest_Any);
NETWORK
TITLE =
END: NOP 0;
END_FUNCTION