
Explore object oriented programming for PLC, including classes, methods, properties, inheritance, polymorphism, interfaces, and wrappers, to build expandable infrastructure with layer design and template projects.
Learn object oriented programming and structured programming by building classes, methods, properties, inheritance, polymorphism, interfaces, abstraction, delegation, and state machines to create scalable infrastructure.
Download a free Codesys-based PLC programming software, learn six languages, simulate visualization and algorithms, and prepare to connect to a real PLC with paid licenses in future lessons.
Explore creating a structured text project and implement a simple if statement to control a coil using start and stop buttons in simulation mode.
Call standard functions like timers, counters, and edge triggers in structured text to build a sequential motor start-stop flow, using rising edge triggers for reliable timing.
Explore designing a finite state machine with a case statement in PLC programming, wiring a mixer, pump, gate, and timer to start and stop triggers for sequential process steps.
Learn how arrays streamline handling multiple booleans, sensors, and coils in object oriented programming, with a basic activation logic and a preview of for loops.
Use a for loop to iterate motors and activate coils based on button and analog sensor conditions, sweeping i from 1 to 4 by one step.
Explore non instantiated functions that return a value without instantiation, enabling boolean or other types to drive conditional logic in structured text via if statements.
Create a non instantiated function with a boolean return type in the PLC object oriented programming course, passing overload and temperature inputs to control motor coils in simulation.
Present the solution for exercise one of design it your self part 1, detailing a two-pump PLC system with start and stop controls, overcurrent checks, valves, ultrasonic threshold, and simulation.
Explore the fundamentals of object oriented programming by learning how a class defines reusable functionality, creates objects, and reduces repetition with instances, methods, and properties.
Create a class in structured text, instantiate motor objects with inputs and outputs like start, stop, overload, and coil, and test them in a main program.
Learn to organize plc variables with structured variables and structure-based declarations. Build motor templates containing start/stop, overload, contactor, coil, and temperature feedback, accessed as motor1.dot and motor2.dot.
Create a structure to pack motor variables and instantiate multiple motor instances, demonstrating how object oriented programming builds infrastructure that simplifies modification and expands variables with dot notation.
Pass a single structure to a class input and return a structure at the output, consolidating motor variables and saving time when managing multiple motors.
Design a structure for motor inputs and a separate structure for motor outputs. Implement mapping to shorten names and simulate the PLC motor using the input and output structures.
Learn to create arrays of structures and objects to organize motor inputs, outputs, and functionality, enabling concise initialization and indexed access to each motor.
Compress the program by creating arrays of motor objects, motor inputs, and motor outputs, then assign inputs and outputs to motors for selective coil simulation.
Use a for loop from i = 1 to 3 by one to activate all motors by setting motor(i).start to true, showing that all outputs activate from one line.
Learn to design a generic sequential activator for multiple motors, using motor input/output structures, start/stop controls, wait times, overload handling, and fault reset.
Explore how methods, as class member functions, organize code into start, stop, overload, and reset actions for motors, enabling manual and automatic modes with safer, reusable design.
Create a motor class with start, stop, set, and reset methods to manage a coil, overload, and fault status in both manual and algorithmic modes.
Explore passing parameters through overload sets in a PLC object oriented program, enabling dynamic motor control with start and stop inputs and testing manual mode versus automatic mode.
Explore how the this keyword resolves variable shadowing between a parent class field overload and a method parameter, using dereferencing to access the parent’s value in PLC object oriented programming.
Explore how the this keyword resolves naming conflicts between a method parameter and a class field in a motor example and allows access to the main class fault status.
Explore wrappers that encapsulate multiple hardware classes (motor, VFD, proximity, ultrasonic) to represent machines, and learn how to pass parameters between methods using internal variables, properties, or methods.
Demonstrate wrappers in structured text by building a conveyor motor, passing delay as a parameter from main to wrapper, and coordinating a timer-based start.
Design a modular plc in which a global constants list sets motors per sequence and the total sequences, enabling instantiation via a for loop with sequence inputs and outputs.
Properties act as intermediaries to internal class variables, with auto-generated get and set methods that map values to internal state, as shown in a motor's fault status example.
Define a boolean property fault status and link it to the internal fault status in the motor program, using get and set to read and assign values.
Link class properties to physical i/o by encapsulating motor functionality in a motor function class with start, stop, frequency, and fault, mapping coil, button, overload, and frequency to real i/o.
Link properties to real I/O by modeling a motor with coil, overload, and fault status, and map them to PLC inputs and outputs for reusable, modular control.
Explore inheritance in object oriented programming by deriving motor, pump, and heater from a three phase device, reusing core functions and adding frequency scaling, low level handling, and over temperature.
Demonstrate inheritance by extending a three phase device into a motor, inheriting core functions and properties, and implement a frequency scale that maps 0–50 Hz to 0–10000 for a VFD.
Extend a three-phase device by creating an inherited pump and reuse its properties; add a level sensor with a threshold to drive a boolean status that lights a PLC lamp.
Explore deep inheritance by extending a motor from a three phase device to a timed motor, adding a timer-based run function to automate on/off cycles.
Explore method override in object oriented programming by comparing a base motor class, a timed motor subclass, showing how overridden turn on behaviors determine which function executes.
Override the turn on method in a three-phase device hierarchy and use the super keyword to access the parent implementation, illustrating temperature driven motor activation and timing behavior.
Explore polymorphism in oop through inheritance and interfaces to switch behavior at runtime. See how a base class reference can point to derived objects and call a unified run method.
Demonstrates polymorphism in a PLC program by switching between motor and timed motor at runtime, using a shared reference to call turn on and manage timing.
Explore access specifiers in object-oriented programming, focusing on public, private, and protected roles and how default public access affects inheritance and main usage.
Explore how private access restricts methods and data to their own class, hiding them from derived classes and the main program for internal calculations and checks.
Explain the protected access specifier in PLC object oriented programming, showing its visibility within a class and its inherited classes. Note main cannot access protected members, unlike private or public.
Explore how access specifiers govern a motor and pump via inheritance, with public, protected, and private methods like start, stop, operation time, and check valves.
Build a motor class to demonstrate access specifiers with protected, private, and public methods. Use timer to track operation time and check product efficiency against 60 kg level sensor threshold.
Extend a motor into a pump object with valve checks, a valves array, and a start override that activates the coil when all valves are open in a PLC program.
Create and implement an interface to standardize start and stop operations across actuators like motor, valve, pump, heaters, and pistons, using a coil boolean property and polymorphism.
Explore when to use interfaces versus inheritance, comparing base class dependencies, data access concerns, and the benefits of composing multiple interfaces for flexible infrastructure design.
Demonstrate implementing two interfaces, analog and digital, to build a VFD and an ultrasonic sensor, linking signal, scale, and coil and applying start and stop control.
Explore why interface-based polymorphism outperforms inheritance by enabling a sensor container to accept any implementing class, and apply this to a finite state machine design.
Demonstrates polymorphism via interfaces by wrapping any sensor implementing the analog interface, enabling runtime switching between voltage and current sensors without changing the wrapper.
Master object composition to build reusable sensor and motor objects by combining read analog, scale, sample, set thresholds, and trigger digital outputs.
Explore how delegation transfers responsibilities between objects, enabling runtime state switching in a wrapper state machine through an interface while preserving inputs and outputs.
Learn how pointers hold object addresses and how dereferencing accesses their contents, and compare them with references that simplify syntax in Katz's object model.
Demonstrate delegation using pointers and references in a sensor wrapper, linking inputs to pressure sensor current and voltage, and scaling an analog signal for a state machine.
Learn to merge pointers with an advanced state machine using a wrapper class that passes itself to states, links outputs via a pointer wrapper, and safely manage inputs and outputs.
Understand FB init as a constructor in PLC object oriented programming, and how to implement it during declaration window initialization, including B_in, B_in_copy, and warm and cold start pointers.
Implement an advanced state machine demo with two states that activate two boolean outputs via a run method, using polymorphism, interfaces, and wrapper objects to manage state execution.
Master transitions in advanced state machines by comparing context-driven and state-driven next state decisions, using a decoupled FSM wrapper with a state array and index-based transitions.
Explore advanced infrastructure in PLC object oriented programming by designing a finite state machine wrapper, defining a sensor, and implementing activation, condition control, and wait states with index-based transitions.
Create a state initializer in the FSM wrapper to map each state, pass its index, and cycle through states using waits and a threshold such as 80, wrapping to zero.
Develop a scalable dosing machine project that coordinates dual silos, spirals, a conveyor, buffering and storage silos, gates, and sensors using layered, object-oriented design for easy expansion.
Embrace a layered, object oriented approach using abstraction and interfaces, pure features, devices, fsm and states, and a wrapper with main io mapping to enable scalable modification.
Create an abstraction layer by defining I activate, I fault, I scale, I ramp, I status, I silo flags with methods and properties for activation, fault handling, scaling, and ramping.
implements the ai actuator implementation as a feature following an interface, defines three boolean properties: coil, start, and stop, and implements turn-off and turn-on logic to drive the actuator.
Implement the fault feature in the features layer by adding fault and reset fault properties, implementing interfaces, and wiring set and get logic to clear the fault status on reset.
Scale the analog input using p scaled value equals p analog value times max unit value divided by max signal value; extend to analog output by overriding the scale method.
Implement a vfd frequency ramp feature with ramp up and ramp down, using a self-resetting timer to sweep from zero to the target frequency at a chosen ramp rate.
Test the ramp implement feature by simulating ramp up and ramp down, guard against zero target frequency, and refactor into private timer scale and done assignment methods for modular testing.
Explore testing and debugging of PLC features by building and activating a default fault, wiring start/stop to manual and auto modes, and validating coil control and fault reset logic.
Test the analog input and analog output features by scaling signals with max signal value and max unit, validating volts, Hz, and milliamps, and discuss inheritance versus polymorphism.
Set up an io structure to group inputs and outputs for gates, vfds, and motors, and implement a common I auto manual interface with a map method.
Design a motor controller class using composition over inheritance, defining motor inputs, outputs, and interfaces for activate, actuate, and fault. Implement fault handling, overload, start/stop logic, and FSM-driven auto/manual testing.
This lecture demonstrates building a VFD controller using composition and inheritance to extend motor input/output, add scale and ramp features, and leverage polymorphism.
Implements ramp and scale functionalities for a VFD controller, using edge detection and interlocks to prevent simultaneous up/down ramps, and maps ramp output to a scaled analog signal.
Test and debug a VFD controller by instantiating the VFD, configuring input and output, applying ramp and frequency scaling, validating motor fault status in manual and auto modes.
Implement a load cell in the actuate and sense layer by defining an analog input, max unit value, and max signal value, plus a scaled output and scale interface.
Define an I detect interface with a boolean detect signal for a proximity sensor, implement AI detect, and create a common return boolean interface for FSM sensor checks.
Create a wrapper class to represent the machine, define constants and arrays for inputs, outputs, and actuators, and establish interfaces for the FSM.
Extend the wrapper layer by implementing a status flags feature for the state machine, define interfaces, implement properties with gets and sets, instantiate inputs, and map implementations.
Map interfaces to actuators and sensors using a private map method and for loops. Instantiate VFDs for spirals, conveyors, elevators, mixers, gates, and proximities to drive the finite state machine.
Instantiate the wrapper in the main, map inputs and outputs, copy constants, declare variables, and observe machine flags like buffering, dosing, and halt as you compile.
Develop and refine an advanced state machine by creating a base state class and I state interface, enabling next state transitions via a wrapper-held state index and a timer guard.
Develop and implement an FSM with states for conveyor, those in it, doze, buffering, gate handler, mixing, storage check, and a guard state for new patches.
Instantiate all fsm states inside the wrapper and map them into an execute array and a state map. Then test by activating the conveyor, elevator, and mixer.
Implement the DDoS init to buffer current silo weights, read load cell scaled values, activate spirals, set dosing, and map the next FSM state for multiple silos.
Create a delta state that checks each silo’s extracted weight against its target and turns off the spiral when reached; add a base state method check dosing for reuse.
Advance in fsm layer part six explains implementing a buffering state in a PLC, using proximity and dosing checks, a timer, and gating logic to the buffering silo.
Learn how to implement a generic gate handler that opens a gate for a user-specified duration, using a gate number, a dedicated gate timer, and state initialization, in dosing checks.
Implement the mixing state with a timer driven by a configurable mixing time, a mixing flag, and a guarded transition to the next state.
Bind buffering and storage flags to proximity sensor signals within the fsm, using an independent state stream and updated state map to manage gating and storage.
Explore two guards in the FSM layer that prevent dosing when the buffering or storage is full, using buffering and storage flags to control mixer deposits and new batch initiation.
Implement fault handling in the wrapper by checking actuators for faults, saving their last status, and restoring it after faults with save and restore status, plus a general shutdown.
Learn how to implement fault handling in an object-oriented PLC FSM by using rising and falling edge triggers to detect faults, save actuator status, and perform controlled shutdown and restoration.
Test the fault handler and status saving in a PLC state machine, handling overload faults, conveyor and motor stoppages, and reset workflows across multiple states to reveal issues.
Implement a per-silo and machine low-product flag system, check load cell weights against the target weight, and halt batching when low product is detected.
Master PLC programming with this very unique course :
When having a project with changing requirements , traditional programming methods using ladder fall short and causes tons of modification to add a new feature to your PLC program.
Now with the most recent IEC-61131-3 standard features , Object oriented Programming (OOP) is Introduced where you can apply a very sophisticated and Advanced programming methods to create a advanced programs with solid infrastructure.
After completing this course you will have a very solid background on designing using OOP , which its concepts are used in the biggest programming languages like C++ / JAVA / C# and even Python.
Topic we will cover:
Basic of Structured Text programming Language
Modular Design
Classes
Methods
Properties
Inheritance
Polymorphism
Access Specifiers
Pointers and References
Interfaces and Abstractions
Advanced State Pattern
Wrappers and Features
Layered Design
Final Project covering a real-world problem to be solved using OOP
Anyone who is looking for the next level PLC programming , this is the right course for you.
The future of PLC programming is OOP , since it guarantees a powerful infrastructure for your project , and this is what the IEC-61131-3 standard is pushing for in the last couple years . Ladder alone is inefficient , and if you have programmed big projects before , you can tell how complicated modifying your program or adding a new machine or even a small feature. It can even involve you erasing your whole program and writing a totally new one to adapt to the new requirement .
But with Layered design and OOP , modification can be very simple , no need to copy paste code , not to change base code.
There is no other course on the internet that covers these topics in a comprehensive way , and that's my role , i'll feed spoon you these concepts slowly and step by step until you fully understand them.
I hope to see you all there .
Mouhammad Hamsho