Sunday, May 14, 2023

Set / Reset Function

Water level controller


Set-Reset functions with ladder logic are represented in this simple example. The purpose is to demonstrate how a Programmable Logic Controller (PLC) can automatically control the water flow entering and exiting a water tank, maintaining a specific water level. The system consists of two solenoid valves, S1 and S2, connected to the water lines, which control the inlet and outlet flow respectively. Additionally, two float switches, F1 and F2, are installed at the top and bottom of the tank to indicate the upper and lower water levels.

When the upper-level float switch, F1, is activated, it sends a 'Water level high' signal to the PLC. Conversely, the lower-level float switch, F2, addresses a 'Water level low' signal. The circuit is operated using push switches SW1 and SW2, which turn the entire system on and off. To initiate the process, the start button is pressed, causing the inlet valve to open and water to enter the tank. Once the water reaches a certain level inside the tank, the upper-level float switch, F1, is activated, resulting in the closure of the inlet valve to prevent further water from entering. Simultaneously, the outlet valve opens automatically, allowing water to drain out of the tank. This process continues until the water level inside the tank reaches its lower limit and activates the lower-level float switch, F2.

Upon receiving the signal from F2, the output valve closes, and the water inlet solenoid, S1, opens automatically, allowing water to enter the tank again. This process continues until the stop switch is pressed, disabling the entire system. The complete process is explained in the schematic diagram below. 



Input and Output Elements and Their Addresses in the Ladder Diagram

Input elements

  • Start switch (SW1) = I1.1
  • Stop switch (SW2) = I1.2
  • Upper-level Float witch (F1) = I1.3
  • Lower level Float switch (F2) = I1.4

 

Output elements

  • Water Inlet Solenoid valve (S1) = Q0.1
  • Water Outlet Solenoid valve (S2) = Q0.2

  

Interfacing of elements with PLC

The following picture depicts the hardware configuration and interfacing of various Input and Output elements with the PLC.


Ladder diagram

Below is a comprehensive Ladder diagram, consisting of four separate rungs, each presented independently.

Rung – 1 

In this rung, M1.0 is an "Internal Relay," also known as a "Flag" for SIEMENS make PLC. It is activated using the SET logical function. PLC operates with Retentive and Non-Retentive type Flags. M1.0 is a Non-Retentive type Flag, and its status becomes Logic-0 when the power supply to the PLC is turned off. The status of Flag M1.0 is verified as Logic-1 using inputs I1.1 and I1.2, which are implemented here as NO and NC Contacts with AND Logic. Pressing the start switch SW1 sets the M1.0 Flag to Logic-1, as SW2 is an NC Contact. The status of M1.0 remains Logic-1 even after releasing the switch SW1. 

Rung – 2 


The "RESET" logic is implemented for Flag M1.0 in this rung. Inputs I1.1 and I1.2 are used as NC and NO Contacts, respectively, performing an AND operation to reset the Flag. When the Stop switch SW2 is pressed, the status of M1.0 becomes Logic-0. If the Flag's status is already Logic-0, it remains unchanged.

 

Rung – 3 

Let's consider the water tank is initially empty, so the input status of I1.3 is Logic-0 and I1.4 is Logic-1. Pressing the switch SW1 sets M1.0 to Logic-1, and Q0.1 becomes High. M1.0, I1.1, and I1.3 (NC contact) work together with AND logic in this case. Releasing the switch SW1 keeps the output Q0.1 ON, as it acts as an NO Contact through OR Logic with I1.1 and I1.4, creating a latching circuit. Once Q0.1 becomes high or Logic-1, it energizes the water inlet solenoid S1, allowing water to enter the tank. This process continues until the accumulated water level triggers the upper-level float switch F1, causing Input I1.3 to become Logic-1. Once I1.3 becomes high, Q0.1 turns Logic-0 (since I1.3 is used here as NC logic), and solenoid S1 de-energizes, stopping the water from entering the tank. 

Rung – 4 

