02 TwinCAT Ru

download 02 TwinCAT Ru

of 131

Transcript of 02 TwinCAT Ru

  • 7/26/2019 02 TwinCAT Ru

    1/131

    TwinCAT Training: Programmer 1

    TwinCAT-Training:

    BeckhoffIndustrial PC

    Beckhoff DriveTechnology

    BeckhoffLightbus

    BeckhoffTwinCAT

    Beckhoff Bus

    Terminal

    Beckhoff

    Fieldbus Box

    BeckhoffEmbedded PC

    Beckhoff

    PC Fieldbuscards,Switches

    BeckhoffEtherCAT

  • 7/26/2019 02 TwinCAT Ru

    2/131

    TwinCAT Training: Programmer 2

    IEC 61131-3 (3)

    (11)

    (14) (31)

    REAL TIME, TwinCAT System Service (36)

    (46)

    (54)ST - (67)

    IL , (90)

    SFC (113)

    IEC (145)

  • 7/26/2019 02 TwinCAT Ru

    3/131

    TwinCAT Training: Programmer 3

    IEC 61131-3 (3)

    1 .(, )

    2 . (, )

    3

    4 , , ,

    5 (3)

    6

    7

  • 7/26/2019 02 TwinCAT Ru

    4/131

    TwinCAT Training: Programmer 4

    HMI

  • 7/26/2019 02 TwinCAT Ru

    5/131

    TwinCAT Training: Programmer 5

    HMI

    Other systems

    ADS/AMS

    Ethernet, RS 232,Modem

    ADS OCX, ADS DLL,TwinCAT OPC

    , , , SystemManager, Scope View

  • 7/26/2019 02 TwinCAT Ru

    6/131

    TwinCAT Training: Programmer 6

    Win NT, 2000, XP

    PLC Server 1,

    PLC Server 2,PLC Server 3,PLC Server 4,NC Server,Cam Server

    ADS-, -

  • 7/26/2019 02 TwinCAT Ru

    7/131

    TwinCAT Training: Programmer 7

    DP RAM PAPLC

    O I

    F-Field-Device

    DP/PA

    F-ActuatorF-Sensor

  • 7/26/2019 02 TwinCAT Ru

    8/131

    TwinCAT Training: Programmer 8

    Main Motion

    Task1 Task2 Task1 Task2

    Program Program Program Program

    FB FB FB FB FB

  • 7/26/2019 02 TwinCAT Ru

    9/131

    TwinCAT Training: Programmer 9

    -

    Main Motion

    BC9020

    Task1 Task2 Task1

    Program Program Program

    FB FB FB FB

    TwinCAT System Manager

    : 1 run time , 1 BC9020 (Ethernet)

  • 7/26/2019 02 TwinCAT Ru

    10/131

    TwinCAT Training: Programmer 10

    (10)

    , ,

    ,

    (!,,,$..)

  • 7/26/2019 02 TwinCAT Ru

    11/131

    TwinCAT Training: Programmer 11

    (11)

    .

    :

    b Booleenr Reals - StringST_ -st FB_ -

    fb M_ -

    bEndschalterLinksrSollPositionsRxDaten

    ST_MotorDaten (declaration)stM1Parameter (instance)

    FB_Ueberlast (declaration)fbM1Ueberlast (instance)

    : ..

  • 7/26/2019 02 TwinCAT Ru

    12/131

    TwinCAT Training: Programmer 12

    IEC61131-3.

    .

    TRUE, FALSE, AND, FUNCTION,.... AutoFormat

    (* *) .

    , .: .

    (*digital inputs*)

    bStart AT%IX0.0:BOOL;(*machine start*)(*analog inputs*)TemK1 AT%IW10(*Byte 10-11*):WORD;

  • 7/26/2019 02 TwinCAT Ru

    13/131

    TwinCAT Training: Programmer 13

    ANY-Type

    (Bit)

    ..

    Boolean ANY_Bit BOOL 1 FALSE TRUE/FALSE

    Bit string (8) BYTE 8 0 0..16#FFBit string (16) WORD 16 0 0..16#FFFF

    Bit string (32) DWORD 32 0 0..16#FFFF_FFFF

    Short integer ANY_Num SINT 8 0 -27...27-1

    Integer INT 16 0 -215...215-1

    Double integer DINT 32 0 -231...231-1

    Unsigned shortinteger

    USINT 8 0 0...28-1

    Unsignedinteger

    UINT 16 0 0...216-1

    Unsigneddouble integer

    UDINT 32 0 0...232-1

  • 7/26/2019 02 TwinCAT Ru

    14/131

    TwinCAT Training: Programmer 14

    ANY-Type

    (Bit)

    . .

    Real ANY_Real REAL 32 0.0 -1.18*10-38

    ..3.4*1038

    Long real LREAL 64 0.0 -2.22*10-308..1.798*10308

    Date ANY_Date DATE (D) 32 D#1970-01-01

    Time of day TIME_OF_DAY(TOD)

    32 TOD#00:00 TOD#00:00..

    TOD#23:59

    Date

    Time

    DATE_AND_TIM

    E (DT)

    32 DT#1970-01-

    01-00:00

    Time ANY_Time TIME 32 T#0ms T#0ms..T#71582m47s295ms

    String ANY_String STRING (80+1)*8

  • 7/26/2019 02 TwinCAT Ru

    15/131

    TwinCAT Training: Programmer 15

    (15)

    BOOL 0,1 16#0, 16#1 TRUE (equal)

    BYTE, WORD,DWORD 10 16#0A 2#1010 (equal)

    DWORD, UINT 32768 16#8000 2#1000_0000 (equal)

    INT -10 --- ---

    TIME T#1h2m4s11ms, T#62m4s11ms, T#3724011ms (equal)

    REAL, LREAL 0.22, 2.2e-1 (equal)

    1000, 1000.0, 1e3 (equal)

    STRING ,

    Text$0D$0A, Text$R$N ()

  • 7/26/2019 02 TwinCAT Ru

    16/131

    TwinCAT Training: Programmer 16

    (16)

    STRING

    .

    .

    (1 255) , 80 .

    , ,

    ..

    VAR

    strVar :STRING(5);

    lenVar: INT;

    sizeVar: INT;

    END_VAR

  • 7/26/2019 02 TwinCAT Ru

    17/131

    TwinCAT Training: Programmer 17

    (17)

    ,LEN SIZEOF VAR

    strVar :STRING(5);

    lenVar: INT;

    sizeVar: INT;

    END_VAR

    Character

    LEN -

    SIZEOF

  • 7/26/2019 02 TwinCAT Ru

    18/131

    TwinCAT Training: Programmer 18

    , $.

    page feed$P or $pline break$R or $r

    single quotation mark$

    dollar signs$$

    line feed$L or $l

    new line$N or $n

    tab$T or $t

    CR LF

    CR LF

  • 7/26/2019 02 TwinCAT Ru

    19/131

    TwinCAT Training: Programmer 19

    ASCII CHR (19)

    ASCII ,

    :1.

    .

    2. ASC CHR,

    ChrAsc.lib.

  • 7/26/2019 02 TwinCAT Ru

    20/131

    TwinCAT Training: Programmer 20

    . .

    bStellerUntenLinks:BOOL:=TRUE;

    Identifier Data type Initial value

    (unlocated)

    .

  • 7/26/2019 02 TwinCAT Ru

    21/131

    TwinCAT Training: Programmer 21

    Identifier

    %M

    %Q

    %I

    .,

    .

    bStellerUntenLinks AT%IX0.0:BOOL;

    AT : ;

    AT X

    B

    W

    D

    Byte Data type

    Byte

    Bit

    (located)

    TwinCAT 2.8 .. bStellerUntenLinks AT%I*:BOOL;

    .

  • 7/26/2019 02 TwinCAT Ru

    22/131

    TwinCAT Training: Programmer 22

    Ain AT%IB0 : INT;IB1 IB0

    IW0

    Ain AT%IW0 : INT;

    Din0 AT%IX10.0 : BOOL;IX10.7 IX10.6 IX10.5 IX10.4 IX10.3 IX10.2 IX10.1 IX10.0

    IB10

    Posi AT%IB20 : UDINT;IB23 IB22

    Posi AT%ID20 : UDINT;

    IB21 IB20IW22 IW20

    ID20

    equal

    equal

    IX22.7 IX22.6 IX22.5 IX22.4 IX22.3 IX22.2 IX22.1 IX22.0

    :

    BitVar AT%IX22.1 : BOOL;

  • 7/26/2019 02 TwinCAT Ru

    23/131

    TwinCAT Training: Programmer 23

    , )

    .

    VAR ..

    END_VARVAR_INPUT ..

    END_VARVAR_IN_OUT ..

    END_VARVAR_OUTPUT ..

    END_VAR

    VAR_GLOBAL ..

    END_VARVAR_CONFIG ..

    END_VAR

    .

  • 7/26/2019 02 TwinCAT Ru

    24/131

    TwinCAT Training: Programmer 24

    VAR_CONFIG (24)

    .

    Mapping .

    TwinCAT System.

  • 7/26/2019 02 TwinCAT Ru

    25/131

    TwinCAT Training: Programmer 25

    (25)

    AlocVar B %MB2.

    PROGRAM A

    VAR

    END_VAR

    PROGRAM B

    VARlocVar AT%MB2:WORD;END_VAR

    LD %MB2

    :

  • 7/26/2019 02 TwinCAT Ru

    26/131

    TwinCAT Training: Programmer 26

    26)

    Var1.

    Var1.

    !

    PROGRAM A

    VARVar1 :WORD;

    END_VAR

    LD Var1

    :

    VAR_GLOBAL

    Var1:WORD;END_VAR

  • 7/26/2019 02 TwinCAT Ru

    27/131

    TwinCAT Training: Programmer 27

    (27)

    .

    :

    .

    VAR RETAIN VAR PERSISTENT

    Counter:UINT; Counter:UINT;END_VAR END_VAR

  • 7/26/2019 02 TwinCAT Ru

    28/131

    TwinCAT Training: Programmer 28

    (28)

    .

    VAR

    AccelerationTime : TIME := T#3s200ms;

    END_VAR

  • 7/26/2019 02 TwinCAT Ru

    29/131

    TwinCAT Training: Programmer 29

    () (29)

    ,

    .

    VAR_GLOBAL .. END_VARCONSTANT.

    !

    VAR_GLOBAL CONSTANTpi:REAL:=3.141592654;

    END_VAR

    PROGRAM A

    VAR CONSTANT

    END_VAR

    VAR_GLOBAL CONSTANT

    END_VAR

  • 7/26/2019 02 TwinCAT Ru

    30/131

    TwinCAT Training: Programmer 30

    (program organisation units) (30)

    IEC 61131-3 POU`s (PROGRAM ORGANISATION UNIT):

    Program

    Function block

    Function

    POU task configurator.

  • 7/26/2019 02 TwinCAT Ru

    31/131

    TwinCAT Training: Programmer 31

    PRG (31)

    PRG ()

    : , , ()

    : .. .

    : , VAR_INPUT

    : , but VAR_OUTPUT

    VAR_IN_OUT

    : online PLC Control

  • 7/26/2019 02 TwinCAT Ru

    32/131

    TwinCAT Training: Programmer 32

    FB (32)

    FB

    :

    : .. . .

    : 0,1,2,3 VAR_INPUT

    : 0,1,2,3 VAR_OUTPUT

    : 0,1,2,3 VAR_IN_OUT: online PLC Control

    . .

    : , .

  • 7/26/2019 02 TwinCAT Ru

    33/131

    TwinCAT Training: Programmer 33

    : FC (33)

    : FC ,

    :

    : , . .

    : 1,2,3........ VAR_INPUT

    : 1!, .

    . : 0,1,2,3 VAR_IN_OUT,

    : online PLCControl ???, .. .

    : (breakpoints)

    : , ., ......

  • 7/26/2019 02 TwinCAT Ru

    34/131

    TwinCAT Training: Programmer 34

    FC (34)

    - Scale.

    Scale

    (Write/Read)

  • 7/26/2019 02 TwinCAT Ru

    35/131

    TwinCAT Training: Programmer 35

    REAL TIME, TwinCAT System Service (35)

    The TwinCAT System Service Windows NT . , TwinCAT System Service

    Windows NT . TwinCAT System Service task bar

    . , TwinCAT.

    TwinCAT System Service TwinCAT run time .

    TwinCAT.

    TwinCAT stopped

    TwinCAT startingTwinCAT running

    TwinCAT Config Mode

  • 7/26/2019 02 TwinCAT Ru

    36/131

    TwinCAT Training: Programmer 36

    TwinCAT System Service (36)

    TwinCAT I/O TwinCAT System Service.

    . -

    .

    Log View . Event logging service

    , Windows NT.

  • 7/26/2019 02 TwinCAT Ru

    37/131

    TwinCAT Training: Programmer 37

    (37)

    Real time

    PLC cycle PLC cycle t

    tPLC cycle PLC cycle

    Win NT & HMI

    Real time (1 task)

  • 7/26/2019 02 TwinCAT Ru

    38/131

    TwinCAT Training: Programmer 38

    (38)

    TwinCAT real-time system TwinCAT System Service.

    real-time.1, TwinCAT800s .

    .

  • 7/26/2019 02 TwinCAT Ru

    39/131

    TwinCAT Training: Programmer 39

    Real time (39)

    .

    Real time

    (2 ms)

    t

    t

    (1ms)

    1 ms 2 ms 3 ms 4 ms 5 mse.g.:

    Win NT HMI

    1 2 3 41 2 31 2

  • 7/26/2019 02 TwinCAT Ru

    40/131

    TwinCAT Training: Programmer 40

    (40)

    .

    . TYPE END_TYPE.

    -

    Name Data type Initial value Range

    Name Data type Initial value Range

  • 7/26/2019 02 TwinCAT Ru

    41/131

    TwinCAT Training: Programmer 41

    ()

    , .

    Syntax:

    TYPE

    :;END_TYPE

    Example: Ads_Net_ID

    TYPE

    Net_ID:STRING(23);

    END_TYPE

  • 7/26/2019 02 TwinCAT Ru

    42/131

    TwinCAT Training: Programmer 42

    ()

    :. .

  • 7/26/2019 02 TwinCAT Ru

    43/131

    TwinCAT Training: Programmer 43

    ()

    , .

  • 7/26/2019 02 TwinCAT Ru

    44/131

    TwinCAT Training: Programmer 44

    (44)

    -. .

    .

    TYPE END_TYPE.

    Syntax:

    TYPE :( ,, ...,);END_TYPE

    Example:TYPE Week:(Mo, Di, Mi, Dn, Fr, Sa, So:=10);(*Mo = 0 Di = 1..

    .. Sa = 6 So = 10*)

    END_TYPETYPE Direction:(Up, Dn);(*Up = 0 Dn = 1*)END_TYPE

  • 7/26/2019 02 TwinCAT Ru

    45/131

    TwinCAT Training: Programmer 45

    (45)

    : .

  • 7/26/2019 02 TwinCAT Ru

    46/131

    TwinCAT Training: Programmer 46

    46) ENUM

    Enum

  • 7/26/2019 02 TwinCAT Ru

    47/131

    TwinCAT Training: Programmer 47

    (47)

    Pers_Data

    Name: Vorname:

    Alter: Anschrift:

    TYPE Pers_Data :STRUCT

    Name: STRING(25);

    Vorname: STRING(25);Alter: USINT;Anschrift: STRING(55);

    END_STRUCTEND_TYPE

  • 7/26/2019 02 TwinCAT Ru

    48/131

    TwinCAT Training: Programmer 48

    (48)

    P1

    P3

    K2

    VARP1, P3 : Pers_Data;

    END_VAR

    VAR_OUTPUTK2 : Pers_Data;END_VAR

    VAR_INPUT

    Employees: Pers_Data;END_VAR

    P1Name:=MllerFirst name:=Peter

    Age:=32Address:=Postweg 34

    P3Name:=KoschnikFirst name:=HeinzAge:=37Address:=Domplatz 10

    Name_Voll:=CONCAT(P3.First name,P3.Name)

    (*HeinzKoschnik*)

  • 7/26/2019 02 TwinCAT Ru

    49/131

    TwinCAT Training: Programmer 49

    (49)

    . ().

    -, -.

    VAR Feld_1 :ARRAY[0..9] OF BYTE; Feld_2 :ARRAY[0..9, 0..1] OF UINT; Feld_3 :ARRAY[0..9, 0..1,0..1] OF DINT;

    END_VAR

    VAR

    Feld_1 AT%MB100:ARRAY[1..10] OF BYTE;END_VAR

    Feld_1[2] := 120; (* *)Feld_2[i,j] := EXPT(i,j); (**)

  • 7/26/2019 02 TwinCAT Ru

    50/131

    TwinCAT Training: Programmer 50

    , (50)

    DBZeiten :ARRAY [0..6] OF TIME:= T#1s, T#2s, T#1s, 4(T#0s);

    Identifier Array Data type Initial value

    0 1 2 3 4 5 6

    T#1s T#2s T#1s T#0s T#0s T#0s T#0s

    Access:

    VAR

    WertAusArray : TIME;

    END_VAR

    WertAusArray := DBZeiten[1];

  • 7/26/2019 02 TwinCAT Ru

    51/131

    TwinCAT Training: Programmer 51

    ,

    Supportpoint:ARRAY [0..1, 0..6] OF REAL:= 0, 1.7, 2, 4(3.33), 6, 6(1.2);

    Identifier Field Date type Initial value

    0 1 2 3 4 5 6

    0 0 1.7 2 3.33 3.33 3.33 3.33

    1 6 1.2 1.2 1.2 1.2 1.2 1.2

    Access:

    VAR

    WertAusArray : REAL;

    END_VAR

    WertAusArray := Supportpoints[1 ,0];

  • 7/26/2019 02 TwinCAT Ru

    52/131

    TwinCAT Training: Programmer 52

    (52)

    :

    Drivingjobs:ARRAY [0..3, 0..1] OF LREAL:=

    (* Target position, Velocity *)

    (*Job 0*) 20.0, 30.0,

    (*Job 1*) 33.75, 30.0,

    (*Job 2*) 45.0, 30.0,

    (*Job 3*) 70.75, 30.0;

    ,

  • 7/26/2019 02 TwinCAT Ru

    53/131

    TwinCAT Training: Programmer 53

    , (53)

    Stuetzpunkte:ARRAY [0..1, 0..2, 0..3] OF UINT:=0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23;

    access:

    VAR

    WertAusArray : UINT;

    END_VAR

    WertAusArray :=

    Stuetzpunkte[ 1,1,3 ];

    [0,0,0]=0

    [0,0,1]=1

    [0,0,2]=2

    [0,0,3]=3

    [0,1,0]

    =4

    [0,1,1]

    =5

    [0,1,2]

    =6

    [0,1,3]

    =7[0,2,0]=8

    [0,2,1]=9

    [0,2,2]=10

    [0,2,3]=11

    [1,0,0]=12

    [1,0,1]=13

    [1,0,2]=14

    [1,0,3]=15

    [1,1,0]=16

    [1,1,1]=17

    [1,1,2]=18

    [1,1,3]=19

    [1,2,0]=20

    [1,2,1]=21

    [1,2,2]=22

    [1,2,3]=23

    ARRAY [0..1, 0..2, 0..3]

    ARRAY [0..1, 0..2, 0..3]

    ARRAY [0..1, 0..2, 0..3]

    )

  • 7/26/2019 02 TwinCAT Ru

    54/131

    TwinCAT Training: Programmer 54

    )

    .

    VARFeld_1 :ARRAY[1..10] OF BYTE;Feld_2 :ARRAY[1..10, 2..5] OF UINT;Feld_3 :ARRAY[1..10] OF DINT;

    END_VAR

    i:= 9 9Feld_1[i+2] := 120;

    Feld_1[9]; 0

    Feld_2[1,2]; 120

    CheckBounds (FUN) (55)

  • 7/26/2019 02 TwinCAT Ru

    55/131

    TwinCAT Training: Programmer 55

    CheckBounds (FUN) (55)

    .

    .

    i

    MinMax

    Limited

    value

    FUNCTION CheckBounds :DINT

    VAR_INPUT

    I,L,U : DINT;

    END_VAR

    IF I< L THEN

    CheckBounds := L;

    ELSIF I > U THEN

    CheckBounds := U;

    ELSE

    CheckBounds := I;

    END_IF

    Error case

    Error case

    OK case

    CheckBounds 1 (FUN) (56)

  • 7/26/2019 02 TwinCAT Ru

    56/131

    TwinCAT Training: Programmer 56

    CheckBounds 1 (FUN) (56)

    CheckBounds Copy Project ( . ). Checkbounds .

    CheckBounds 2 (FUN) (57)

  • 7/26/2019 02 TwinCAT Ru

    57/131

    TwinCAT Training: Programmer 57

    CheckBounds 2 (FUN) (57)

    CheckBounds, :

    I,L U

    (CheckBounds) (DINT)

    .

    CheckBounds (FUN) (58)

  • 7/26/2019 02 TwinCAT Ru

    58/131

    TwinCAT Training: Programmer 58

    CheckBounds (FUN) (58)

    10

    10

    Checkbounds

    (

    )

    :

    :

  • 7/26/2019 02 TwinCAT Ru

    59/131

    TwinCAT Training: Programmer 59

    (59)

    Check division by 0

    CheckDivByte

    CheckDivWord CheckDivDWord

    CheckDivReal

    Check value ranges

    CheckRangeSigned

    CheckRangeUnsigned

    (see appendix)

    : (60)

  • 7/26/2019 02 TwinCAT Ru

    60/131

    TwinCAT Training: Programmer 60

    : (60)

    :

    Structure:TYPE DrillPos :STRUCT

    XPos: LREAL;FeedrateX: LREAL;AccelerationX: LREAL;DeccelerationX: LREAL;JerkX: LREAL;YPos: LREAL;FeedrateY: LREAL;AcceleartionY: LREAL;DeccelerationY: LREAL;JerkY: LREAL;FeedDrill: LREAL;Kuehlen: BOOL; (*Pump ?*)

    END_STRUCTEND_TYPE

    :

    Positions :ARRAY[0..100] OF DrillPos;

    : (61)

  • 7/26/2019 02 TwinCAT Ru

    61/131

    TwinCAT Training: Programmer 61

    : (61)

    Drillpos 55:

    MoveXAx (*FB Instanz*)

    (Execute:= TRUE,

    Position:= Positions[55].XPos ,

    Velocity:= Positions[55].FeedrateX

    Acceleration:= Positions[55].AccelerationX,

    Deceleration:= Positions[55].DeccelerationX,

    Jerk:= Positions[55].JerkX,

    Direction:= .........,Axis:= .............,

    );

    ST - (62)

  • 7/26/2019 02 TwinCAT Ru

    62/131

    TwinCAT Training: Programmer 62

    ST (62)

    () ()

    ()

    EXPT

    Negate -

    Bulid complements NOT

    Multiply *

    Divide /

    Modulo MODAdd +

    Subtract -

    ,=

    =

    BOOL AND AND

    BOOL XOR XOR

    BOOL OR OR

    (10/2*5 = 25 )

    ST - (63)

  • 7/26/2019 02 TwinCAT Ru

    63/131

    TwinCAT Training: Programmer 63

    ( )

    Instruction Example

    Assignment := Posvalue := 10;

    Call of function block Ton1(IN:=Start, PT:=T2s); Output:= Ton1.Q;

    RETURN RETURN;

    IF More details and examples on the followingpages

    CASE

    FOR

    WHILE

    REPEAT

    EXIT

    Empty instruction ;

    IF (64)

  • 7/26/2019 02 TwinCAT Ru

    64/131

    TwinCAT Training: Programmer 64

    ( )

    , .

    IF .

    GOTO

    :

    IF THEN

    ELSIF

    ELSE

    END_IF

    IF (65)

  • 7/26/2019 02 TwinCAT Ru

    65/131

    TwinCAT Training: Programmer 65

    ( )

    Yes

    No

    IF THEN

    ;

    END_IF

    IF(66)

  • 7/26/2019 02 TwinCAT Ru

    66/131

    TwinCAT Training: Programmer 66

    IF a>b THEN

    A;

    ELSEB;

    END_IF

    Yes

    No

    A B

    IF(67)

  • 7/26/2019 02 TwinCAT Ru

    67/131

    TwinCAT Training: Programmer 67

    IF 1 THEN

    A;

    ELSE

    IF 2 THEN

    B;

    ELSE

    IF 3 THEN

    C;ELSE

    D;

    END_IF

    END_IF

    END_IF A

    1

    YesNo

    B

    2

    Yes

    No

    3

    YesNo

    C

    D

    IF(68)

  • 7/26/2019 02 TwinCAT Ru

    68/131

    TwinCAT Training: Programmer 68

    IF 1 THEN

    A;

    ELSIF 2 THENB;

    ELSIF 3 THEN

    C;

    ELSE

    D;END_IF

    A

    1

    YesNo

    B

    2

    Yes

    No

    3

    YesNo

    C

    D

    IF(69)

  • 7/26/2019 02 TwinCAT Ru

    69/131

    TwinCAT Training: Programmer 69

    ?

    IF bVar THEN.

    IF a>b THEN

    .

    IF LEFT(STR:= strVar, SIZE:=7) = 'TwinCAT'THEN

    .

    IF Ton1.Q THEN

    .IF Ton1(IN:=bVar, PT:=T#1s ) THEN

    :

    !

    CASE (70)

  • 7/26/2019 02 TwinCAT Ru

    70/131

    TwinCAT Training: Programmer 70

    CASE OF

    1: 1

    2, 4, 6: 27..10: 3

    ..

    ELSE

    END_CASE;

    .

    1

    = 1

    Yes

    No

    2

    = 2

    or 4 or 6

    Yes

    No

    YesNo

    3

    = 7

    8 9 10?

    CASE :

  • 7/26/2019 02 TwinCAT Ru

    71/131

    TwinCAT Training: Programmer 71

    CASE State OF

    0: Q0:=TRUE;

    IF Transition THEN state := 1; END_IF

    1: Q1:=TRUE;

    IF Transition THEN state := 2; END_IF

    2: Q2:=TRUE;

    IF Transition THEN state := 3; END_IF

    3: Q3:=TRUE;

    IF Transition THEN state := 0; END_IFEND_CASE

    (Actions)

    (Transition)

    CASE (72)

  • 7/26/2019 02 TwinCAT Ru

    72/131

    TwinCAT Training: Programmer 72

    CASE State OF

    0: ;(*State=0*)

    IF THEN

    1: ;(*State=1*)

    2: ;(*State=2*)

    3: ;(*State=3*)

    END_CASE

    (72)

    IF State = 0

    IF State = 1

    IF State = 2

    IF State = 3

    CASE 73)

  • 7/26/2019 02 TwinCAT Ru

    73/131

    TwinCAT Training: Programmer 73

    )

    Enum-Typ:

    TYPE Steps :

    (INIT:=0, START, AUTOMATIC, END);

    END_TYPE

    CASE State OF

    INIT: ;(*State=0*)

    START: ;(*State=1*)

    AUTOMATIC: ;(*State=2*)

    END: ;(*State=3*)

    END_CASE

    state, online .

    VAR

    State:Steps;

    (* State:INT also possible*)

    END_VAR

    CASE :

  • 7/26/2019 02 TwinCAT Ru

    74/131

    TwinCAT Training: Programmer 74

    TYPE Steps :

    ( INIT:=0, START, AUTOMATIC, END);

    END_TYPE

    CASE State OF

    INIT: Q0:=TRUE;

    IF Transition THEN state := START; END_IF

    START: Q1:=TRUE;

    IF Transition THEN state := AUTOMATIC; END_IF

    AUTOMATIC: Q2:=TRUE;

    IF Transition THEN state := END; END_IF

    END: Q3:=TRUE;

    IF Transition THEN state := INIT; END_IF

    END_CASE

    .

    (actions)

    (Transition)

    Step

    CASE (75)

  • 7/26/2019 02 TwinCAT Ru

    75/131

    TwinCAT Training: Programmer 75

    ( )

    VAR CONSTANT

    Step1 : INT:= 0;

    Step2 : INT:= 1;

    Step3 : INT:= 2;Step4 : INT:= 3;

    END_VAR

    VAR

    State:INT;END_VAR

    CASE State OF

    Step1: ;(*State=0*)

    Step2: ;(*State=1*)

    Step3..Step4: ;(*State=2 oder 3*)

    END_CASE

    (76)

  • 7/26/2019 02 TwinCAT Ru

    76/131

    TwinCAT Training: Programmer 76

    . run time.

    :

    .

    real-time,

    . .

    1ms 2ms 3ms 4ms 5mse.g.:

    1 2 3 41 1 11 1

    Win NT

    () (77)

  • 7/26/2019 02 TwinCAT Ru

    77/131

    TwinCAT Training: Programmer 77

    EXIT,.

    -

    FOR SINT/INT/DINT

    WHILE BOOL

    REPEAT BOOL

    FOR (78)

  • 7/26/2019 02 TwinCAT Ru

    78/131

    TwinCAT Training: Programmer 78

    i (. ). ( BY)

    i ( TO), .

    FOR i:=1 TO 12 BY 2 DOField[i]:=i*2;(* *)

    END_FOR

    cycle n Start i:=Startvalue

    Instruction block

    cycle n

    i>Endvalue

    Yes

    No

    I:= i+ step width

    WHILE (79)

  • 7/26/2019 02 TwinCAT Ru

    79/131

    TwinCAT Training: Programmer 79

    WHILETRUE., .

    FALSE, WHILE.

    i:=0;WHILE i

  • 7/26/2019 02 TwinCAT Ru

    80/131

    TwinCAT Training: Programmer 80

    REPEAT(UNTIL).

    .

    i:=0;

    REPEATField[i]:=i*2;(*Instruction*)i:=i+1;

    UNTIL i>100

    END_REPEAT

    I:= i+ step width

    cycle n

    cycle n

    No Yes

    ST (81)

  • 7/26/2019 02 TwinCAT Ru

    81/131

    TwinCAT Training: Programmer 81

    TON1 (IN:= NOT TON1.Q , PT:=T#1s );

    Q0:= TON1.Q;

    VAR

    TON1:TON;

    END_VAR

    TON1(IN:= NOT TON1.Q, PT:=T#1s , Q=>Q0 );

    ST (() (82)

  • 7/26/2019 02 TwinCAT Ru

    82/131

    TwinCAT Training: Programmer 82

    TON1.IN:= NOT TON1.Q;

    TON1. PT:=T#1s;

    TON1();

    Q0:= TON1.Q;

    VAR

    TON1:TON;

    END_VAR

    ST)

  • 7/26/2019 02 TwinCAT Ru

    83/131

    TwinCAT Training: Programmer 83

    Result:=Scale (x:=Input, xug:=0.0, xog:=32767.0, yug:=0.0,yog:=100.0);

    (* equal:*)

    Result:=Scale (Input, 0.0, 32767.0, 0.0, 100.0);

    (* equal:*)Result:=Scale (

    x:= Input,

    xug:= 0.0,

    xog:= 32767.0,

    yug:= 0.0,

    yog:= 100.0

    );

    ST(84)

  • 7/26/2019 02 TwinCAT Ru

    84/131

    TwinCAT Training: Programmer 84

    Result := Scale (x:=Input, xug:=0.0, xog:=32767.0, yug:=0.0,yog:=100.0);

    (* equal:*)

    Result:=Scale (

    x:= Input,

    xug:= 0.0,

    xog:= 32767.0,

    yug:= 0.0,

    yog:= 100.0

    );

    SFC Sequential Function Chart (85)

  • 7/26/2019 02 TwinCAT Ru

    85/131

    TwinCAT Training: Programmer 85

    Only one step is active at atime

    The condition to change fromone step to another is thetransition.

    In the action must beprogrammed what should beexecuted during the activestep.

    Step

    Transition

    ActionN

    Qualifier

    Followingstep

    Transition

    ActionN

    Qualifier

    Action,

    Can be written in StructuredText, Instruction list, LadderDiagram, Function Block

    Diagram and in SequentialFunction Chart .

    Steps (86)

  • 7/26/2019 02 TwinCAT Ru

    86/131

    TwinCAT Training: Programmer 86

    The activity of a step can berequested with Stepname.X.

    The duration of the activity of astep can be requested withStepname.T

    Both are components of astructure, which are createdautomatically from PLCControl. At the programmingonly the stepname has to be

    defined Stepname.X and Stepname.T

    are local variable and can onlybe read.

    Init

    Transition

    ActionN

    Normalstep

    Step1

    Transition

    ActionN

    Initial step,active at the

    start

    Actions (87)

  • 7/26/2019 02 TwinCAT Ru

    87/131

    TwinCAT Training: Programmer 87

    Step1

    Transition

    bOutputN

    Action can be a variable oftype BOOL.

    The variable is TRUE byactivating the the step and

    FALSE by leaving the step.

    Transition

    Step1

    Transition

    ActionN

    Action, can be programmed in

    -> Structured Text,

    -> Instruction List,

    -> Ladder Diagram,

    -> Functionblock Diagram,CFC/FBD-> Sequential Function Chart, SFC

    Transition

    Actions, several allowed per step(88)

  • 7/26/2019 02 TwinCAT Ru

    88/131

    TwinCAT Training: Programmer 88

    Step1

    Transition

    N bOutput

    P STAction

    N LDAction

    R FBDAction

    Steps /alternative branches (89)

  • 7/26/2019 02 TwinCAT Ru

    89/131

    TwinCAT Training: Programmer 89

    Only one branch can becomeactive.

    Because only the left or theright branch is important, twotransitions are necessary

    before the combination.

    Step_a

    Init

    Transition

    ActionN

    Transition

    ActionN

    Transition

    Transition

    ActionNStep_b

    Steps /alternative branches(90)

  • 7/26/2019 02 TwinCAT Ru

    90/131

    TwinCAT Training: Programmer 90

    The branches need not tobe symmetrcial.

    Step_a

    Init

    Transition

    ActionN

    Transition

    ActionN

    Transition

    Transition

    ActionNStep_b

    Transition

    ActionN

    Step_c

    Steps /alternative branches (91)

  • 7/26/2019 02 TwinCAT Ru

    91/131

    TwinCAT Training: Programmer 91

    Branches can be skipped.

    Step_a

    Init

    Transition

    ActionN

    Transition

    ActionN Transition

    Steps /simultaneous branches (92)

  • 7/26/2019 02 TwinCAT Ru

    92/131

    TwinCAT Training: Programmer 92

    Both branches are processedsimultaneous.

    Step_a

    Init

    Transition

    ActionN

    Transition

    ActionN ActionNStep_b

    A transition at the

    beginning of thesimultaneous branch.

    A transitionat the end

    Dobble line,simbolises thesimulaneousbranch

    Steps /simultaneous branches (93)

    Si l b h d

  • 7/26/2019 02 TwinCAT Ru

    93/131

    TwinCAT Training: Programmer 93

    Simultaneous branches neednot to be symmetrical.

    Step_a

    Transition

    Transition

    ActionN

    ActionN

    Step_c

    ActionN

    Step_b

    Transition

    Transitions (94)

  • 7/26/2019 02 TwinCAT Ru

    94/131

    TwinCAT Training: Programmer 94

    A transition has to be of typeBOOL. Possibilities:

    boolean variable

    ST instruction

    programmed transition

    Init

    bVariable

    ActionN

    BOOLEANVARIABLE

    Step1

    A > B

    ActionN

    ST instruction:

    The result has to be oftype BOOL.

    Note:If the instructions are toolong, the display will beshorten automatically.

    Transitions (95)

    Programmed Transitions

  • 7/26/2019 02 TwinCAT Ru

    95/131

    TwinCAT Training: Programmer 95

    Programmed Transitions

    Init

    ActionN

    Step1ActionN

    GTANDA

    B

    INPUT0

    001Comment

    A > B

    Points toprogrammedtransition

    NOTHING CONNECT

    The result has to be of typeBOOL and is the transition

    With thismark its only acomment.

    Hides behind

    Possible: FBD, LD, IL, ST.

    Limitations: one network,one instruction sequence,

    Note for FB calls:All transisitions arepassed independentlyfrom the current step.

    Final-Scan (96)

    If a step is left the processing takes exactly one more cycle This behaviour can

  • 7/26/2019 02 TwinCAT Ru

    96/131

    TwinCAT Training: Programmer 96

    If a step is left, the processing takes exactly one more cycle. This behaviour canbe used for cleaningin the action. Example: Reset outputs.

    Step1.X

    001

    At the last pass the step.X =FALSE. Thus the variable

    Output is FALSE .

    Step1

    Go on

    ActionN

    Followingstep

    Transition

    ActionN

    Output

    Step.X

    Action processing

    t

    t

    1

    0

    1

    0

    1 cycle

    Final-Scan (97)

    At a certain action the final scan leads to an unwanted behaviour.

  • 7/26/2019 02 TwinCAT Ru

    97/131

    TwinCAT Training: Programmer 97

    At a certain action the final scan leads to an unwanted behaviour.

    Step1

    TRUE

    ActionN

    Behaviour:

    Counter := Counter +1;

    (*Counter increases at 2*)

    Step.X

    Action processing

    t

    t

    1

    0

    1

    0

    1 cycle1 cycle

    Remedy: the step flag is only for onecyle 1:

    IF Schritt1.X THENCounter := Counter +1;

    END_IF

    (*Counter increases at 1*)

    Qualifier (98)

    Controls the action processing after activating a step. N: Non Stored

  • 7/26/2019 02 TwinCAT Ru

    98/131

    TwinCAT Training: Programmer 98

    Controls the action processing after activating a step. N: Non Stored

    Step

    TRUE

    ActionNStep.X

    Action processing

    t

    t

    1

    0

    1

    0

    1 cycle

    N: Non Stored

    Context in FBD

    Step.X

    001

    Action processing

    Qualifier (99)

    Controls the action processing after activating a step. S: SET

  • 7/26/2019 02 TwinCAT Ru

    99/131

    TwinCAT Training: Programmer 99

    Controls the action processing after activating a step. S: SET

    Step

    TRUE

    ActionS

    Conetxt in FBD

    Step.X

    Action processing

    t

    t

    1

    0

    1

    0

    1 cycle

    Step.X

    001

    Action processing

    SRS

    R

    Qualifier (100)

    Controls the action processing after activating a step. R: RESET

  • 7/26/2019 02 TwinCAT Ru

    100/131

    TwinCAT Training: Programmer 100

    p g g p

    Step

    TRUE

    ActionR

    Context in FBD

    Step.X

    001

    Action processing

    SRS

    R

    Step.X

    Action processing

    t

    t

    1

    0

    1

    0

    1 cycle

    Qualifier (101)

    Controls the action processing after activating a step. D: DELAY

  • 7/26/2019 02 TwinCAT Ru

    101/131

    TwinCAT Training: Programmer 101

    p g g p

    Context in FBD

    Step.X

    Action processing

    t

    t

    1

    0

    1

    0

    Delay

    Step

    TRUE

    ActionD T#1s

    Step.X

    001

    Action processingTON

    IN

    PT ET

    Q

    T#1s

    Qualifier (102)

    Controls the action processing after activating a step. L: LIMITED

  • 7/26/2019 02 TwinCAT Ru

    102/131

    TwinCAT Training: Programmer 102

    p g g p

    Step

    TRUE

    Action

    Context in FBD

    Step.X

    Action processing

    t

    t

    1

    0

    1

    0

    Limited

    L T#1s

    Step.X

    001Action processing

    TON

    IN

    PT ET

    Q

    T#1s

    AND

    Qualifier (103)

    Controls the action processing after activating a step. P: PULSE

  • 7/26/2019 02 TwinCAT Ru

    103/131

    TwinCAT Training: Programmer 103

    Step

    TRUE

    Action

    Context in FBD

    P

    t

    t

    Step.X

    Actions processing

    1

    0

    1

    0

    1 cycle 1 cycle

    Step.X

    001

    Action processing

    R_TRIG

    Clk Q

    ATTENTION: A SECOND FLOW

    PROCESSES!

    Qualifier, Combinations (104)

    SD: Stored and delayed

  • 7/26/2019 02 TwinCAT Ru

    104/131

    TwinCAT Training: Programmer 104

    DS: Delayed and stored

    SL: Stored and time limited

    Sequential Function chart - step diagnosis(105)

    VAR

  • 7/26/2019 02 TwinCAT Ru

    105/131

    TwinCAT Training: Programmer 105

    SFCEnableLimit: BOOL;

    (*This variable is of the type BOOL. When it has the valueTRUE, the timeouts of the steps will be registered in SFCError.Other timeouts will be ignored.*)

    SFCInit: BOOL;

    (*When this boolean variable has the value TRUE the sequentialfunction chart is set back to the Init step. The other SFC flagsare reset too (initialization).The Init step remains active, but is not executed, for as long asthe variable has the value TRUE. It is only when SFCInit isagain set to FALSE that the block can be processed normally.*)

    Sequential Function chart - step diagnosis(106)

    SFCReset: BOOL;

  • 7/26/2019 02 TwinCAT Ru

    106/131

    TwinCAT Training: Programmer 106

    (* This variable, of type BOOL, behaves similarly to SFCInit.Unlike the latter, however, further processing takes place afterthe initialization of the Init step. Thus for example the

    SFCReset flag could be re-set to FALSE in the Init step *)

    Sequential Function chart - step diagnosis(107)

    SFCQuitError: BOOL;

  • 7/26/2019 02 TwinCAT Ru

    107/131

    TwinCAT Training: Programmer 107

    (* Execution of the SFC diagram is stopped for as long as thisboolean variable has the value TRUE whereby a possible timeout inthe variable SFCError is reset. All previous times in the active steps

    are reset when the variable again assumes the value FALSE.*)

    SFCPause: BOOL;

    (*Execution of the SFC diagram is stopped for as long as this booleanvariable has the value TRUE.*)

    SFCTrans: BOOL;

    (* This boolean variable takes on the value TRUE when a transition isactuated.*)

    Sequential Function chart - step diagnosis(108)

    SFCError: BOOL;

  • 7/26/2019 02 TwinCAT Ru

    108/131

    TwinCAT Training: Programmer 108

    (* This Boolean variable is TRUE when a timeout has occurred in aSFC diagram. If another timeout occurs in a program after the firstone, it will not be registered unless the variable SFCError is reset

    first.*)

    SFCErrorStep: STRING;

    This variable is of the type STRING. If SFCError registers a timeout,in this variable the name of the step is stored which has caused thetimeout.

    SFCErrorPOU: STRING;

    In case of timeout this variable of the type STRING contains the nameof the block in which a timeout has occurred.

    Sequential Function chart - step diagnosis(109)

    SFCCurrentStep: : STRING;

  • 7/26/2019 02 TwinCAT Ru

    109/131

    TwinCAT Training: Programmer 109

    This variable is of the type STRING. The name of the step isstored in this variable which is active, independently of the timemonitoring. In the case of simultaneous sequences the step is

    stored in the branch on the outer right.No further timeout will be registered if a timeout occurs and thevariable SFCError is not reset again.

    Sequential Function chart (110)

    SFCErrorAnalyzation: STRING;

    (* Thi i bl f STRING id h i i

  • 7/26/2019 02 TwinCAT Ru

    110/131

    TwinCAT Training: Programmer 110

    (* This variable, of type STRING, provides the transitionexpression as well as every variable in an assembledexpression which gives a FALSE result for the transition and

    thus produces a timeout in the preceding step. A requirementfor this is declaration of the SFCError flag, which registers thetimeout. SFCErrorAnalyzation refers back to a function calledAppedErrorString in the TcSystem.Lib library. The output string

    separates multiple components with the symbol |. *)

    Sequential Function chart (111)

    SFCTip: BOOL;

    SFCTi M d BOOL

  • 7/26/2019 02 TwinCAT Ru

    111/131

    TwinCAT Training: Programmer 111

    SFCTipMode: BOOL;

    (* This variables of type BOOL allow inching mode of the SFC.When this is switched on by SFCTipMode=TRUE, it is onlypossible to skip to the next step if SFCTip is set to TRUE. Aslong as SFCTipMode is set to FALSE, it is possible to skip evenover transitions.*)

    END_VAR

    Example Diagnosis (112)

  • 7/26/2019 02 TwinCAT Ru

    112/131

    TwinCAT Training: Programmer 112

    Declare variable

    Example Diagnosis (113)

    Set step attributes for the step to be observed.

  • 7/26/2019 02 TwinCAT Ru

    113/131

    TwinCAT Training: Programmer 113

    Example Diagnosis (114)

    T i t 1

  • 7/26/2019 02 TwinCAT Ru

    114/131

    TwinCAT Training: Programmer 114

    Tracing to 1

    Tip mode (115)

    Insert implicit variable:

  • 7/26/2019 02 TwinCAT Ru

    115/131

    TwinCAT Training: Programmer 115

    Effect:

    SFCTipMode SFCTip Transition Effect

    TRUE FALSE TRUE Process stays in current step

    TRUE TRUE TRUE Change to next step

    TRUE TRUE FALSE Change to next step

    FALSE TRUE FALSE Process stays in current step

    FALSE FALSE TRUE Change to next step

    Actions also in other IEC languages possible!(116)

    Mainprogram

  • 7/26/2019 02 TwinCAT Ru

    116/131

    TwinCAT Training: Programmer 116

    Action step2

    Action step1

    (117)

  • 7/26/2019 02 TwinCAT Ru

    117/131

    TwinCAT Training: Programmer 117

    Standard.LIB.

    .

    Standard blocks

    Function blocks Functions

    Timer

    Counter

    String functions

    Memory

    Trigger

    STFUP / CFC

  • 7/26/2019 02 TwinCAT Ru

    118/131

    TwinCAT Training: Programmer 118

    DWORDAND

    WORD

    AND

    BOOL AND

    STFUP / CFC

    FUP / CFC ST

  • 7/26/2019 02 TwinCAT Ru

    119/131

    TwinCAT Training: Programmer 119

    , (INT).

    - * /

    (

    4)

    , SEL(120)

  • 7/26/2019 02 TwinCAT Ru

    120/131

    TwinCAT Training: Programmer 120

    FUP / CFC

    :

    If Mode1 = TRUE , StrVarmodeMode1Selected

    .

    ST

    StrVarMode := SEL(Mode1, , Mode1Selected );

    SEL

    , MUX (121)

    FUP /CFC

  • 7/26/2019 02 TwinCAT Ru

    121/131

    TwinCAT Training: Programmer 121

    Online:

    integer,

    FUP /CFC

    ST:

    (122)

    ms

    ST

  • 7/26/2019 02 TwinCAT Ru

    122/131

    TwinCAT Training: Programmer 122

    :

    0.4 FALSE,

    >=0.5 TRUE

    bVar1:BOOL

    iT1:INT

    msrt1:REAL

    (123)(123)

    FUP / CFC ST

  • 7/26/2019 02 TwinCAT Ru

    123/131

    TwinCAT Training: Programmer 123

    20000.0

    Implicit conversion also

    possible

    INT up/down

    INT up/down

    ()

    R_TRIG F_TRIG(124)

    FUP

    /

    CLK

    R TRIG

  • 7/26/2019 02 TwinCAT Ru

    124/131

    TwinCAT Training: Programmer 124

    CLK BOOL Trigger input R_TRIG: Rising Edge,

    F_TRIG: Falling EdgeQ BOOL Signal output (one for 1 PLC cycle)

    /CFC

    ST

    Q

    CLK

    Q

    R_TRIG

    F_TRIG

    SR RS (125)

    SET1FUP

    /C

    SR

  • 7/26/2019 02 TwinCAT Ru

    125/131

    TwinCAT Training: Programmer 125

    SET1 BOOL Set SR: setRS: resetRESET1 BOOL Reset

    Q1 BOOL Output

    S

    T

    CFC

    RESET1

    Q1

    SET1

    RESET1

    Q1

    RS

    TON (126)

    INFUP

    /

  • 7/26/2019 02 TwinCAT Ru

    126/131

    TwinCAT Training: Programmer 126

    Q

    ET

    IN BOOL

    PT TIME Q BOOL

    ET TIME

    CFC

    ST

    TOF(127)

    FUP

    /IN

  • 7/26/2019 02 TwinCAT Ru

    127/131

    TwinCAT Training: Programmer 127

    ST

    CFC

    IN BOOL IN,

    PT TIME Q BOOL

    ET TIME

    Q

    ET

    PT

    TP (128)

    IN

    FUP

    /

  • 7/26/2019 02 TwinCAT Ru

    128/131

    TwinCAT Training: Programmer 128

    Q

    ET

    ST

    CFC

    IN BOOL , PT TIME

    Q BOOL

    ET TIME

    CTU (129)

    FUP

    /C

  • 7/26/2019 02 TwinCAT Ru

    129/131

    TwinCAT Training: Programmer 129

    ST

    CFC

    CU BOOL Count Up, Counter with edge atCU, output is set if

    counter value has thesame value as PV.

    RESET BOOL Reset

    PV UINT

    Q BOOL PV

    CV WORD

    CTD (130)

    FUP

    /C

  • 7/26/2019 02 TwinCAT Ru

    130/131

    TwinCAT Training: Programmer 130

    ST 0

    CFC

    CD BOOL Count Down, LOAD ,

    CD, Q = True.

    LOAD BOOL PV

    PV UINT

    Q BOOL 0

    CV UINT

    LOAD

    CD

    CTUD (131)

    FUP

    /CF

  • 7/26/2019 02 TwinCAT Ru

    131/131

    TwinCAT Training: Programmer 131

    CU

    RESET

    CV

    QD

    QU

    CV=PV

    ST

    CU BOOL Count UP, + CV UINT Current counter value

    CD BOOL Count DOWN, - CD CU,

    RESET BOOL Reset

    LOAD BOOL PV

    PV UINT

    QU BOOL PV

    QD BOOL 0

    FC