Reader small image

You're reading from  Mastering PLC Programming

Product typeBook
Published inMar 2023
PublisherPackt
ISBN-139781804612880
Edition1st Edition
Right arrow
Author (1)
Mason White
Mason White
author image
Mason White

M.T. White has been programming since the age of 12. His fascination with robotics flourished when he was a child programming microcontrollers such as Arduinos. M.T. currently holds an undergraduate degree in mathematics, a master's degree in soft ware engineering, and is currently working on an MBA in IT project management. M.T. is currently working as a soft ware developer for a major US defense contractor and is an adjunct CIS instructor at ECPI University. His background mostly stems from the automation industry where he programmed PLCs and HMIs for many different types of applications. M.T. has programmed many different brands of PLCs over the years and has developed HMIs using many different tools.
Read more about Mason White

Right arrow

Assessments

This section contains answers to questions from all chapters. Go ahead and check if you’ve got them right.

Chapter 1: Software Engineering for PLCs

  1. C
  2. A, B, E
  3. B
  4. D
  5. A
  6. C

Chapter 2: Advanced Structured Text — Programming a PLC in Easy-to-Read English

  1. A pointer points to a memory address where a reference is similar to a pointer with less syntax and references another variable.
  2. The ^ symbol dereferences a pointer.
  3. TRY, CATCH, FINALLY
  4. Self-documenting code is logically named program attributes such as variable names.
  5. A good comment is a comment that is short and adds context to the code without cluttering it. A bad comment will not add any context to the code, is long, or will unnecessarily clutter the code.
  6. You should code to a variable so you only need to change values in one place, which will reduce the number of bugs in a program. Coding to a variable will also add context to what the value represents.

Chapter 3: Debugging — Making Your Code Work

  1. Print debugging is where messages are put in the program to help the developer see where they are at in the program’s execution.
  2. Using a tool such as the debugging tool.
  3. The process of finding and eliminating a bug in a program.
  4. Functional Error

Chapter 4: Complex Variable Declaration — Using Variables to Their Fullest

  1. C
  2. A GVL is a global variable list where a struct is a data type.
  3. A constant is a variable that does not change where an ENUM is a user-defined data type that is composed of constants.
  4. There are many different errors you can get with an array; however, the most common one stems from trying to access an element that is not present.
  5. ArrayName[1..5, 1..6] OF <TYPE>;

Chapter 5: Functions — Making Code Modular and Maintainable

  1. A function is a callable block of code that provides modularity to a program, can accept parameters/arguments, and will only run when invoked.
  2. Arguments that are pre-assigned and do not need to be provided when the function is called.
  3. A parameter that is assigned a value when the function is called based on its name.
  4. The function’s parameters, return type, and other attributes that distinguish it.
  5. By default in a one-to-one fashion.
  6. Any amount of code as long as the code’s intended purpose can be described in one sentence without the word and.
  7. The type of value the function will return.
  8. Technically yes, depending on the system. However, certain return types cannot be assigned to certain variables.

Chapter 6: OOP — Reducing, Reusing, and Recycling Code

  1. Class
  2. A method calls itself.
  3. 3. A pointer of a function block to its own function block instance.
  4. Getter and Setter
  5. A getter will retrieve a value where setter will set a value.

Chapter 7: OOP — The Power of Objects

  1. Abstraction, Encapsulation, Inheritance, Polymorphism
  2. No
  3. No limit
  4. Private hides attributes such as methods from outside files, while public allows any file to access the attributes.

Chapter 8: Libraries — Write Once, Use Anywhere

  1. A set of prebuilt attributes that can be imported and called by your current program.
  2. It shows users how to implement and use the library.
  3. Via the library manager.
  4. Singleton, Factory, Façade, anything that will simplify the use of the library.
  5. /// is Declaration header while (**) is a member header.
  6. Varies

Chapter 9: The SDLC — Navigating the SDLC to Create Great Code

  1. The number of lines tested in a unit test.
  2. 80%
  3. 50%
  4. The steps involved for developing and deploying a piece of software (steps in the software development process).
  5. Roughly six; however, that number can vary from person-to-person.
  6. A way of showing the relationship between function blocks.
  7. Unit test is where a developer will test out code modules. Regression testing ensures the system works as intended after a code change.
  8. A test case is a set of criteria that is used to ensure a code works under a given circumstance.
  9. Validation is ensuring the program solves the original problem. Verification ensures the software works as it was designed to work.

Chapter 10: Advanced Coding — Using SOLID to Make Solid Code

  1. Function blocks, methods, functions
  2. Break the module up so it is describable in a complete sentence without the word and.
  3. Principle that states that an object of a part class/function block should be replaceable with objects of a child class/function without affecting the behavior.
  4. Principle that states that a function block should not have to implement an interface it does not use, nor should it depend on a method that it does not use.
  5. See the following:
    • S: Single-responsibility Principle
    • O: Open-closed Principle
    • L: Liskov Substitution Principle
    • I: Interface Segregation Principle
    • D: Dependency inversion Principle

Chapter 11: HMIs — UIs for PLCs

  1. An HMI is a User Interface for an industrial machine.
  2. Industrial User Interface for automation projects.
  3. PLC, HMIS, Sensors, Logging devices, and so on.
  4. A rough outline of a UI/HMI screen.
  5. Yes: with the proper plugins and libraries

Chapter 12: Industrial Controls — User Inputs and Outputs

  1. An HMI control that affects a Boolean variable when pressed to trigger an event.
  2. Arrays
  3. Yes
  4. Yes: it will depend on the situation.

Chapter 13: Layouts — Making HMIs User Friendly

  1. Red: error, Yellow: warning, Green: normal operation.
  2. Dark colors such as black and dark grey.
  3. An HMI should be tasked with running one and only one operation such as programming, monitoring health, and so on.
  4. Visualization manager
  5. The home screen.
  6. Varies.

Chapter 14: Alarms — Avoiding Catastrophic Issues with Alarms

  1. An alarm is a machine health/operation status.
  2. Info, Warning, Error
  3. Error
  4. Objects that consume alarm configurations
  5. A confirmation to the system that the alarm has been seen, and in some cases, addressed.

Chapter 15: Putting It All Together — The Final Project

The questions in this chapter are open-ended with no wrong or right answer. They are meant to be exploratory so readers can come to their own conclusions.

Chapter 16: Distributed Control Systems, PLCs, and Networking

  1. A cluster that supervises multiple other processes.
  2. When a single process needs to be overseen.
  3. 125 Kbps, 250 Kbps, 500 Kbps
  4. One is ethernet based, the other is serial based, among other things such as speed.
  5. Star
  6. TCP/IP is slower but more reliable than UDP. UDP is faster but data integrity is not guaranteed.
  7. UDP
  8. Profinet, EtherCat
  9. 121 ohm
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Mastering PLC Programming
Published in: Mar 2023Publisher: PacktISBN-13: 9781804612880
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.
undefined
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 €14.99/month. Cancel anytime

Author (1)

author image
Mason White

M.T. White has been programming since the age of 12. His fascination with robotics flourished when he was a child programming microcontrollers such as Arduinos. M.T. currently holds an undergraduate degree in mathematics, a master's degree in soft ware engineering, and is currently working on an MBA in IT project management. M.T. is currently working as a soft ware developer for a major US defense contractor and is an adjunct CIS instructor at ECPI University. His background mostly stems from the automation industry where he programmed PLCs and HMIs for many different types of applications. M.T. has programmed many different brands of PLCs over the years and has developed HMIs using many different tools.
Read more about Mason White