JZGKCHINAIndustrial Control Technology Sharing Platform
Introduction
With the continuous development of automation control technology, PLC (Programmable Logic Controller) is increasingly applied in industrial automation. As one of the important functional modules in PLC applications, the recipe management function helps enterprises flexibly and efficiently manage the settings of different process parameters during production. This article will introduce how to use PLC to write a recipe management program with a practical PLC program example, and discuss its application scenarios and further considerations.
1
Program Code and Introduction
The following is the complete PLC program code (the code is based on the ST language of the CodeSys platform):
FUNCTION_BLOCK PM_RecipeManagerVAR_INPUT LoadRecipe : BOOL; // Load recipe request SaveRecipe : BOOL; // Save recipe request RecipeID : UINT; // Recipe number RecipeDataIn : ARRAY[1..20] OF REAL; // Recipe data input from HMI Confirm : BOOL; // Confirm load/saveEND_VARVAR_OUTPUT RecipeDataOut : ARRAY[1..20] OF REAL; // Recipe data output to controller CurrentRecipeID : UINT; // Current recipe number Status : STRING; // Status informationEND_VARVAR Recipes : ARRAY[1..50, 1..20] OF REAL; // Recipe storage array, assuming there are 50 recipes, each with 20 parameters LastLoad : BOOL; LastSave : BOOL; i : INT;END_VAR// Load recipeIF LoadRecipe AND NOT LastLoad AND Confirm THEN IF RecipeID >= 1 AND RecipeID <= 50 THEN FOR i := 1 TO 20 DO RecipeDataOut[i] := Recipes[RecipeID, i]; END_FOR CurrentRecipeID := RecipeID; Status := 'Recipe loaded'; ELSE Status := 'Invalid Recipe ID'; END_IFEND_IF// Save recipeIF SaveRecipe AND NOT LastSave AND Confirm THEN IF RecipeID >= 1 AND RecipeID <= 50 THEN FOR i := 1 TO 20 DO Recipes[RecipeID, i] := RecipeDataIn[i]; END_FOR Status := 'Recipe saved'; ELSE Status := 'Invalid Recipe ID'; END_IFEND_IFLastLoad := LoadRecipe;LastSave := SaveRecipe;
2
Program Introduction
This program implements a simple recipe management function block (PM_RecipeManager), which mainly includes the following functions:
-
Load Recipe: When a load recipe request is received (LoadRecipe is TRUE), the program loads the corresponding recipe data based on the recipe number (RecipeID) and outputs the data to the controller (RecipeDataOut).
-
Save Recipe: When a save recipe request is received (SaveRecipe is TRUE), the program saves the recipe data input from HMI (RecipeDataIn) to the corresponding recipe storage array.
-
Status Update: The program updates the status information (Status) based on the operation results, helping users understand the current operation status.
The recipe data is stored in a two-dimensional array Recipes where up to 50 recipes are stored, each containing 20 parameters. The program ensures the safety and correctness of operations by checking the validity of the recipe number.
3
Application Scenarios
The PLC recipe management function has wide applications in industrial production, especially in the following scenarios:
Batch Production: In industries such as chemicals, food, and pharmaceuticals, the production process often requires multiple recipes, selecting different recipe parameters based on product types. The PLC recipe management system can simplify this process and improve production efficiency.
Production Line Automation: In automated production lines, using PLC to manage recipes can achieve automatic recipe switching, reduce manual operations, and improve production stability and consistency.
Real-time Adjustment and Optimization: Through PLC control, recipe parameters can be adjusted in real-time during production to respond to changes in the environment or demand, ensuring product quality.
Data Recording and Traceability: The loading, saving, and status information of recipes can be recorded and logged for later traceability and analysis.
4
Further Considerations
In practical applications, recipe management is not limited to reading and storing operations; in the future, it can be combined with more functions to enhance the system’s intelligence and flexibility:
Remote Management and Monitoring: By integrating with SCADA or cloud platforms, operators can remotely access and control the loading and saving of recipes, further enhancing the flexibility of production management.
Data Analysis and Optimization: By combining real-time analysis of production data, the system can automatically optimize recipe parameters, making the production process more efficient and reducing waste.
Recipe Version Control: Managing multiple versions of recipes to ensure the optimal recipe version can be selected under different production requirements.
Recipe Security: By introducing permission management and data encryption, the security of recipe data can be ensured, preventing unauthorized operations.
Conclusion
The PLC recipe management program is not only an important component of automation control but also plays a significant role in improving production efficiency, reducing human errors, and ensuring product quality. By designing and optimizing PLC programs reasonably, it can better meet complex production demands and enhance the production capacity and competitiveness of enterprises. With the development of technology, PLC recipe management systems can also integrate with more intelligent and digital technologies, bringing more possibilities to industrial production.

Feel free to ask questions, and I will answer them


We welcome everyone to propose some standard function block requirements in the comments section. If suitable, we will share them in future articles.

Previous Articles
Weekly Programming Example: Comparison of Two Implementations for Bit to Word Conversion
Weekly Programming Example: Recording Device Operating Time
Weekly Programming Example: Start Control System Based on Long Press Detection
Weekly Programming Example: Exploring PLC Data Logging Function Block
Weekly Programming Example: Heartbeat Detection and PLC Applications
Weekly Programming Example: Ramp Generator
Weekly Programming Example: Rotational Speed Calculation
Weekly Programming Example: Calculating PLC Cycle Period | Routine Requirement Collection!
Weekly Programming Example: How to Elegantly Split Strings
Weekly Programming Example: Valve Control Program with Feedback
Weekly Programming Example: Pulse Relay Function Block in Siemens LGF Library
Weekly Programming Example: Control Application for Curve Acceleration and Deceleration
Weekly Programming Example: Easily Remove Leading Characters from Strings
Weekly Programming Example: Update Input Based on Threshold
Weekly Programming Example: Official Analog Input Processing Module
Weekly Programming Example: Sequential Control of Master-Slave Motors
Weekly Programming Example: Optimization Scheme Based on First-Order Lag Filtering
Weekly Programming Example: Magical Conversion from Hexadecimal to Floating Point
Weekly Programming Example: PLC Long Press Control Program
Weekly Programming Example: PLC Program for Splitting Multi-digit Integers
Weekly Programming Example: Flow Accumulation Calculator
Weekly Programming Example: Standard Control Module for Motors Used in Chains
Weekly Programming Example: Implementation and Application of PID Control Algorithm in PLC Systems
Weekly Programming Example: Custom Seed for Generating Random Numbers
Weekly Programming Example: Adjustable Time Pulse Generator
Weekly Programming Example: Standard Analog Input Function Block with Filtering
Weekly Programming Example: Using PLC to Convert Strings to Date Format
Weekly Programming Example: Comparing Two DB Blocks (STL)
Weekly Programming Example: How to Reverse an Array Using PLC

November 2025
1. Smart200 & V90 Servo System: 15 courses updated
2. Beckhoff Live Courses: 30 courses updated
3. PKS Quick Start: Beginner & Intermediate – All
4. Classic Public Course on Industrial Control: 35 courses updated5. EPLAN Quick Start: All 20 Beginner Courses