beautypg.com

Discrete i/o, Discrete i/o overview, Discrete inputs – Delta RMC151 User Manual

Page 389: E discrete i/o

background image

5 Programming

y

:=

r

;

ELSE

x

:=

r

*

COS

(

theta

* (

M_PI

/ 180.0));

y

:=

r

*

SIN

(

theta

* (

M_PI

/

180.0));

END_IF

Polar2Cart

:=

TRUE

;

END_FUNCTION

Example 4
Returns the index of the least significant bit that is set in a DWORD.

Usage

MyIndex

:=

LSB

(

MyDWORD

);

Declaration

(*

LEAST SIGNIFICANT BIT

returns the index of the least significant bit set in a DWORD.

*)

FUNCTION

LSB

: DINT

VAR_INPUT

DW_IN

: DWORD;

END_VAR

VAR

DW

: DWORD;

C

: DINT;

END_VAR

IF

DW_IN

<>

0

THEN

DW

:=

DW_IN

AND

DINT_TO_DWORD

(

DWORD_TO_DINT

(NOT

DW_IN

) +

1);

C

:= 0;

IF

(

DW

AND 16#FFFF0000) <> 0

THEN

C

:=

C

+ 16;

END_IF

IF

(

DW

AND 16#FF00FF00) <> 0

THEN

C

:=

C

+ 8;

END_IF

IF

(

DW

AND 16#F0F0F0F0) <> 0

THEN

C

:=

C

+ 4;

END_IF

IF

(

DW

AND 16#CCCCCCCC) <> 0

THEN

C

:=

C

+ 2;

END_IF

IF

(

DW

AND 16#AAAAAAAA) <> 0

THEN

C

:=

C

+ 1;

END_IF

LSB

:=

C

;

ELSE

LSB

:= -1;

END_IF

END_FUNCTION

5.15. Discrete I/O

5.15.1. Discrete I/O Overview

Discrete I/O are physical boolean inputs or outputs. General discrete I/O are available on the

following modules:

deltamotion.com

369

This manual is related to the following products: