[?]: Convert Double Word To Bool

SIMATIC S7-200/300/400, Step7, PCS7, CFC, SFC, PDM, PLCSIM,
SCL, Graph, SPS-VISU S5/S7, IBHsoftec, LOGO ...
ELYAS_GH
Posts: 35
Joined: Mon Jan 23, 2012 11:05 am

[?]: Convert Double Word To Bool

Post by ELYAS_GH »

Hello
How to convert double word to bit in Siemens plc s7؟
PCS7 V 8.1
Thank you
SHKODRAN
Posts: 199
Joined: Wed Dec 24, 2008 4:37 pm
Location: Europe

Re: [?]: Convert Double Word To Bool

Post by SHKODRAN »

ELYAS_GH wrote: Sat Aug 27, 2022 3:26 am Hello
How to convert double word to bit in Siemens plc s7؟
PCS7 V 8.1
Thank you
Here you go.

Code: Select all

FUNCTION FC2 : VOID

VAR_INPUT
IN: DWORD;
END_VAR

VAR_OUTPUT
OUT: INT;
END_VAR
VAR_TEMP
s,i: INT;
END_VAR

s:=0;

FOR i:= 0 TO 31 DO
s:=s+DWORD_TO_INT(ROR(IN:=IN,N:=i) AND dw#16#1);
END_FOR;

OUT:=s;

END_FUNCTION