beautypg.com

Delta RMC151 User Manual

Page 388

background image

RMC70/150 and RMCTools User Manual

MyPos

:=

Avg4

(

_Axis[0].ActPos

,

_Axis[1].ActPos

,

_Axis[2].ActPos

,

_Axis[3].ActPos

);

Declaration

(*

Returns the average of the 4 input parameters.

*)

FUNCTION

Avg4

: REAL

VAR_INPUT

Val1

: REAL;

Val2

: REAL;

Val3

: REAL;

Val4

: REAL;

END_VAR

Avg4

:= (

Val1

+

Val2

+

Val3

+

Val4

) / 4.0;

END_FUNCTION

Example 3
Converts polar coordinates to cartesian coordinates.

Usage

Polar2Cart

(

radius

,

angle,x

,

y

);

Declaration

(*

Converts polar coordinates r, theta to cartesian coordinates x,

y. Theta is in the interval [0,360) degrees.

*)

FUNCTION

Polar2Cart

: BOOL

VAR_INPUT

r

: REAL;

//radius

theta

: REAL;

//angle in degrees [0,360)

END_VAR

VAR_OUTPUT

x

: REAL;

y

: REAL;

END_VAR

IF

theta

= 0.0 OR

theta

= 180.0

THEN

x

:=

r

;

y

:= 0.0;

ELSEIF

theta

= 90.0 OR

theta

= 270.0

THEN

x

:= 0.0;

368

Delta Computer Systems, Inc.

This manual is related to the following products: