OmronPLC Set and Reset Instruction Application Details
1. Overview of Set and Reset Instructions
In Omron PLC programming, Set (Set) and Reset (Reset) are two basic bit operation instructions used to control the state of output bits:
|
Instruction |
Function Description |
Characteristics |
|
Set (Set) |
Sets the specified bit variable to ON (1) state |
Once set, the bit will remain in the ON state until cleared by a reset instruction |
|
Reset (Reset) |
Sets the specified bit variable to OFF (0) state |
Clears the bit’s ON state, returning it to OFF state |
Note: In Omron PLC’s ST (Structured Text) language, Set and Reset instructions are typically written as SET and RSET.
2. Basic Syntax Format
1. Set Instruction Syntax
SET(BOOL_VARIABLE);
2. Reset Instruction Syntax
RSET(BOOL_VARIABLE);
Where BOOL_VARIABLE is a boolean type variable tag.
3. Variable Definitions (Tags)
VAR
// Input Signals
StartButton AT %IX0.0 : BOOL; // Start Button
StopButton AT %IX0.1 : BOOL; // Stop Button
EmergencyStop AT %IX0.2 : BOOL;// Emergency Stop Button
MotorOverload AT %IX0.3 : BOOL; // Motor Overload Signal
// Output Signals
MotorRun AT %QX0.0 : BOOL; // Motor Run Output
AlarmIndicator AT %QX0.1 : BOOL; // Alarm Indicator Light
SystemReady AT %QX0.2 : BOOL; // System Ready Indicator Light
// Internal Flags
MotorRunFlag : BOOL; // Motor Run Flag
AlarmFlag : BOOL; // Alarm Flag
SystemReadyFlag : BOOL; // System Ready Flag
// Timers
MotorStartTimer : TON; // Motor Start Delay Timer
AlarmBlinkTimer : TP; // Alarm Blink Timer
END_VAR
4. Application Scenarios and Program Examples
Application Scenario 1: Motor Start/Stop Control
Requirement Description: Implement motor start and stop control, requiring the motor to run continuously after starting until a stop signal is received.
// Motor Start/Stop Control Program
IF StartButton AND NOT EmergencyStop AND NOT MotorOverload THEN SET(MotorRunFlag); // Set Motor Run Flag
END_IF;
IF StopButton OR EmergencyStop OR MotorOverload THEN RSET(MotorRunFlag); // Reset Motor Run Flag
END_IF;
MotorRun := MotorRunFlag; // Output to actual motor control
Application Scenario 2: Alarm Latching and Reset
Requirement Description: When a fault is detected, the alarm flag should be latched and maintained until the operator confirms the reset.
// Alarm Latching and Reset Program
// Set alarm flag when overload is detected
IF MotorOverload THEN SET(AlarmFlag);
END_IF;
// Operator confirms reset of alarm
IF StopButton AND AlarmFlag THEN RSET(AlarmFlag);
END_IF;
// Alarm indicator light control (blinking)
AlarmBlinkTimer(IN := AlarmFlag, PT := T#500MS); AlarmIndicator := AlarmBlinkTimer.Q;
Application Scenario 3: System Status Management
Requirement Description: Manage system ready status, automatically setting and clearing the ready status under specific conditions.
// System Status Management Program
// Set ready flag after system initialization is complete
IF NOT EmergencyStop AND NOT MotorOverload THEN MotorStartTimer(IN := TRUE, PT := T#2S);
IF MotorStartTimer.Q THEN
SET(SystemReadyFlag);
END_IF;
ELSE
RSET(SystemReadyFlag);
MotorStartTimer(IN := FALSE);
END_IF;
SystemReady := SystemReadyFlag;
Application Scenario 4: Step Logic in Sequential Control
Requirement Description: In multi-step sequential control, use Set/Reset to achieve step transitions.
VAR
Step1 : BOOL;
Step2 : BOOL;
Step3 : BOOL;
StepComplete : BOOL;
END_VAR
// Sequential Control Step Logic
IF StartButton AND NOT Step1 AND NOT Step2 AND NOT Step3 THEN SET(Step1); // Start First Step
END_IF;
IF Step1 AND StepComplete THEN
RSET(Step1); // Clear First Step
SET(Step2); // Enter Second Step
END_IF;
IF Step2 AND StepComplete THEN
RSET(Step2); // Clear Second Step
SET(Step3); // Enter Third Step
END_IF;
IF Step3 AND StepComplete THEN
RSET(Step3); // Clear Third Step, process ends
END_IF;
5. Complete Program Example
PROGRAM MainProgram
VAR // Input Signals
StartButton AT %IX0.0 : BOOL;
StopButton AT %IX0.1 : BOOL;
EmergencyStop AT %IX0.2 : BOOL;
MotorOverload AT %IX0.3 : BOOL;
// Output Signals MotorRun AT %QX0.0 : BOOL;
AlarmIndicator AT %QX0.1 : BOOL;
SystemReady AT %QX0.2 : BOOL;
// Internal Variables MotorRunFlag : BOOL; AlarmFlag : BOOL; SystemReadyFlag : BOOL;
MotorStartTimer : TON;
AlarmBlinkTimer : TP; END_VAR
// Main Program Logic
// 1. Motor Control Logic
IF StartButton AND NOT EmergencyStop AND NOT MotorOverload THEN
SET(MotorRunFlag);
END_IF;
IF StopButton OR EmergencyStop OR MotorOverload THEN
RSET(MotorRunFlag);
END_IF; MotorRun := MotorRunFlag;
// 2. Alarm Management Logic
IF MotorOverload THEN
SET(AlarmFlag);
END_IF;
IF StopButton AND AlarmFlag THEN
RSET(AlarmFlag);
END_IF;
AlarmBlinkTimer(IN := AlarmFlag, PT := T#500MS); AlarmIndicator := AlarmBlinkTimer.Q;
// 3. System Status Logic
IF NOT EmergencyStop AND NOT MotorOverload THEN MotorStartTimer(IN := TRUE, PT := T#2S);
IF MotorStartTimer.Q THEN
SET(SystemReadyFlag);
END_IF;
ELSE
RSET(SystemReadyFlag);
MotorStartTimer(IN := FALSE);
END_IF;
SystemReady := SystemReadyFlag;
END_PROGRAM
6. Precautions for Use
- Priority Management: Ensure that reset conditions have a higher priority than set conditions in the program, especially in safety-related applications.
- Scan Cycle Impact: Set and Reset instructions take effect immediately within the current scan cycle, affecting subsequent logical judgments within the same cycle.
- Avoid Duplicate Operations: Do not perform Set/Reset operations on the same variable in multiple locations in the program to avoid logical confusion.
- Initialization Handling: All flags using Set/Reset should be properly initialized at the start of the program.
- Documentation: Add clear comments for each Set/Reset operation, explaining the conditions for setting and resetting.
》》》》》》》Previous Reviews《《《《《《《1. Detailed Explanation of Mitsubishi PLC Interrupt Control2. Detailed Explanation of Floating Point Applications in Mitsubishi PLC3. Mitsubishi FX Series PLC Closed Loop Control System for Constant Pressure Water Supply via Analog Modules4. Detailed Explanation of Data Types and Array Types in Mitsubishi FX Series PLC5. Detailed Explanation of CC-Link Communication Technology in Mitsubishi Q Series PLC6. Detailed Explanation of RS485 RTU Communication Control of Inverters via Mitsubishi FX3U7. Detailed Explanation of Modbus Communication Protocol8. Detailed Explanation of ST Language Instructions in Omron NJ Series PLC9. Omron NJ Series PLC Socket Communication Guide10. Omron NJ Series PLC Function Block (FB) Programming Guide》》》》》》》》END《《《《《《《《