PLCs for Beginners (M. T. White)(Z-Library)
C
An introductory guide to building robust PLC programs with the Structured Text language
12
Views
0
Downloads
0.00
Total Donations
Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Page
1
(This page has no text content)
Page
2
PLCs for Beginners Copyright © 2024 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Group Product Manager: Preet Ahuja Publishing Product Manager: Suwarna Rajput Book Project Manager: Uma Devi
Page
3
Senior Editor: Isha Singh Technical Editor: Yash Bhanushali Copy Editor: Safis Editing Proofreader: Isha Singh Indexer: Subalakshmi Govindhan Production Designer: Vijay Kamble DevRel Marketing Coordinators: Linda Pearlson and Rohan Dobhal First published: May 2024 Production reference: 1100524 Published by Packt Publishing Ltd. Grosvenor House 11 St Paul’s Square Birmingham B3 1RB, UK ISBN 978-1-80323-093-1 www.packtpub.com
Page
4
To mom and dad. Contributors About the author M. T. White has been programming since the age of 12. His fascination with robotics flourished when he was a child programming microcontrollers. He holds an undergraduate degree in mathematics, a master’s degree in software engineering, and an MBA in IT management. He is currently working as a software developer for a major US defense contractor and is an adjunct CIS instructor, where he teaches Python, C, and an array of other courses. His background mostly stems from the automation industry where he programmed PLCs and HMIs for many different types of applications. He has programmed many different brands of PLCs over the years and has developed HMIs using many different tools. Other technologies that he is fluent in include Linux, Ansible, Docker, AWS, C#, Java, and Python. Be sure to check out his channel AlchemicalComputing on YouTube. About the reviewers Keith Lyding is an electrical engineer for a manufacturing company in Columbus, Ohio. He has over 15 years of experience in the electrical field, as well as more than 9 years of experience in automation. He graduated from Thomas Edison State University in 2019. He served in the US Navy for six years and has also worked for Nucor Steel. He currently works for
Page
5
Sonoco Products Company, where he works primarily with Allen Bradley PLCs, Inductive Automation’s Ignition platform, EXOR and Panelview HMIs, and many other platforms. He enjoys troubleshooting, as well as automating complex operations. In his spare time, he loves to serve in his church, coach his son’s baseball team, and spend time with his family. I extend my deepest gratitude to my wife, Katie, for her unending support. I am grateful to my colleagues and mentors for their guidance throughout my journey: Kyle Ahrendt, William Carleton, and K. Andy Steinacker. I am also appreciative of the men in my life for continuing to sharpen, push, and encourage me to become more like Jesus: Paul Cassidy, Brian Babin, Ken Lyding, K. Andy Steinacker, Jon Krull, David Bout, Isaac Dye, and many, many others. Ninad Deshpande is an author, storyteller, international speaker, and technology evangelist known in the industrial automation fraternity. He has over 15 years of extensive hands-on experience in varied fields of the automation industry, such as application development, testing, R&D, marketing, corporate communication, and global product management. He is the co-author of the Packt book The Art of Manufacturing. Today, as a co- founder and director of Passion Minds Private Limited, he helps organizations across the globe in various industries with services focusing primarily on technologically and strategically driven content generation. I thank my family and friends for teaching me life lessons and consistently inspiring me. I admire my mother’s and my wife’s fighting spirit; their constant support and motivation enable me to achieve my dreams.
Page
6
Table of Contents Preface
Page
7
Part 1: Basics of Computer Science for PLC Programmers 1 Computer Science Versus Automation Programming Technical requirements What is computer science? Why study computer science? What is automation programming? What is a PLC? Exploring automation through computer science How does computer science help automation programmers? Why should automation programmers care? Cloud technologies
Page
8
The internet of things Machine learning What does this mean for automation engineering? PLCs versus microcontrollers What are microcontrollers? Surface-level differences PLC and microcontroller programming languages Use cases PLC versus computers What is a computer? PLC versus computers Summary Questions 2
Page
9
PLC Components – Integrating PLCs with Other Modules Technical requirements PLC types Common PLC modules Power supply Chassis CPU modules I/O modules Safety modules Sinking versus sourcing NPN versus PNP Sensors Motors and motor controls What is a motor? Open and closed-loop control systems
Page
10
Stepper motors Servo motors Encoders Motor drives Communication protocols What is a communication protocol, and what is it used for? Wiring diagrams Final project Specs BOM Summary Questions Further reading 3
Page
11
The Basics of Programming Technical requirements Understanding what a program is What is the purpose of a program? Why use software over hardware? How to view software and hardware in a system Software is not a cure-all solution Understanding programming languages Syntax Translators Machine instruction Language paradigms Keywords Dos and don’ts of learning keywords and syntax Program flow
Page
12
Program iteration Exploring the IEC 61131-3 standard IEC 61131-3 pitfalls Final project Strategy Summary Further reading Questions 4 Unleashing Computer Memory Technical requirements What is memory? Memory Storage How computer/PLC memory and storage work
Page
13
HDDs SSDs Volatile versus non-volatile memory Volatile memory Non-volatile memory Memory addresses How memory works Computer memory – an analogy Common storage devices USB drives External hard-drives SD cards Cloud storage Obsolete storage devices Floppy drives
Page
14
Summary Questions Further reading 5 Designing Programs – Unleashing Pseudocode and Flowcharts Technical requirements What are pseudocode programs and flowcharts? Pseudocode What does pseudocode look like? Flowcharting What do flowcharts look like? Why use pseudocode and flowcharts in PLC programming? Why use pseudocode? Why use flowcharting?
Page
15
When to use one over the other? Tools needed for flowcharts and pseudocode Pseudocode tools Flowchart tools Whiteboarding Design exercises The quadradic equation The beer program Final project – Robot startup system Design requirements Design logic Wait sequence Pseudocode Flowchart Summary
Page
16
Questions 6 Boolean Algebra Technical requirements What is Boolean algebra? Boolean operators The basic operators The OR operator The NOT operator Boolean expressions Exploring NOT The OR operator The AND operator Operator laws Idempotent law
Page
17
Solving Boolean equations Examples Getting to know truth tables Basic operators Final project: Creating custom truth tables from scratch Row 1 Row 2 Row 3 Row 4 Final truth table Summary Questions Further reading
Page
18
Part 2: Introduction to Structured Text Programming 7 Unlocking the Power of ST Technical requirements What is ST? Area of a circle program in ST Why is ST important? ST versus LL Example 1 – The area of a circle program – LL Example 2 – Toggling a light What is CODESYS? Installing CODESYS A CODESYS exploration
Page
19
Exploring the PLC_PRG file The final project – Hello World Step 1 – Creating a new project! Step 2 – Code implementation Step 3 – Running the program! Chapter challenge Summary Further reading Questions 8 Exploring Variables and Tags Technical requirements What are variables/tags? Applications of variables Variables/tags under the hood
Page
20
Why use variables? Data types What is a data type? The IEC 61131-3 data types Bits and bytes Common data types How to declare variables Variable section of a fi le Declaring a variable Initializing a variable Variable naming Rules to naming a variable Naming conventions Final project – declare the variables of a triangle Code implementation
The above is a preview of the first 20 pages. Register to read the complete e-book.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
AI guide
【One-Line Pitch】
A practical on-ramp to industrial automation for newcomers who want to write reliable PLC programs in Structured Text rather than fear it. Best suited to beginners, students, and self-taught automation enthusiasts willing to pair CODESYS practice with computer-science fundamentals.
【Book Arc】
- **Opening (~0%–10%)**: Sets up the automation mindset—why software quality determines machine quality, how computer science principles apply to automation, and where PLCs sit relative to microcontrollers and everyday electronics.
- **Early (~10%–23%)**: Hardware and low-level foundations: discrete I/O modules, encoders, motor drives (AC, DC, servo, stepper), memory vs. storage, volatile/non-volatile distinctions, and the basics of how programs flow.
- **Early (~23%–32%)**: Program design before code: pseudocode, flowcharts, algorithmic thinking, Boolean simplification, and design exercises that build a "machine mindset."
- **Middle (~32%–48%)**: The core language turn—installing CODESYS, meeting Structured Text, comparing it with Ladder Logic, and working through variables, tags, naming conventions, arithmetic, trigonometry, and built-in function blocks.
- **Late (~48% onward)**: Control flow and applied logic: IF and CASE statements, counters, and a color-sorting project that leans on pseudocode and flowcharting; later material moves into IEC 61131-3 iteration, pitfalls, and troubleshooting.
- **Ending**: Consolidation through final projects, troubleshooting broken software and hardware, power supply and network diagnosis, and a PLC toolkit approach to real-world faults.
【Key Takeaways】
- **Software quality is the limiting factor in automation** (Opening): advanced hardware cannot rescue poorly written programs, so computer-science discipline directly improves machine performance.
- **PLCs are not microcontrollers** (Opening): microcontrollers dominate low-voltage, non-industrial applications, while PLCs are built for rugged, complex industrial environments—knowing the difference shapes design choices.
- **Discrete I/O is binary by nature** (Opening): digital modules read on/off states via voltage thresholds (commonly 24V), and output modules drive relays, LEDs, and alarms accordingly.
- **Motors need matching drive and feedback** (Early): servo motors typically require a motor drive and encoder, and the four main drive families—AC, DC, servo, stepper—map to different control needs.
- **Memory and storage are distinct concerns** (Early): volatile vs. non-volatile behavior, HDD vs. SSD trade-offs, and solid-state storage in modern PLCs all affect reliability and troubleshooting.
- **Design before code** (Early): pseudocode and flowcharts translate directly into Structured Text, and practicing algorithmic sequencing is the real hurdle for most beginners.
- **Structured Text is approachable, not intimidating** (Middle): ST closely resembles pseudocode and can be easier to read than Ladder Logic for many applications, making it a strong first language.
- **Variables, naming, and math are foundational** (Middle): data types, camel/pascal/snake casing, arithmetic, and trigonometric functions are the daily vocabulary of PLC programming.
- **Flow control drives real behavior** (Late): IF and CASE statements, counters, and projects like color sorting show how programs choose paths and act on inputs.
【Reading Tips】
- Deep-read the early chapters on program design and pseudocode; they are the bridge to everything in Structured Text.
- Skim hardware chapters if you already know motor drives and I/O, but return to the memory/storage section when troubleshooting.
- Install CODESYS early and follow along with the downloadable example code—reading ST without typing it will not stick.
- Treat the final projects and troubleshooting chapters as a checklist: they reveal which earlier concepts you actually internalized.
- If trigonometry or Boolean algebra feels shaky, pause and review before the math-heavy sections; the book assumes some prior comfort.
【Coverage Limits】
This guide is based on stratified excerpts covering roughly the first half of the book plus later chapter markers; specific later-project details, exact chapter titles, and full troubleshooting procedures are not fully represented. Where the excerpts are thin, the guide stays at the level of themes rather than inventing specifics.
Passage locations
Excerpt 1
. Get in touch Feedback from our readers is always welcome. General feedback: If you have questions about any aspect of this book, email us at customercare@p...
View in text
Excerpt 2
is also important to understand the concept of keywords to implement that structure. Keywords Every programming language has keywords. Keywords are reserved...
View in text
Excerpt 3
pts to really hammer home when and where ST should be used. In this chapter, we’re going to explore the following topics: This code is for demonstration purp...
View in text
Excerpt 4
certainly run into situations where you needed to copy and paste a series of instructions in multiple places. In programming, having code in more than one lo...
View in text
Recommended for You
{{#thumbnailUrl}}
{{/thumbnailUrl}}
{{^thumbnailUrl}}
{{/thumbnailUrl}}
Loading recommended books...
Failed to load, please try again later
Tip the Site
Scan the WeChat Pay or Alipay code to tip. No login required.
WeChat Pay
Alipay