As water enters the tank, after some time, the Input I1.4 of the lower-level float switch F2 becomes Logic-0 and stays that way as the water level continues to rise. When the rising water level activates the float switch F1, I1.3 becomes Logic-1, causing Output Q0.2 to become Logic-1 and energizing the water outlet solenoid coil S2. In this case, Flag M1.0, I1.3, and I1.4 (NC contact) work together with AND logic. Water starts flowing out of the tank through the valve by energizing solenoid S2. As water flows out, after a while, F1 gets deactivated, changing its status to Logic-0, and the output Q0.2 remains activated. Q0.2 functions as a Contact, operating OR logic with Input I1.3, creating a latching circuit. This state continues until the lower-level float switch F2 is activated. Water stops flowing outward, and Output Q0.2 becomes Logic-0 as Input I1.4 becomes Logic-1. The program then follows the sequence described in Rung-3, as this state satisfies activating Q0.1, continuing the cycle. To stop the cycle or sequence of operation (automatic water inlet and outlet) at any point, pressing SW2 sets M1.0 to Logic-0 and de-energizes either solenoid valves S1 or S2. If we pause the cycle temporarily and the water level is between the upper and lower levels, pressing the SW1 switch will always turn the S1 solenoid ON.


Wednesday, May 3, 2023

Motor Starter program

This step-by-step ladder diagram PLC program demonstrates the control of a 3-phase induction motor. The program is presented in three to four steps, gradually introducing different input and output elements for easy comprehension. Let's begin by explaining the electrical circuit and hardware that control the motor. 

Hardware circuit

The circuit diagram below illustrates the hardware control circuitry of the induction motor. The electric circuit is divided into two sections: the Power section and the Control section. In the Power section, the motor is connected to the 3-phase AC power supply through an Overload Contact. The Control section incorporates two push-button switches for turning the motor ON and OFF. 

To activate the contactor and turn ON the motor, a 400V AC operating coil voltage is required. The voltage supplied to the contactor is obtained from two phases of the main supply line. One end of the Coil supply passes through the NC contact of an Overload, while the other end connects to a Start (NO contact) and Stop (NC contact) switch on the contactor. This means that completing the supply to the contactor coil involves passing through the start and stop switches, the overload contact, and connecting the other end to the L3 supply line. Once the start switch is pressed, the contactor is activated, allowing the 3-phase AC supply to be delivered to the motor terminals via the overload. As long as the start switch remains pressed, the contactor stays energized, and the motor continues to rotate.

Pressing the stop switch interrupts the voltage flow, de-energizing the contactor coil and disconnecting the supply voltage to the motor. To restart the motor, simply press the start switch again. In case of an overload, the NC contact of the overload interrupts the supply to the contactor coil, protecting the motor. Once the overload condition is resolved and reset, the connection is re-established.  

Ladder Programming

In the ladder diagram programming, the Power section of the previous circuit remains mostly the same, while the hardware control circuit is replaced by a PLC. The power section comprises the Motor, Contactor, Overload, and similar hardware circuitry as depicted in the previous circuit diagram. The following elements and addresses are used in the PLC ladder logic for motor control: 

  • Start Switch (NO contact, push switch) = I 1.2
  • Stop Switch (NO contact, push switch) = I 1.3
  • Overload Contact (NC contact) = I 1.4
  • Output Coil = Q 0.3

Here, two Normally Open (NO) push switches serve as the Start and Stop functions, connected to input addresses I1.2 and I1.3, respectively. The overload relay, with an NC contact, is assigned input address I1.4. The output coil, Q0.3, is responsible for energizing the motor contactor. The contactor used here operates with a 24V DC coil voltage instead of 400V AC. The coil is directly connected to the PLC's output module, which activates it to supply 3-phase AC to the motor through the overload.

In the ladder diagram, the inputs I1.2, I1.3, and I1.4 are combined using an AND logic function. The output Q0.3 is triggered and activated only when the input I1.2 (Start switch) is Logic-1. As both the input I1.4 (overload) and input I1.3 (stop switch) are NC contacts, the status of Q0.3 will be Logic-1 only when input I1.2 is Logic-1. The power flow diagram during the Press state of the Start switch is depicted in the image below: 

