
Explore pattern-based, structured text and CFC design to build modular PLC components and a controller, enabling easy extension of production lines and clean signal interfaces.
Explore the dozing machine project, detailing bunkers, dozers, mixer, gate, conveyors, and sensors, and advocate a modular, expandable software design.
Explore component design as a modular approach that groups multiple units into reusable blocks. Understand calibration ports, virtual control board, fault injection, and global valuables for testing and orchestration.
Discover how global variables and IO global valuables provide a program-wide mapping between analog and digital inputs and outputs, enabling easy calibration, maintenance, and flexible signal swapping in ST.
Design an analog handler in ST that converts voltage or current signals to a physical value via gain scaling, producing a scaled value with upper and lower limits and warnings.
Design a motor driver block in ST that integrates start, overload, and emergency inputs with a feedback timer to validate coil activation and report status.
design a structured text proximity function block that handles any digital sensor by adding on time and off time delays to filter jitter and noise, yielding a detected output.
Perform a proximity sensor unit test in Codesys by instantiating the proximity function, wiring on-delay and off-delay timers, and simulating input signals to verify correct detect timing.
Introduces a product handler that moves product from the bunker to the mixer using dose control, weight tracking, and max/min limits via a structure text state machine.
Test and validate the product handler by instantiating the function, wiring inputs and outputs, and simulating weight targets, max limits, dosing logic, and state transitions.
Program the calibration board for the dozer by creating a duty, copying parameters, and configuring analog outputs and inputs with gain and limits using prefixes motor, bunker, weight, and way.
Design and implement data structures for read and send ports driven by analog and digital inputs and outputs, including initialization of the virtual control port with motor start.
Instantiate the analog output handler, route the controller-generated frequency through the virtual control board frequency scale, and apply calibrated gain and limits to drive the dozer speed controller.
instantiate the motor and connect the gate motor driver with digital inputs, fault injections, and motor start control, linking sources, sinks, and calibration timeout to enable safe motor operation.
Adapt the dozer frequency logic to the mixer, rename fault injection fields to frequency analog signal, and change the enable type from real to boolean before building the mixer frequency.
Instantiate the mixer timer by dragging a timer handler, wiring inputs and outputs, and using a virtual control board to start and read the mixer preset time from calibration.
Design and implement a mixer gate by building the gates driver, DFA blocks, and inputs and outputs for a virtual control board, including gate open sensor calibration and fault injection.
Create and instantiate global valuables across the Io and parameters folders for calibration, measurement, virtual control, and fault injection, centralizing communication and reading calibration through these assets.
Summarizes creating input/output module mapping in ST, linking each dozer and mixer signals to digital and analog inputs via global variables, and mapping outputs to their coils.
Perform integration testing of the doser system using the dozer component, refactoring test folders, fixing calibration timing, and validating fault injection, motor start, and emergency and overload scenarios.
Test the doser integration by injecting a real load into the load cell and converting the analog input to unsigned values, validating upper and lower limits up to 5000 kg.
Practice mixer integration testing in Codesys by configuring calibration, correcting unit timing from milliseconds to seconds, and validating fault injection, motor start, and emergency scenarios.
Perform integration testing of the mixer frequency control in CODESYS ST, validating frequency injection, analog handler conversion, and unsigned integer handling to achieve correct DAC output.
System test part 1 demonstrates testing after combining multiple components and connecting the control, addressing a bug in controller mapping, fault injection, and a new reset mechanism.
You are on this page, so you probably know that writing a PLC code that gets the job done, is sometimes not really super complicated.
You are also probably aware that customers tend to change their minds quite frequently about the PLC design and the system algorithm.
If that's the case, then you are definitely aware that changing a complicated algorithm written in Lader Logic or even CFC languages is not that of an easy task. Especially when dependencies in your code are high. Well, that is what we call a Spaghetti Code. It is a code, that basically gets the job done. But it lacks all the extend
Here I am presenting you a solution, a way to elevate above the masters of PLC programmers.
Learning Pattern-based programming is like designing a puzzle-based design, where you design individual code pieces and fit them together to create a powerful PLC software infrastructure.
We will first start the design by creating unit functions, building them up to components that form the machines in the production line. And finally the controller. Modifying any piece of these would be so easy that you won't have to scratch your head for hours trying to figure out how to modify your algorithm or even worse deleting the whole thing. We all been there once!
This knowledge can be applied to any PLC and any platform, be it Codesys, Tia portal, Bechoff or any brand that supports the following languages:
CFC
Structured Text
You are going to master a very famous design pattern including extensive hands-on Structured text and CFC.
I hope to see you all in there!