Obsidean_VM/01-Documentation/SIEMENS & WINCC/PLC Siemens/Read DI indirectly.md

2.5 KiB

#readdi #read_di #pointers

CreateAnyPointer:

#Pointers #CreateAnyPointer

!Pasted image 20231017112006.png

FB905 - Supervisor Henkel

      L     P##o_anyAddress
      LAR1
// I prepare the ANY parameter of the pointer
      L     WORD#16#1002         // h10 Standard Siemens, 02 = Byte
      T W [ AR1 , P#0.0 ]
      L     #i_udiLength         // Byte number to copy
      T W [ AR1 , P#2.0 ]
      L     #i_DB                // Reference DB
      T W [ AR1 , P#4.0 ]
      L     #i_udiStartByte
      SLD   3
      L     P#DBX0.0
      OW
      T D [ AR1 , P#6.0 ]

FC Read DI:

#FCReadDI #Pointers

     L     #Address
      L     0
      ==I
      SPB   fine

      L     #Address
      L     1
      ==I
      SPB   fin2


      L     #Address
      L     10
      /I
      T     "MD240"
      L     "MW242"
      SLW   3
      L     "MW240"
      +D
      T     #punt
      U E [ #punt]
      =     #Input
      BEA

fine: NOP 0
      R     #Input
      BEA
fin2: NOP 0
      S     #Input
      BEA
      U     #Mot_DB.CFG_VIS_SA
      SPBN  SA
      CALL  "FC Read DI"
         Address :=#Mot_DB.CFG_Add_Signal_SA
         Input   :=#Mot_DB.IN_Signal_SA
SA:   NOP 0

The address is given as an integer 235 for example. Then this FC convert the integer as a pointer to E23.5 and return the input as a Return.

IF #Address = 0 THEN
    #Input := FALSE;
    #ReadDI := FALSE;
    RETURN;
END_IF;

IF #Address = 1 THEN
    #Input := TRUE;
    #ReadDI := TRUE;
    RETURN;
END_IF;

#DMem := INT_TO_DWORD(#Address / 10);
#punt := SHL( IN:=#WMem[1],N:=3) + #WMem[0];
  U E [ #punt]
  =     #Input
  =     #ReadDI

Controlar lo siguiente:

#byte1 := BYTE_TO_DWORD(PEEK(area := 16#1, dbNumber := 0, byteOffset := #InterfaceParam1 + 1));

!Pasted image 20231019093044.png

Ultima version:


// FC Read DI: Reads peripheral inputs from the Input parameter. Converts the UINT XXXXX to XXXX.X and returns the XXXX.X value, except
// in the special cases where the addresses are 0 and 1.
// 
// FC Read DI: Legge gli input periferici dal parametro Input. Converte l'UINT XXXXX in XXXX.X e restituisce il valore XXXX.X, eccetto
// nei casi speciali in cui gli indirizzi sono 0 e 1.

CASE #Address OF
    0:
        #Input := FALSE;
    1:
        #Input := TRUE;
    ELSE
        #Input := PEEK_BOOL(area := 16#81, dbNumber := 0, byteOffset := (#Address / 10), bitOffset := UINT_TO_INT(#Address MOD 10));
END_CASE;