Below is a general example of what I would imagine a ramp sequence would look like. This will vary depending on your project, but just so you get a general idea here is a macro I came up with in office.
macro_command main()
short PERIOD_SEC = 5
// Ramp durations
short TASK1_SEC = 3600
short TASK2_SEC = 7200
short TASK3_SEC = 10800
// Angle setpoints in whole degrees
short ANGLE_START = 100
short ANGLE_1_END = 150
short ANGLE_2_END = 200
short ANGLE_3_END = 250
short profile_step
short elapsed_sec
short start_angle
short end_angle
short duration_sec
short t_eff
int angle_sp
int delta_angle
// Read current sequence state
GetData(profile_step, “Local HMI”, LW, 100, 1)
GetData(elapsed_sec, “Local HMI”, LW, 101, 1)
// Initialize sequence
if profile_step == 0 then
profile_step = 1
elapsed_sec = 0
end if
// Select active task
if profile_step == 1 then
// Task 1: 100 → 150 over 1 hour
start_angle = ANGLE_START
end_angle = ANGLE_1_END
duration_sec = TASK1_SEC
else if profile_step == 2 then
// Task 2: 150 → 200 over 2 hours
start_angle = ANGLE_1_END
end_angle = ANGLE_2_END
duration_sec = TASK2_SEC
else if profile_step == 3 then
// Task 3: 200 → 250 over 3 hours
start_angle = ANGLE_2_END
end_angle = ANGLE_3_END
duration_sec = TASK3_SEC
else
// Sequence finished: hold final angle
angle_sp = ANGLE_3_END
SetData(angle_sp, “Local HMI”, LW, 10, 1)
SetData(profile_step, “Local HMI”, LW, 100, 1)
SetData(elapsed_sec, “Local HMI”, LW, 101, 1)
return
end if
// Advance time by macro period
elapsed_sec = elapsed_sec + PERIOD_SEC
// Clamp effective time
if elapsed_sec < 0 then
t_eff = 0
else if elapsed_sec > duration_sec then
t_eff = duration_sec
else
t_eff = elapsed_sec
end if
// Linear ramp calculation
delta_angle = end_angle - start_angle
angle_sp = start_angle + (delta_angle * t_eff) / duration_sec
// When task completes, snap to endpoint and advance
if elapsed_sec >= duration_sec then
angle_sp = end_angle
elapsed_sec = 0
profile_step = profile_step + 1
end if
// Write outputs
SetData(angle_sp, “Local HMI”, LW, 10, 1) // Current angle setpoint
SetData(profile_step, “Local HMI”, LW, 100, 1) // Current task number
SetData(elapsed_sec, “Local HMI”, LW, 101, 1) // Elapsed time in current task
end macro_command