0% found this document useful (0 votes)
4 views8 pages

PLC Programming Notes

This document serves as a comprehensive guide for students learning PLC programming, covering fundamentals, architecture, programming languages, and practical examples. It details key components of PLCs, the IEC 61131-3 programming standards, and offers best practices for programming and troubleshooting. The guide emphasizes the importance of safety, documentation, and hands-on practice with tools like TIA Portal.

Uploaded by

Cynthia Mutare
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views8 pages

PLC Programming Notes

This document serves as a comprehensive guide for students learning PLC programming, covering fundamentals, architecture, programming languages, and practical examples. It details key components of PLCs, the IEC 61131-3 programming standards, and offers best practices for programming and troubleshooting. The guide emphasizes the importance of safety, documentation, and hands-on practice with tools like TIA Portal.

Uploaded by

Cynthia Mutare
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

PLC PROGRAMMING

Learning Notes

Complete Guide for Students

Covering:
Fundamentals • Architecture • Programming Languages
Ladder Logic • TIA Portal • Practical Examples

1. Introduction to PLCs
What is a PLC?
A Programmable Logic Controller (PLC) is an industrial digital computer designed to perform
specific tasks in manufacturing and process control environments.

Key Characteristics:
• Rugged and reliable for harsh industrial environments
• Real-time processing of inputs and outputs
• Programmable using standardized languages (IEC 61131-3)
• Modular design allowing easy expansion
• Continuous operation with minimal downtime

Common Applications:
• Assembly line automation
• Process control (temperature, pressure, flow)
• Building automation (HVAC, lighting)
• Water and waste treatment systems
• Packaging and labeling machines

2. PLC Architecture and Components


Basic Components
Component Function
CPU Executes the program, manages I/O, handles timing
Memory Stores program code and data (ROM for program, RAM for runtime)
Input Module Reads signals from sensors and switches (digital/analog)
Output Module Sends signals to actuators (motors, solenoids, lights)
Power Supply Provides regulated DC power to all components

PLC Scan Cycle


The PLC operates in continuous loops called scan cycles:
1. Input Scan
Read all input devices and store values in input image table
Typical duration: 5-50 ms
2. Program Scan
Execute the control program using current input values
Update internal variables and output image table
3. Output Scan
Transfer output image table values to output modules
Energize/de-energize output devices

3. IEC 61131-3 Programming Languages


IEC 61131-3 is the international standard for programmable controllers. It defines 5 main
programming languages:

1. Ladder Logic (LD) - Graphical


The most popular language, mimics electrical relay circuits. Uses rungs with contacts and coils.

2. Structured Text (ST) - Text-based


Similar to Pascal or C, used for complex logic and calculations.

3. Function Block Diagram (FBD) - Graphical


Uses blocks representing functions with inputs and outputs connected by lines.

4. Instruction List (IL) - Text-based


Similar to assembly language, rarely used in modern systems.

5. Sequential Function Chart (SFC) - Graphical


Used for state machines and sequential processes.
4. Ladder Logic Programming
Ladder Logic is the foundation for most industrial automation. It represents control circuits
graphically.

Basic Elements
Element Symbol Function
NO Contact (—|—) Reads input (true when ON)
NC Contact (—|/—) Inverted input (true when OFF)
Coil (—( )—) Output or internal variable
Set Coil (—(S)—) Sets coil to ON, stays ON
Reset Coil (—(R)—) Resets coil to OFF, stays OFF

Logic Operations
AND Logic (Series)
All contacts must be true for output to energize
Example: Switch1 AND Switch2 → Motor starts only when BOTH are ON

OR Logic (Parallel)
Any contact being true will energize output
Example: Switch1 OR Switch2 → Motor starts when EITHER is ON

NOT Logic (Negation)


Inverts the logic of a contact
Example: NOT Switch → Output ON when switch is OFF

5. Basic Programming Concepts


Variables and Data Types
Input Variables (Read-Only)
Represent physical inputs from sensors and switches
Format: I0.0 (Input byte 0, bit 0)

Output Variables (Write-Only)


Control physical outputs to actuators
Format: Q0.0 (Output byte 0, bit 0)
Memory Variables (Internal)
Used for intermediate calculations and flags
Format: M0.0 (Memory bit) or MW100 (Memory word)

Data Types
• BOOL: Boolean (true/false, ON/OFF)
• INT: Integer (-32768 to 32767)
• REAL: Floating point numbers
• TIME: Time duration
• STRING: Text data

Timers
ON-Delay Timer (TON)
Delays the output by a set time after input becomes true
Application: Ramp up time before motor starts

OFF-Delay Timer (TOF)


Keeps output ON for a set time after input becomes false
Application: Cool down period after device stops

