Hello,
Yes I used memcmp and memcpy and it worked for comparing it. But.. How do I say I want to know if the difference is more then 5 for ex. MEMCMP has outputs just less, equal or more..
Just comparing:
Code:
IF MEMCMP( pBuf1 := ADR(Byte1) , pBuf2:= ADR(SaveByte1) , n:= 1) <> 0 THEN
Trig_Byte1 := TRUE;
MEMCPY(destAddr:= ADR (SaveByte1) , srcAddr:= ADR(Byte1) , n:= 1 );
END_IF
Update:Smt like that: save input into pointer, save also saved value (new value with thich you compare to the pointer) that compare that..
Code:
VAR
Input_Byte1 AT%IB1 : BYTE; //our read variable
new_Byte1 : BYTE;//variable into which we save it
pBUf1 : POINTER TO UDINT; //pointer for our variable
pBuf2 : POINTER TO UDINT;//pointer to variable where we save readed variable
delta : UDINT := 5;
END_VAR
pBuf1 := Input_Byte1;
pBuf2 :=new_Byte1
CASE nSTEP OF
0:
MEMCPY(destAddr:=ADR (new_Byte1), srcAddr := ADR(Input_byte1),n:=1);
nStep :=1;
1:
IF ((pbuf1- pBuf2) > delta) OR ((pBuf1 - pbuf2 < (-delta)) THEN
MEMCPY(destAddr:=ADR (new_Byte1), srcAddr := ADR(Input_byte1),n:=1); //save if delta
END_IF
END_CASE