Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Mastering PLC Programming

You're reading from   Mastering PLC Programming The software engineering survival guide to automation programming

Arrow left icon
Product type Paperback
Published in Jan 2026
Publisher Packt
ISBN-13 9781836642558
Length 528 pages
Edition 2nd Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
M. T. White M. T. White
Author Profile Icon M. T. White
M. T. White
Arrow right icon
View More author details
Toc

Table of Contents (26) Chapters Close

Preface
1. Part I: Advanced Structured Text
2. Advanced Structured Text: Programming a PLC in Easy-to-Read English FREE CHAPTER 3. Complex Variable Declaration: Using Variables to Their Fullest 4. Functions: Making Code Modular and Maintainable 5. Object-Oriented Programming: Reducing, Reusing, and Recycling Code 6. OOP: The Power of Objects 7. Best Practices for Writing Incredible Code 8. Libraries: Write Once, Use Anywhere 9. Part II: Software Engineering for Automation
10. Getting Started with Git 11. SDLC: Navigating the SDLC to Create Great Code 12. Architecting Code with UML 13. Testing and Troubleshooting 14. Advanced Coding: Using SOLID to Make Solid Code 15. Part III: HMI Design
16. Industrial Controls: User Inputs and Outputs 17. Layouts: Making HMIs User-Friendly 18. Alarms: Avoiding Catastrophic Issues with Alarms 19. Part IV: Putting Knowledge Into Action
20. DCSs, PLCs, and the Future 21. Putting It All Together: The Final Project 22. Unlock Your Exclusive Benefits
23. Answer Sheet
24. Other Books You May Enjoy
25. Index

Exploring methods

To get the most out of a function block, you should add methods to it. Methods are a special type of function that are declared in and must be invoked through a function block. Where a standard method is globally accessible in a PLC program, a method can only be invoked in a file that references the function block, as we saw in the previous section. Another unique feature of a method is that when inheritance is invoked, function blocks can share certain methods with other function blocks. To start exploring methods, we’re going to add four methods to the Calculator function block we created in the last example.

Adding methods

Adding a method is relatively simple. To add a method, all you have to do is right-click the Calculator function block, hover over Add Object, and click Method…, similar to what is shown in Figure 4.3.

Figure 4.3: Adding a method

Figure 4.3: Adding a method

When you follow these steps, you will be met with a wizard that will generate...

lock icon The rest of the chapter is locked
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Mastering PLC Programming
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Modal Close icon
Modal Close icon