This tutorial will show how to access individual bits of analog variables directly in MasterTool X, allowing you to manipulate specific parts of an integer or Word-type value.
Components
Equipment: 1 computer/laptop.
Software: MasterTool X
Tutorial Sections
- ARCHITECTURE
- DEVELOPMENT
1.ARCHITECTURE
A computer/laptop will be required to use MasterTool X.
Figure 1. Computer running MasterTool X
2.DEVELOPMENT
Accessing variable bits is widely used in automation applications where the goal is to optimize memory use and control multiple states within a single variable, commonly found in communication systems, signaling, and internal process control.
Concept
Variables of the type:
- INT
- WORD
are stored internally in binary form, meaning they consist of bits that can be accessed individually.
Access method
To access a specific bit of a variable, use the following syntax:
variable_name.bit
Examples:
temperatura.0→ accesses bit 0temperatura.5→ accesses bit 5
Application in Logic
Bits can be used directly in Ladder logic as boolean signals.
Practical example:
- Normally open contact:
temperatura.0 - Coil:
temperatura.5
Figure 2. Accessing bits of an analog variable
Example operation
By actuating bit 0 through the contact and bit 5 through the coil, both become TRUE within the variable.
Value interpretation
Each bit represents a power of 2:
- Bit 0 → 2⁰ = 1
- Bit 5 → 2⁵ = 32
If both are active:
1 + 32 = 33
That is, when viewing the complete variable:
temperatura = 33
Figure 3. Manipulating bits of an analog variable
Applications in automation
- Control of multiple states in a single variable
- Communication with devices
- Use of registers
- Memory optimization
- Control flags
Important notes
- More common in INT and WORD variables
- Each bit has a specific binary weight
- Avoid overwriting bits without control
- Allows detailed manipulation of the variable
Comments
0 comments
Please sign in to leave a comment.