When the start switch is pressed, the output Q0.3 activates, and all input and output elements assume a Logic-1 status, represented by light grey color. Output Q0.3 is connected as a latching circuit with input I1.2. This means that when the start switch is released or the input status of I1.2 becomes Logic-0, the output Q0.3 remains ON, acting as a replacement for input I1.2 and functioning as a latching circuit. The power flow line of the ladder diagram, considering the current situation, is illustrated in the following image: 

Q0.3, acting as a latching circuit, energizes the motor contactor, ensuring the motor remains ON until the stop switch is pressed. When the stop switch is pressed and the input I1.3 becomes Logic-0 (as it functions as an NC contact), the output Q0.3 turns OFF (becomes Logic-0). The power flow line discontinues at this point, and it remains in this state until the start switch is pressed again. Regardless of whether the stop switch is ON or OFF, the output Q0.3 will no longer be Logic-1, and the circuit will return to the initial position. Pressing the start switch again will trigger the output status Q0.3 anew. The power flow line during the operating state of the stop switch is shown in the following image: 

Another input, I1.4, is implemented in the ladder diagram to stop the motor in case of an overload. This input is connected to an NC contact inside the overload. Under normal conditions, the input I1.4 remains Logic-1 (as an NC contact). However, in an overload situation, it opens, changing its status to Logic-0. Consequently, the output Q0.3 also becomes Logic-0, and this state persists until the overload is reset. Resetting the overload NC contact changes its status back to Logic-1, allowing the circuit to operate again. The power flow line during the overload state of the motor is illustrated in the following image:



Supplementary Coil / Output with a Ladder Diagram


Using a PLC to compute an additional element is advantageous as it offers versatility. Supplementary devices can easily connect to the existing circuit with minimal hardware changes, requiring only the addition of one or two rungs to the ladder diagram. In this case, two additional output elements, the Start and Stop indicator lamps representing the motor status (Q0.4 and Q0.5), are connected to the output module of the PLC. The modified ladder diagram, along with the necessary hardware changes, is illustrated in the picture.

 

In the previous diagram, the motor ON output Q0.3 functions as NO logic, aligning with the ON lamp output Q0.4. Similarly, the OFF lamp output Q0.5 functions as NC logic, resulting in a Logic-1 status. This means that when output Q0.3 is Logic-0, the 'motor OFF' lamp glows, and when it is Logic-1, the 'motor ON' lamp illuminates. The motor OFF lamp remains lit until the motor start switch is pressed or the output status Q0.3 becomes Logic-1. The picture below illustrates the power flow line during the motor's ON state.

 

Adding an Input with a Ladder diagram


Just as output elements can be easily added, input elements can also be coupled with a PLC effortlessly. In the following circuit, an additional 'Safety switch' is introduced, which can be considered as a signal indicating that the machine door is closed. The motor will not start unless the machine door is closed. The safety switch is Normally Open (NO) and is connected to input I1.5 using NO logic in the ladder diagram. The modified ladder diagram, along with the necessary hardware changes, is shown in the picture.

A simple 'Limit Switch' can serve as a safety switch. Input I1.5 is connected here as an AND logic with the existing diagram, activating the motor ON output Q0.3. Input I1.5 employs NO logic, and the motor ON output will not energize unless the input status I1.5 becomes Logic-1. The picture illustrates the power flow diagram during the activation of the safety switch.

 

Reverse-running the motor 

To enable the motor to rotate in the reverse direction, an additional input and output element need to be connected to the hardware circuit. An extra push switch with the address Input I1.6 is used to command the motor to run in the reverse direction. A separate Contactor with the output address Q0.6 will be activated to achieve the reverse rotation. The 'power circuit' of the motor requires some hardware changes for rotation in both directions. The pictures below explain the necessary modifications to the motor's hardware connections and the amendments to the ladder diagram programming. 

