User Tools

Site Tools


en-us_products:mpino_studio2:box_functions

This is an old revision of the document!


MPINO STUDIO 2 Phase 4 · Box Functions

This page explains how to enter and edit box functions, when they run, and which box functions MPINO Studio 2 provides.

This page explains how to enter and edit box functions, when they run, and which box functions MPINO Studio 2 provides.

1. Box Function Editor

The box function editor is where you find a command and complete its arguments. Each marker points to the item described below.

The box function editor is where you find a command and complete its arguments. Each marker points to the item described below.

  • Category: Choose a command group such as Timer, Counter, or Arithmetic.
  • Command list: Choose a command in the selected category.
  • Command input: Enter the command and its arguments on one line.
  • Description: Check the selected command's behavior, arguments, and example.
  • OK and Cancel: Save the input to the cell or discard the change.

2. Choose and Enter a Command

Choose a category and a command. The editor fills in the command template and selects its first argument. Enter a value and press Tab to move to the next argument. Separate the command and arguments with spaces.

  1. Select a ladder cell and press Ctrl + Enter to create a box function.
  2. Choose a category and command in the editor.
  3. Enter the selected argument, then press Tab for the next argument.
  4. Press Enter or OK when the command is complete.

3. Edit an Existing Command

To edit an existing box function, select its cell and press Enter, or double-click it. Choosing another command replaces the entire input with that command's template. OK saves the change; Cancel restores the value from before editing.

4. Contact Condition and Execution

The ON or OFF state from the contacts on the left is the box function's input. Arithmetic, transfer, bit, conversion, SET, RST, and free-form commands run while it is ON. Timers and counters also receive the OFF state and update their current and done states by command. With no contact, the input is always ON. Use a positive-edge contact when a cumulative command such as INC D0 should run once.

The ON or OFF state from the contacts on the left is the box function's input. Arithmetic, transfer, bit, conversion, SET, RST, and free-form commands run while it is ON. Timers and counters also receive the OFF state and update their current and done states by command. With no contact, the input is always ON. Use a positive-edge contact when a cumulative command such as ''INC D0'' should run once.

5. Structured and Free-form Input

Structured commands are the 44 commands registered in the palette; each has a fixed syntax and argument count. Free-form input accepts an assignment, expression, or Arduino function call that you enter directly.

Type Example When to use
Structured MOV D0 D1 Choose a palette command and fill in its displayed arguments
Free-form D0 = readSensor() Enter a supported expression or call a function written in Arduino code

6. Box Function List

Category Command Function
Timer Box Functions TON Accumulates time while the input is ON and turns the done state ON at the set value.
TOFF Turns the done state ON immediately with the input.
TPL Turns the done state ON when the input changes to ON.
TMON Starts one pulse when the input turns ON and holds the done state ON for the set time.
TMR Accumulates time while the input is ON.
TAON Provides the same on-delay behavior as TON with a 100 ms tick.
TAOFF Provides the same off-delay behavior as TOFF with a 100 ms tick.
TAPL Provides the same input-held pulse behavior as TPL with a 100 ms tick.
TAMON Provides the same one-shot pulse behavior as TMON with a 100 ms tick.
TAMR Provides the same retentive behavior as TMR with a 100 ms tick.
Counter Box Functions CTU Increments the current value once whenever the left condition changes from OFF to ON.
CTD Preloads the current value with the set value, then decrements it once on each rising edge of the left condition.
CTUD While the left condition is ON, a rising edge on the up input adds one and a rising edge on the down input subtracts one.
Bit and Latch Box Functions SET When the left condition is ON, stores ON in an M bit or a P bit configured as an output and holds it after the condition turns OFF.
RST When the left condition is ON, stores OFF in an M bit or a P bit configured as an output.
Arithmetic Box Functions ADD Adds two values and stores the result in the destination.
SUB Subtracts the second value from the first and stores the result in the destination.
MUL Multiplies two values and stores the result in the destination.
DIV Divides the first value by the second and stores the quotient.
MOD Divides the first value by the second and stores the remainder.
INC Increments the destination by one and stores it back at the same address.
DEC Decrements the destination by one and stores it back at the same address.
SCALE Linearly maps an integer from an input range to an integer output range.
FLOOR Stores the greatest integer that is not larger than the source.
SQRT Stores the square root of the source.
Transfer Box Functions MOV Copies one source value to the destination.
GMOV Copies a contiguous range of D, C, or T WORD values to a destination range in the same order.
FMOV Reads one D, C, or T WORD address and fills a contiguous destination WORD range with that value.
Bitwise Operation Box Functions WAND Applies bitwise AND to two WORD values and stores the result.
WOR Applies bitwise OR to two WORD values and stores the result.
WXOR Applies bitwise XOR to two WORD values and stores the result.
WNOT Inverts every bit in the source WORD and stores the result.
SHL Shifts a WORD left and stores the result.
SHR Logically shifts a D WORD right and stores the result.
ROL Rotates a D, C, or T WORD left.
ROR Rotates a D, C, or T WORD right.
Conversion Box Functions INV Inverts every bit in the source WORD and stores the result.
NEG Reverses the sign of the source value and stores the result.
H2D Interprets a source WORD containing four BCD digits as a decimal integer and stores the result.
D2H Converts a decimal integer from 0 to 9999 into four-digit BCD and stores it in a WORD.
Logic Control Box Functions JMP When the left condition is ON, moves to a later label in the same ladder and skips the ladder rows between.
JMPN When the left condition is OFF, moves to a later label in the same ladder.
MCS Starts a master control zone at a level from 0 to 15.
MCSCLR Ends the master control zone at the specified level and any inner zones.
Free-form Box Functions Free-form Box Functions D0 = D0 + 1 · R0 += 1.5 · D0 = readSensor()

7. Check Build Errors

An invalid command or argument appears as a build error. Check the ladder name and row in the message, then reopen that box function.

Symptom What to check
Unknown command Check the command spelling and the structured-command list
Wrong argument count Check the command syntax and spaces on its detail page
Address or type error Check the memory kind and data format in Phase 2
Possible division by zero Check the divisor or input range used by DIV, MOD, or SCALE
en-us_products/mpino_studio2/box_functions.1788944070.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki