The objective of this tutorial is to explain how to insert and use the MUX operator in a MasterTool X project.
Components
Equipment: 1 computer/notebook.
Software: MasterTool X
Tutorial Sections
- ARCHITECTURE
- DEVELOPMENT
1. ARCHITECTURE
A computer/notebook will be required to use MasterTool X.
Figure 1. Computer running MasterTool X
2. DEVELOPMENT
MUX is a logical operator used for selecting values, but with an important characteristic: it allows selection between multiple inputs, not just two.
MUX is widely used when there is a need to choose a value from several possible values, using a numerical index to define which input will be sent to the output.
Functionality
The MUX (Multiplexer) operator functions as a multiple value selector.
It uses a numerical selection value to determine which of the available inputs will be sent to the operator output.
Unlike the SEL operator, which works with only two options, the MUX allows selection between several inputs, such as:
- IN0
- IN1
- IN2
- IN3
- among other possibilities depending on the configuration.
This makes the operator very useful for applications where there are multiple setpoints, operating modes, or process references.
How to Insert into Code
To use the MUX operator in the program, it must be inserted directly into the program logic through the toolbox:
- Open the Toolbox
- Go to the Other Operators category
- Locate the MUX operator
- Drag the operator to the programming area
- Define the variable or constant that will be used in the K input
- Parameterize the values in the IN0, IN1, IN2, IN3 inputs, as needed
- Use the OUT output in the program logic
Figure 2. Inserting the MUX operator into the code
Input Parameters
K (Index)
Defines which input will be selected.
- Data type: integer (INT, DINT, etc.)
- The value of this variable determines which input will be sent to the output.
Example:
| Value of K | Selected Input |
| 0 | IN0 |
| 1 | IN1 |
| 2 | IN2 |
| 3 | IN3 |
IN0, IN1, IN2, IN3...
These are the available values for selection.
- All inputs must have the same data type
- They can be variables or constants
- The selected value will depend on the value of input K
Output Parameters
OUT
- Data type: same type as the inputs
- Represents the value selected from the available inputs
The operator sends the value corresponding to the input indicated by index K to OUT.
Operation Logic
The operator's behavior can be represented as follows:
- If K = 0, then OUT = IN0
- If K = 1, then OUT = IN1
- If K = 2, then OUT = IN2
- If K = 3, then OUT = IN3
In this way, the operator functions as a signal multiplexer, directing a specific value to the output.
Figure 3. MUX Operator Parameterization
Application Example
Consider a system where a device can operate at four different speeds, selected by an operating index.
Operator Configuration:
- K = Speed_Selector
- IN0 = Low_Speed
- IN1 = Medium_Speed
- IN2 = High_Speed
- IN3 = Maximum_Speed
Operating Table:
| Selector Value | Applied Speed | Value in Numbers |
| 0 | Low_Speed | 10 |
| 1 | Medium_Speed | 50 |
| 2 | High_Speed | 70 |
| 3 | Maximum_Speed | 100 |
Thus, depending on the value defined in the Speed_Selector, the MUX operator sends the corresponding speed to the block output.
Figure 4. Operation of the MUX operator
Applications in Automation
The MUX operator is widely used in situations such as:
- Selection between multiple setpoints
- Choice between several sensors
- Selection of operating modes
- Control of process parameters
- Systems with multiple levels of operation
In short, the MUX operator allows selecting a value from several inputs using a numerical index, being an extremely useful tool for implementing multiple reference selection within the control logic in projects developed in MasterTool X.
Comments
0 comments
Please sign in to leave a comment.