Overview: Two Categories of Five Languages
- Graphical Languages (Intuitive, similar to drawing)
Ladder Diagram (LD) – The most commonly used, suitable for logic control.
Function Block Diagram (FBD) – Suitable for process control.
Sequential Function Chart (SFC) – Suitable for sequential processes.
- Textual Languages (Similar to writing code)
Structured Text (ST) – Powerful, suitable for complex algorithms.
Instruction List (IL) – Similar to assembly language, now rarely used.
1. Ladder Diagram – Ladder Diagram (LD)
- Description: Originating from relay control circuits, composed of contacts, coils, and function blocks, it implements logic through the concept of “energy flow”. It is the most commonly used PLC language.
- Applicable Scenarios: Digital logic control, motor start/stop, interlocking circuits.
- Example: Classic “Start-Stop” Circuit
- Control Requirements: Press the start button (I0.0), the motor (Q0.0) runs; press the stop button (I0.1), the motor stops. The motor can maintain its state (self-locking) after running.
- Character Diagram:
|—[ I0.0 ]—[ /I0.1 ]—( Q0.0 )—| | | | |—[ Q0.0 ]————————-|
- [ I0.0 ]: Normally open contact (start button)
- [ /I0.1 ]: Normally closed contact (stop button, the “/” symbol indicates normally closed)
- ( Q0.0 ): Output coil (motor)
- —[ Q0.0 ]—: Parallel self-locking contact
- Program Explanation:
- When I0.0 is pressed (conducting), and I0.1 is not pressed (normally closed contact defaults to conducting), the “energy flow” can pass through, energizing the coil Q0.0.
- After Q0.0 is energized, its own normally open contact [ Q0.0 ] closes, forming a self-lock. At this point, even if I0.0 is released, the circuit remains conducting.
- When the stop button I0.1 is pressed, its normally closed contact opens, cutting off the “energy flow”, Q0.0 loses power, the motor stops, and the self-lock is released.
2. Function Block Diagram – Function Block Diagram (FBD)
- Description: Uses function blocks (such as logic gates, timers, counters, etc.) and connecting lines to represent control logic. Signals flow from left to right.
- Applicable Scenarios: Process control, analog signal processing.
- Example: Simple Alarm Circuit
- Control Requirements: When the temperature is too high (I0.2) and the pressure is too high (I0.3), trigger an alarm indicator light (Q0.1), and the alarm needs to last for 5 seconds before automatically extinguishing.
- Character Diagram:
+———+ +—————–+ | I0.2 | | TP | +——-+ |———|—->|IN Q ELapsed|—>| Q0.1 | | I0.3 | | |PT T#5s | +——-+ |———|–|->| | +———+ +—————–+ AND Function Block Pulse Timer Function Block
- AND: AND logic function block, all inputs must be 1 for the output to be 1.
- TP: Pulse timer function block, when there is a rising edge at the IN terminal, the Q terminal outputs a pulse lasting the preset time (5 seconds).
- Program Explanation:
- I0.2 (high temperature) and I0.3 (high pressure) are connected as inputs to an AND function block.
- AND block’s output is connected to the TP (pulse timer) IN terminal. The timer’s PT (preset time) is set to 5 seconds (T#5S).
- When both temperature and pressure are too high, the AND block outputs 1, triggering the timer, and the timer’s output Q will immediately output a “1” signal lasting 5 seconds.
- This 5-second pulse signal drives the alarm indicator light Q0.1 to light up, which automatically extinguishes after 5 seconds.
3. Sequential Function Chart – Sequential Function Chart (SFC)
- Description: Describes the execution sequence of the program in the form of a flowchart, consisting of “steps” and “transitions”. Very suitable for sequential control.
- Applicable Scenarios: Robotic arms, assembly lines, and other processes with a clear sequence.
- Example: Automatic reciprocating motion of a cylinder
- Control Requirements:
- Step 1: Cylinder moves forward (Q0.2=ON) until the front limit (I0.4).
- Step 2: Delay for 2 seconds.
- Step 3: Cylinder moves backward (Q0.3=ON) until the rear limit (I0.5), then loops.
- Character Diagram:
[Initial Step S0] (Action: None) | |I0.6 (Start)| V [Step S1]——->(Action: SET Q0.2 //Forward) | |I0.4 (Front Limit)| V [Step S2]——->(Action: TON (T#2S) //Delay) | |T0.Q (Timer Done)| V [Step S3]——->(Action: SET Q0.3 //Backward) | |I0.5 (Rear Limit)| V |<———–(Jump back to S1)
- [Step]: Represents a stable working state.
- |Condition|: Transition condition, when the condition is true, it transitions from the current step to the next step.
- (Action: …): Actions executed within that step.
- Program Explanation:
- Program starts from S0, when the start signal I0.6 is valid, it transitions to S1.
- In S1 step, set Q0.2 (cylinder forward). Until the front limit I0.4 is triggered, it transitions to S2.
- In S2 step, start a 2-second timer. When the timer time is up T0.Q=1, it transitions to S3.
- In S3 step, set Q0.3 (cylinder backward). Until the rear limit I0.5 is triggered, the program directly jumps back to S1, starting a new cycle.