The push switch (Input I1.6) labeled 'Run reverse' is connected to initiate the motor's reverse rotation. The logical operation of energizing the reverse contactor coil (Q0.6) is similar to the motor's 'Start' operation. This means setting the output Q0.6 to Logic-1 and correlating the input I1.6 with an AND logic using inputs I1.3, I1.4, and I1.5. The Start operation corresponds to the 'Run forward' process of the motor, and a latching circuit is also functional with the output Q0.6, keeping it constantly ON after pressing the reverse run push switch. As depicted in the third ladder rung, Q0.6 and Q0.3 function as an 'OR' logic, resulting in a Logic-1 output status for Q0.4. This means that regardless of the motor's rotation direction, the 'Motor ON' lamp will glow. In the fourth ladder rung, Q0.6 and Q0.3 are connected with an AND logic, functioning as an NC contact and resulting in a Logic-0 output status for Q0.5 (motor OFF lamp) during either the forward or reverse operation. The picture illustrates the power flow line of the ladder diagram during the reverse rotation of the motor. 


Regarding the motor power connections, some modifications have been made using two Contactors, each engaging independently for the 'Forward' and 'Reverse' motor movements. A 3-Phase AC supply with L1, L2, and L3 phases is connected to the motor terminals M1, M2, and M3 during the 'Forward' motor movement. During 'Reverse' rotation (when the Reverse Contactor is energized), the L1, L2, and L3 supply lines will connect to the motor terminals with a phase change, and the motor terminals M1, M2, and M3 will connect to L3, L2, and L1, respectively. This change in the sequence of connections alters the phase and causes the motor to rotate in the reverse direction.

 

Star / Delta connection of induction motor


Running the motor with a Star and Delta configuration requires some hardware modifications to the motor power connections. A 3-phase induction motor typically has three separate coils and six power terminals. The power terminals of the motor coils are identified as U1-U2, V1-V2, and W1-W2 (see the picture below). In the Star configuration, a 3-phase AC voltage supply is connected to one side of each coil, while the other sides are shorted. In the Star contactor, the U1, V1, and W1 coil terminals are connected to the supply line through the C1 Contactor and the U2, V2, and W2 terminals are shorted when the C3 Contactor is activated. In the Delta configuration, the motor terminals U1 and V2, V1 and W2, and W1 and U2 are connected when the C2 Contactor is energized and connected to the supply line, while the C1 Contactor is initiated. The picture represents the Star/Delta configuration of a 3-phase induction motor. 

Three separate Contactors, C1, C2, and C3, are operational in the ladder diagram, and the main connector (C1) supplies the 3-phase AC power to the motor through an Overload Contact. C2 and C3 function to select the Star and Delta motor configurations, respectively. The ladder diagram is prepared based on the previous circuit configuration. 

The ladder diagram resembles the forward and reverse movement of the motor. An additional output Q0.2 is used to energize the 'Main contactor' C1, while Q0.3 and Q0.6 are used for Star and Delta operations of the motor, respectively. Both outputs Q0.3 and Q0.6 operate with an 'OR' logic (see the 4th rung), and output Q0.2 maintains a Logic-1 state when either of them is activated. The push switch inputs I1.2 and I1.6 serve as Star and Delta configurations for motor running. Pressing either the Star or Delta push switch activates the main contactor along with the respective Star or Delta contactor. A modification has been made in the logic, ensuring that either Q0.3 or Q0.6 is activated. In the 1st rung, Q0.6 functions as an NC contact with an AND operation among the remaining logic, energizing Q0.3. This means the Star Contactor will not activate unless the Delta Contactor is de-energized. In the 2nd rung, the Delta Contactor will not energize unless the Star Contactor is de-energized. This prevents a short circuit situation where both contactors are accidentally turned on simultaneously. Output Q0.4 is used for the 'Motor On lamp' and operates with an OR logic involving output Q0.2, activating it along with the Main Contactor.

Popular Posts