한국어 | English
Functions are ladder instructions that take up several cells, such as comparisons, math, timers and counters. You can pick them from the Functions panel or type the instruction in the Insert Function window.
A function runs while the condition to the left of the function block is ON, and power continues to the right of the block according to the result. Comparison functions are placed in the row like contacts and pass power when the comparison is true.
Click the Functions button on the symbol rail or press Alt+2 to open the Functions panel.
Press Ctrl+E, Ctrl+Enter or [, or select Edit → Insert Function, to open the Insert Function window.
MOVE D0 D1, ADD D0 20 D1, TON T0 1s[TON] [IN] [SV], TON: On Delay Timer, the operating condition and an input example). If no function matches, No matching instruction. is shown.Enter to insert the function at the cursor cell.Enter, or simply start typing a value, to change just that argument.Enter to open the Edit Function window, where you can edit the whole instruction on one line.If an address in an argument does not match the data type the function expects (bit, byte, word, double word or real), the cell turns red. Hover over the cell to see the reason.
The timer set value (SET VALUE) is in units of 10 ms. TON T0 100 and TON T0 1s are the same 1-second setting, and the block shows it as 1S.
P0: the timer start conditionTON T0 1s: while the condition is ON, the current value of T0 increases, and when it reaches the set value (1 second), T0 turns ON. When the condition turns OFF, the current value returns to 0.T0 contact: passes power to the next rung when the timer is ON.P33: the timer output| Function | Action |
|---|---|
| TON | On Delay Timer — turns ON when the condition has stayed ON for the set time or longer. When the condition turns OFF, the current value becomes 0. |
| TOFF | Off Delay Timer — stays ON for the set time after the condition turns OFF. |
| TPL | Pulse Timer — turns ON when the condition turns ON, for up to the set time. If the condition turns OFF first, it turns OFF too. |
| TMON | Pulse Extended Timer — turns ON for the set time when the condition turns ON. It stays ON for the full set time even if the condition turns OFF in the meantime. |
| TMR | Accumulative Timer — accumulates the time the condition is ON. The current value remains when the condition turns OFF, so clear it from another rung to reset it. |
The arguments of CTU are COUNT (counter address), SET VALUE (set value) and RESET (reset bit), in that order. Example: CTU C0 5 P2
C0 increases by 1.C0 turns ON.P2) is ON, the current value becomes 0.
The arguments of CTD (DOWN Counter) are COUNT, SET VALUE and SET, and it turns ON when the current value reaches 0.
Comparison functions (==, >, U< and so on) compare two values and pass power when the result is true. For example, >= D0 100 is true when D0 is 100 or more (signed comparison). MOVE (block name MOV) copies the value of IN to OUT.
The 16 categories of the Functions panel and their functions are listed below. The argument order is shown in parentheses.
| Category | Functions |
|---|---|
| Comparison | == (equal) · != (not equal) · > · < · >= · ⇐ — signed comparison, U> · U< · U>= · U⇐ — unsigned comparison (IN1, IN2) |
| Conversion | H2D (hex → decimal) · D2H (decimal → hex) · INV (ones' complement) · NEG (two's complement) (IN, OUT) |
| Math | ADD · SUB · MUL (IN1, IN2, OUT) · DIV (IN1, IN2, OUT, REM) · INC · DEC (IN) · SCALE (IN, IN_MAX, IN_MIN, OUT, OUT_MAX, OUT_MIN) · FLOOR · SQRT (IN, OUT) |
| Counter | CTU (COUNT, SET VALUE, RESET) · CTD (COUNT, SET VALUE, SET) · CTUD (COUNT, CU, CD, SET VALUE, RESET) · HCNT (CHANNEL, OUT) · HRST (CH) · ENCODER (CHANNEL, OUT) · ENMOV (CHANNEL, IN) |
| Timer | TON · TOFF · TPL · TMON · TMR (TIMER, SET VALUE) |
| Logic Control | JMP · JMPN · LABEL (LABEL) · END |
| Word Logic | WAND · WOR · WXOR (IN1, IN2, OUT) · SHL · SHR (IN, N, OUT) · SWAP (IN, OUT) |
| Analog | ADC · ADC2 (4 to 20 mA) · DAC (CHANNEL, MAX VALUE, MIN VALUE, OUT) · AFILTER (IN, WEIGHT, OUT) · NTEMP · PTEMP (CHANNEL, OUT) · PWM (PORT, DUTY, WIDTH) · FPWM (PORT, FREQ) · FDPWM (PORT, FREQ, DUTY) · NPWM (PORT, FREQ, N) · POFF (PORT) · PSR (OUT) · PID (PV, SV, KP, KI, KD, OUT MAX, OUT MIN, MV) · PID_PWM (PORT, PV, SV, KP, KI, KD, MV) |
| MOVE | MOVE (IN, OUT) · GMOVE · FMOVE (IN, OUT, N) |
| Data Processing | MAX · MIN · SUM · AVE · MUX · ENCO · DECO (IN, OUT, N) |
| Program Control | MCS · MCSCLR (NUM) |
| Serialport | PUT (CHANNEL, DATA, LENGTH) · GET (CHANNEL, LENGTH, OUT) · PUT_LEN · GET_LEN (CHANNEL, OUT) · SERID (CHANNEL, ID) · SERRATE (CHANNEL, RATE) · MNET (CH) · MNET_READ (RATE, ADD) |
| I2C | ISTA (ADDRESS, READ) · ISTP · IWR (DATA) · IRD (OUT, ACK) · ISR (OUT) · IBR (IN) |
| CLCD (Character LCD) | CINI (ADR, TYPE) · CLOC (ADR, X, Y) · CSTR (ADR, STRING) · CINT · CREAL (ADR, IN, DIGIT, ZERO, SIGN) · CHEX (ADR, IN, DIGIT, ZERO) · CCLS · CCON · CCOF (ADR) · CLON · CLOF · CPUT (ADR, ID, DEFINE) · CGET (ADR, ID) |
| 7Segment | FINI (CLK, DIO) · FINT (IN, POSITION, LENGTH, DOT, ZERO, SIGN) · FDATA (DATA, POSITION) |
| DS3231 (RTC) | DS3231_WR · DS3231_RD (YEAR, MONTH, DATE, DAY, HOUR, MINUTE, SECOND) |
Analog, pulse and temperature functions can be used only on models or expansion modules that have that feature. The range of channel numbers depends on the selected model.