F_CXNaviSwitch

F_CXNaviSwitch 1:

The function F_CXNaviSwitch converts the value of the CX1100 navigation switch into an enum value of type E_CX1100_NaviSwitch.

FUNCTION F_CXNaviSwitch: E_CX1100_NaviSwitch

VAR_INPUT
    iCX1100_IN : USINT
END_VAR

E_CX1100_NaviSwitch: Value of the CX1100 input 'IN'

Enum E_CX1100_NaviSwitch

TYPE E_CX1100_NaviSwitch : (
    e_CX1100_NaviSwitch_IDLE := 0,
    e_CX1100_NaviSwitch_MIDDLE := 16,

    (* clockwise in 45 degree steps *)
    e_CX1100_NaviSwitch_TOP := 1,
    e_CX1100_NaviSwitch_TOPRIGHT := 9,
    e_CX1100_NaviSwitch_RIGHT := 8,
    e_CX1100_NaviSwitch_BOTTOMRIGHT := 10,
    e_CX1100_NaviSwitch_BOTTOM := 2,
    e_CX1100_NaviSwitch_BOTTOMLEFT := 6,
    e_CX1100_NaviSwitch_LEFT := 4,
    e_CX1100_NaviSwitch_TOPLEFT := 5,

    (* clockwise in 45 degree steps with middle switch pressed *)
    e_CX1100_NaviSwitch_MIDDLE_TOP := 17,
    e_CX1100_NaviSwitch_MIDDLE_TOPRIGHT := 25,
    e_CX1100_NaviSwitch_MIDDLE_RIGHT := 24,
    e_CX1100_NaviSwitch_MIDDLE_BOTTOMRIGHT := 26,
    e_CX1100_NaviSwitch_MIDDLE_BOTTOM := 18,
    e_CX1100_NaviSwitch_MIDDLE_BOTTOMLEFT := 22,
    e_CX1100_NaviSwitch_MIDDLE_LEFT := 20,
    e_CX1100_NaviSwitch_MIDDLE_TOPLEFT := 21
END_VAR 

Values other than those defined in enum (e.g. 11) are displayed as "*** INVALID: value ***" in online mode (e.g. "*** INVALID: 11 ***"). The function F_CXNaviSwitch then returns the invalid value (e.g. 11).

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v3.1.0

CX (x86)

Tc2_SystemCX