en-us_products:mp_studio:functions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en-us_products:mp_studio:functions [2026/11/05 10:13] – external edit 127.0.0.1en-us_products:mp_studio:functions [2026/11/13 13:42] (current) – external edit 127.0.0.1
Line 9: Line 9:
 ===== Functions Panel ===== ===== Functions Panel =====
  
-Click the **Functions** button on the symbol rail or press ''Alt+2'' to open the Functions panel.+Press ''Alt+2'' to open the Functions panel. The **Functions** button on the symbol rail opens the Insert Function window instead.
  
 {{ :en-us_products:mp_studio:fn-panel-marked.svg?300 |Figure 2. The Functions panel (with the Timer category expanded) }} {{ :en-us_products:mp_studio:fn-panel-marked.svg?300 |Figure 2. The Functions panel (with the Timer category expanded) }}
Line 16: Line 16:
   * **② Category header:** click to expand or collapse the category. Each category has its own color, and the number on the right is the number of functions in it.   * **② Category header:** click to expand or collapse the category. Each category has its own color, and the number on the right is the number of functions in it.
   * **③ Function row:** double-click to insert the function at the cursor cell.   * **③ Function row:** double-click to insert the function at the cursor cell.
-  * **④ Mark list:** the bookmarks in the program.+  * **④ Bookmark List:** the bookmarks in the program.
  
 {{ :en-us_products:mp_studio:fn-panel-search.png?300 |Figure 3. The Functions panel filtered by TON }} {{ :en-us_products:mp_studio:fn-panel-search.png?300 |Figure 3. The Functions panel filtered by TON }}
Line 25: Line 25:
  
   - In **① Instruction**, type the function name followed by its arguments, separated by spaces. Examples: ''MOVE D0 D1'', ''ADD D0 20 D1'', ''TON T0 1s''   - In **① Instruction**, type the function name followed by its arguments, separated by spaces. Examples: ''MOVE D0 D1'', ''ADD D0 20 D1'', ''TON T0 1s''
-  - As you type the name, **② the argument order and a description** are shown (for example ''[TON] [IN] [SV]'', ''TON: On Delay Timer'', the operating condition and an input example). If no function matches, **No matching instruction.** is shown.+  - As you type the name, **② the argument order and a description** are shown (for example ''[TON] [IN] [SV]'', ''TON: On Delay Timer'', the operating condition and an input example). If no function matches, **No matching instructions** is shown.
   - Click **OK** or press ''Enter'' to insert the function at the cursor cell.   - Click **OK** or press ''Enter'' to insert the function at the cursor cell.
  
Line 37: Line 37:
 {{ :en-us_products:mp_studio:fn-edit-box.png?540 |Figure 5. The Edit Function window for editing the whole instruction }} {{ :en-us_products:mp_studio:fn-edit-box.png?540 |Figure 5. The Edit Function window for editing the whole instruction }}
  
-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.+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. How to use an indexed address such as ''D100[D0]'' in an argument is described in [[:en-us_products:mp_studio:indexed_address|Indexed Addresses (Pointers)]] (V1.3.0 and later).
  
 ===== Timers ===== ===== Timers =====
  
-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''.+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''. In a project whose [[:en-us_products:mp_studio:menus_settings#timer_base|timer base]] is set to 1 ms, the unit is 1 ms, so ''TON T0 100'' becomes 0.1 seconds (V1.3.0 and later).
  
 {{ :en-us_products:mp_studio:fn-timer-rung-marked.svg?1100 |Figure 6. A TON that turns P33 on after P0 has been held for 1 second }} {{ :en-us_products:mp_studio:fn-timer-rung-marked.svg?1100 |Figure 6. A TON that turns P33 on after P0 has been held for 1 second }}
Line 53: Line 53:
 | 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. | | 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. | | 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. |+| TPL | Pulse Timer — turns ON when the condition turns ON and stays 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. | | 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. | | 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. |
 +| TFLK | Flicker Timer (ON/OFF) — while the condition is ON, repeatedly turns on for the ON time and off for the OFF time. When the condition turns OFF, the output turns off and the current value becomes 0 (V1.4.0 and later). |
  
 ===== Counters ===== ===== Counters =====
Line 62: Line 63:
  
   * Each time the condition on the left goes from OFF to ON, the current value of ''C0'' increases by 1.   * Each time the condition on the left goes from OFF to ON, the current value of ''C0'' increases by 1.
-  * When the current value reaches the set value or more, ''C0'' turns ON.+  * When the current value is equal to or greater than the set value, ''C0'' turns ON.
   * When the bit given as RESET (''P2'') is ON, the current value becomes 0.   * When the bit given as RESET (''P2'') is ON, the current value becomes 0.
  
Line 77: Line 78:
 ===== Function List ===== ===== Function List =====
  
-The 16 categories of the Functions panel and their functions are listed below. The argument order is shown in parentheses.+The 17 categories of the Functions panel and their functions are listed below. The argument order is shown in parentheses.
  
 ^ Category ^ Functions ^ ^ Category ^ Functions ^
Line 84: Line 85:
 | 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) | | 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) | | 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) |+| Timer | ''TON'' · ''TOFF'' · ''TPL'' · ''TMON'' · ''TMR'' (TIMER, SET VALUE) · ''TFLK'' (TIMER, ON, OFF) |
 | Logic Control | ''JMP'' · ''JMPN'' · ''LABEL'' (LABEL) · ''END'' | | Logic Control | ''JMP'' · ''JMPN'' · ''LABEL'' (LABEL) · ''END'' |
