Creating Ramps in SCL
Kenneth Jensen
Automation, Integration, & Controls Engineer / Electrical Engineer / Power Coordinator / Drive Engineer
Introduction
Ramp functions are essential for controlling the rate of change in various automation processes. They are especially useful for heat up logic in furnaces, signal ramping for speed and torque control functions, and many other applications. In this article, we'll delve into the basics of ramp functions, how to implement them in SCL, and the importance of optimizing these functions for different applications.
Basics of Ramp Functions
Ramp functions control the rate of change over time, providing smooth transitions and preventing abrupt changes that could lead to mechanical failures. Commonly used ramp functions include acceleration and deceleration ramps, which are simple yet effective.
Ramp functions are great for taking scaled analog values and slowing them down to reduce mechanical failures. They have been critical for moving all the drives at the same acceleration and deceleration for line speed changes in a steel mill, and by slowly ramping, we can also reduce tension anomalies.
Implementing a Linear Ramp Function in SCL
Linear ramp functions provide a straightforward method to control the rate of change. Here's a step-by-step guide to creating a linear ramp function:
Example: Linear Ramp Function
FUNCTION_BLOCK FB_LinearRamp
VAR_INPUT
TargetValue : REAL; // Desired target value
RampTime : INT; // Time for the ramp to complete in seconds
CurrentValue : REAL; // Current value
END_VAR
VAR_OUTPUT
RampValue : REAL; // Output value of the ramp
END_VAR
VAR
RampStep : REAL; // Incremental step for the ramp
TimeCounter : INT := 0; // Counter for time
END_VAR
BEGIN
// Calculate the ramp step
RampStep := (TargetValue - CurrentValue) / RampTime;
// Increment the time counter
TimeCounter := TimeCounter + 1;
// Update the ramp value
IF TimeCounter < RampTime THEN
RampValue := CurrentValue + (RampStep * TimeCounter);
ELSE
RampValue := TargetValue;
END_IF;
END_FUNCTION_BLOCK
Explanation
1. TargetValue: The desired value you want to reach.
2. RampTime: The duration over which the ramp should occur.
3. CurrentValue: The starting value.
4. RampStep: The incremental step calculated based on the target value and ramp time.
5. RampValue: The output value that ramps from the current value to the target value over the specified time.
Implementing Exponential Ramp Function in SCL
Exponential ramp functions are useful for processes that require a smooth start and end. They provide a more gradual change at the beginning and end of the ramp.
Example: Exponential Ramp Function
领英推荐
FUNCTION_BLOCK FB_ExponentialRamp
VAR_INPUT
TargetValue : REAL; // Desired target value
RampTime : INT; // Time for the ramp to complete in seconds
CurrentValue : REAL; // Current value
END_VAR
VAR_OUTPUT
RampValue : REAL; // Output value of the ramp
END_VAR
VAR
RampStep : REAL; // Incremental step for the ramp
TimeCounter : INT := 0; // Counter for time
ExpFactor : REAL; // Exponential factor
END_VAR
BEGIN
// Calculate the exponential factor
ExpFactor := LOG(TargetValue / CurrentValue) / RampTime;
// Increment the time counter
TimeCounter := TimeCounter + 1;
// Update the ramp value
IF TimeCounter < RampTime THEN
RampValue := CurrentValue * EXP(ExpFactor * TimeCounter);
ELSE
RampValue := TargetValue;
END_IF;
END_FUNCTION_BLOCK
Practical Example: Ramp Function for Motor Speed Control
Combining ramp functions with scaling allows for precise control over motor speed, reducing mechanical stress and improving system reliability.
Example: Motor Speed Control with Ramp Function
FUNCTION_BLOCK FB_MotorSpeedControl
VAR_INPUT
SpeedTarget : REAL; // Desired motor speed
RampTime : INT; // Time for the ramp to complete
CurrentSpeed : REAL; // Current motor speed
END_VAR
VAR_OUTPUT
SpeedOutput : REAL; // Ramped motor speed
END_VAR
VAR
RampSpeed : REAL; // Ramped speed value
RampFB : FB_LinearRamp; // Instance of the linear ramp function block
END_VAR
BEGIN
// Apply the ramp function
RampFB.TargetValue := SpeedTarget;
RampFB.RampTime := RampTime;
RampFB.CurrentValue := CurrentSpeed;
RampSpeed := RampFB.RampValue;
// Output the ramped speed value
SpeedOutput := RampSpeed;
END_FUNCTION_BLOCK
Advanced Example: Coordinated Line Speed Control in a Steel Mill
Using globalized ramp functions can be critical for moving all the drives at the same acceleration and deceleration for line speed changes in a steel mill. This ensures that all parts of the system operate harmoniously, reducing tension anomalies and mechanical failures.
Example: Coordinated Line Speed Control
FUNCTION_BLOCK FB_LineSpeedControl
VAR_INPUT
LineSpeedTarget : REAL; // Desired line speed
RampTime : INT; // Time for the ramp to complete
CurrentLineSpeed : REAL; // Current line speed
END_VAR
VAR_OUTPUT
LineSpeedOutput : REAL; // Ramped line speed
END_VAR
VAR
RampLineSpeed : REAL; // Ramped line speed value
RampFB : FB_LinearRamp; // Instance of the linear ramp function block
END_VAR
BEGIN
// Apply the ramp function
RampFB.TargetValue := LineSpeedTarget;
RampFB.RampTime := RampTime;
RampFB.CurrentValue := CurrentLineSpeed;
RampLineSpeed := RampFB.RampValue;
// Output the ramped line speed value
LineSpeedOutput := RampLineSpeed;
END_FUNCTION_BLOCK
Tips for Accurate Ramp Function Implementation
1. Understand Process Dynamics: Different processes require different ramp rates. Tailor your ramp functions to match the process dynamics and capabilities.
2. Test Before Implementation: Run a ghost process to test ramp functions and ensure they perform as expected.
3. Optimize for Different Applications: Adjust ramp rates based on how slowly the process changes and what it can handle.
4. Simple Ramp Functions: Use simple integers for time and difference to make it easy to adjust ramps during operations.
Conclusion
Mastering ramps in SCL is key to developing robust and efficient control systems. By implementing these techniques, you can improve system reliability, reduce mechanical stress, and optimize process performance.
---
About the Author
Ken Jensen brings over 24 years of experience in electrical, automation, and controls engineering across diverse industries like nuclear, steel, and glass. He is a highly skilled problem-solver with expertise in electrical systems, PLCs, SCADA, and Industry 4.0 technologies. He is adept at leading projects, driving innovation, and fostering collaboration.