Pulse Timer (TP)


Produces a pulse of fixed duration when triggered
Application: Brief activation signals

Counters
Up Counter (CTU)
Increments count on each rising edge of input
Sets output when count reaches preset value
Application: Count parts on conveyor belt

Down Counter (CTD)


Decrements count on each rising edge
Sets output when count reaches 0
Application: Countdown to target quantity

6. Introduction to TIA Portal


TIA Portal (Totally Integrated Automation Portal) is Siemens’ unified engineering
platform for configuring PLCs, HMI panels, and drives.

Main Components
Project Structure
• Project contains all engineering data
• PLC device configuration
• Program blocks and logic
• Variables and data structures
• HMI pages and screens

Block Types in TIA Portal


Organization Block (OB)
Main program block (OB1), executes cyclically
Function Block (FB)
Reusable code with memory (instance data)
Function (FC)
Reusable code without persistent memory
Data Block (DB)
Storage for variables and structured data

Creating a Simple Program in TIA Portal


Step 1: Create New Project
• File → New → Project
• Select CPU (e.g., S7-1200, S7-1500)
• Configure I/O addresses

Step 2: Create Variables


• Go to Variable table in OB1
• Define inputs, outputs, and temporaries
• Assign memory addresses

Step 3: Write Logic


• Use Ladder Logic, FBD, or Structured Text
• Add contacts, coils, and function blocks
• Test logic with simulation or actual device

7. Practical Examples
Example 1: Simple Motor Control
Requirement: Start a motor with a push button and stop with another

Ladder Logic Approach:


Rung 1: Start button (NO) connected to Motor coil
Rung 2: Stop button (NC) in series with Motor coil

Example 2: Timer-Based Operation


Requirement: Turn on a light for 10 seconds when button is pressed

Solution:
1. Button press activates TON timer
2. Timer preset value: 10 seconds
3. Timer output (Done bit) controls light coil

Example 3: Counter Application


Requirement: Count 100 parts, then trigger alarm

Solution:
1. Sensor input increments CTU counter
2. Counter preset value: 100
3. Counter Done output triggers alarm relay

8. Best Practices for PLC Programming


1. Documentation
• Document all variables with meaningful names
• Add comments to explain logic, not what is obvious
• Include revision history and change notes
• Create wiring diagrams and I/O mapping documents

2. Safety and Reliability


• Always include emergency stop logic
• Use watchdog timers to detect system failures
• Implement input filtering to avoid noise sensitivity
• Use safety-rated functions where required
• Test thoroughly before deployment

3. Code Organization
• Group related logic into function blocks
• Use consistent naming conventions
• Separate input processing, logic, and output control
• Modularize large programs
• Avoid nested logic when possible

4. Debugging and Troubleshooting


• Use online monitoring to watch variable values
• Enable diagnostic outputs for testing
• Check scan time to ensure program completes in time
• Use breakpoints and step execution
• Keep test reports and error logs

9. Common Mistakes and How to Avoid Them


1. Multiple Outputs on Same Variable
Problem: Two rungs control the same output
Solution: Use Set/Reset logic or ensure only one rung controls each output

2. Uninitialized Variables
Problem: Program behavior unpredictable at startup
Solution: Always initialize variables with default values

3. Forgotten Reset Logic


Problem: Counters and timers never reset
Solution: Always provide reset conditions (manual or automatic)

4. Ignoring Scan Time


Problem: Fast events missed between scans
Solution: Use interrupt inputs for time-critical signals

5. Poor Variable Naming


Problem: Confusing variable names make code hard to maintain
Solution: Use descriptive names like MotorStartButton instead of I0

10. Quick Reference Guide


PLC Addressing
Address Type Format Example
Digital Input I[byte].[bit] I0.0
Digital Output Q[byte].[bit] Q0.0
Internal Memory Bit M[byte].[bit] M0.0
Word (16 bits) MW[address] MW100

Common Function Blocks


TON (Timer ON-Delay) - Delays output by set time
TOF (Timer OFF-Delay) - Extends output after input goes false
TP (Timer Pulse) - Creates pulse of fixed duration
CTU (Counter UP) - Counts up to preset value
CTD (Counter DOWN) - Counts down to zero
CTUD (Counter UP/DOWN) - Counts in both directions

Conclusion
PLC programming is a critical skill in industrial automation. Start with these fundamentals:

• Master Ladder Logic—it’s the foundation


• Understand timers and counters—they solve 80% of real applications
• Practice with TIA Portal—hands-on experience is essential
• Write clean, documented code—maintainability matters
• Always think about safety—your code controls real machines

Good luck with your industrial attachment and engineering career!

You might also like