-| Word Logic | ''WAND'' · ''WOR'' · ''WXOR'' (IN1, IN2, OUT) · ''SHL'' · ''SHR'' (IN, N, OUT) · ''SWAP'' (IN, OUT) |+| Word Logic | ''WAND'' · ''WOR'' · ''WXOR'' (IN1, IN2, OUT) · ''SHL'' · ''SHR'' (IN, N, OUT) · ''SWAP'' (IN, OUT) · ''ROL'' · ''ROR'' (IN, N, OUT) | 
 +| Bit Logic | ''FF'' (OUT) · ''BSFT'' (BIT, N, IN, DIR) · ''BRST'' · ''BSETN'' (BIT, N) · ''LOADB'' · ''LOADBN'' (IN, N) · ''BOUT'' · ''BSET'' · ''BRESET'' (OUT, N) · ''BMOV'' (IN, SB, OUT, DB, N) · ''BSUM'' (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) | | 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) | | MOVE | ''MOVE'' (IN, OUT) · ''GMOVE'' · ''FMOVE'' (IN, OUT, N) |
 | Data Processing | ''MAX'' · ''MIN'' · ''SUM'' · ''AVE'' · ''MUX'' · ''ENCO'' · ''DECO'' (IN, OUT, N) | | Data Processing | ''MAX'' · ''MIN'' · ''SUM'' · ''AVE'' · ''MUX'' · ''ENCO'' · ''DECO'' (IN, OUT, N) |
-| Program Control | ''MCS'' · ''MCSCLR'' (NUM) | +| Program Control | ''MCS'' · ''MCSCLR'' (NUM) · ''SSET'' · ''SOUT'' (GROUP, STEP) | 
-| 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) |+| Serial Port | ''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) · ''MBTRIG'' (NO) · ''UPTRIG'' (NO) |
 | I2C | ''ISTA'' (ADDRESS, READ) · ''ISTP'' · ''IWR'' (DATA) · ''IRD'' (OUT, ACK) · ''ISR'' (OUT) · ''IBR'' (IN) | | 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) | +| 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) · ''CSCR'' (ADR, PAGE) | 
-| 7Segment | ''FINI'' (CLK, DIO) · ''FINT'' (IN, POSITION, LENGTH, DOT, ZERO, SIGN) · ''FDATA'' (DATA, POSITION) |+| 7-Segment | ''FINI'' (CLK, DIO) · ''FINT'' (IN, POSITION, LENGTH, DOT, ZERO, SIGN) · ''FDATA'' (DATA, POSITION) · ''FSCR'' (DSP, PAGE) |
 | DS3231 (RTC) | ''DS3231_WR'' · ''DS3231_RD'' (YEAR, MONTH, DATE, DAY, HOUR, MINUTE, SECOND) | | 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. 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.
 +
 +''MBTRIG'' is described in [[:en-us_products:mp_studio:modbus_device_table|Modbus Device Table]], ''UPTRIG'' in [[:en-us_products:mp_studio:user_protocol|User Protocol]], ''CSCR'' in [[:en-us_products:mp_studio:lcd_screen_editor|CLCD Screen Editor]], ''FINI'', ''FINT'', ''FDATA'' and ''FSCR'' in [[:en-us_products:mp_studio:seven_segment|7-Segment Display]], and the Bit Logic category functions plus ''TFLK'', ''ROL'', ''ROR'', ''SSET'' and ''SOUT'' in [[:en-us_products:mp_studio:bit_control|Bit Control Functions]].
  
 ===== Related Pages ===== ===== Related Pages =====
Line 103: Line 107:
   * [[:en-us_products:mp_studio:memory_symbols|Phase 5 · Memory and Symbols]]   * [[:en-us_products:mp_studio:memory_symbols|Phase 5 · Memory and Symbols]]
   * [[:en-us_products:mp_studio:simulation|Phase 8 · Simulation]]   * [[:en-us_products:mp_studio:simulation|Phase 8 · Simulation]]
 +  * [[:en-us_products:mp_studio:bit_control|Bit Control Functions]]
  
 [[:en-us_products:mp_studio|← Back to the MP STUDIO 2 User Manual]] [[:en-us_products:mp_studio|← Back to the MP STUDIO 2 User Manual]]
  
en-us_products/mp_studio/functions.1793841188.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki