The objective of this tutorial is to explain how to use P and N contacts 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
P and N contacts are special contacts used to detect signal transitions, allowing logic to be activated only at the instant of the state change, and not while the signal remains on or off.
They function similarly to R_TRIG and F_TRIG blocks, but in a simpler and more direct way, as they are implemented directly as contacts in the Ladder logic.
Concept and operation
P Contact (positive edge)
- Detects the transition from FALSE to TRUE.
- Closes the contact only for one sweep cycle during the rising edge of the signal.
- Even if the signal remains TRUE, the contact reopens in the next cycle.
Negative Edge Contact (N)
- Detects the transition from TRUE to FALSE.
- Closes the contact only for one cycle during the falling edge of the signal.
- Ideal for actions that should occur when a button is released.
Usability in logic
The P and N contacts are indicated when:
- The logic requires instantaneous action
- It is not desired to keep the signal active
- A simpler solution is sought, without the use of function blocks
Inserting P and N contacts into the logic
Insertion is done from a conventional contact already existing in the logic:
- Insert a normally open (NO) contact using the conventional methods already presented.
- Click on the contact to select it.
- Right-click.
- Access the Edge Detection option.
- With each click, the contact will alternate between:
- Conventional Contact
- P Contact (positive edge)
- N Contact (negative edge)
Repeat the command until you reach the desired contact type.
Figure 2. Insertion of contacts with P/N pulse detection
Difference compared to R_TRIG / F_TRIG:
P and N contacts do not require an instance variable, as they are not function blocks. This reduces the number of variables and simplifies the program.
Important note:
- P and N contacts operate for only one scan cycle.
- They do not replace conventional contacts in logics that need to maintain state.
- They are ideal for one-off events and momentary commands.
P and N contacts offer a quick and efficient way to implement edge detection directly in Ladder logic, keeping the program clean, simple, and easy to understand.
Figure 3. Operation of P/N contacts
Comments
0 comments
Please sign in to leave a comment.