Siemens Step 7 Ramp Generator

B

Thread Starter

Bill Stonier

I am trying to write a ramp generator using Step 7 software this is being used
to ramp a drive motor speed up ( and down).
The variables I have are...
1) Start Speed
2) End Speed
3) Ramp time (x.x secs)

I am aware of how to do this using a timer in PLC5, but cannot work out how to do this using S7.

I would appreciate any help!
 
J
If you have access to scl then look this over. I have used this block quite successfully in applications where I need to ramp a setpoint from point a to point b. The key is the {S7_scan_time} compiler directive. This causes the OB time to be loaded into the scantime variable. This is used to provide the time
basis for the code.

FUNCTION_BLOCK "RampGen"

{

S7_alarm_ui :='1';
S7_m_c := 'true'

}

// Block Parameter
VAR_INPUT
// Input Parameter

Enable {S7_m_c := 'true'} : Bool; // Hold logic
Hold {S7_m_c := 'true'} : Bool; // Hold logic

Setpoint {S7_m_c := 'true'} : Real; // Goal
RampRate {S7_m_c := 'true'} : Real := 1.0; // Rate in delta
out per unit time (1/60)* samepletime
StartOut {S7_m_c := 'true'} : Real; // Where does
the ramp begin

ScanTime {S7_sampletime := 'true';
S7_visible := 'false'} : Real; // Execution time
in seconds

SampleTime {S7_m_c := 'true'} : Real := 1.0; // one second
execution rate

Conversion {S7_visible := 'false'} : Real := 60.0; // Used to
convert the Ramprate units from minute to sec


END_VAR

VAR_IN_OUT
// In/Out Parameter


Reset {S7_m_c := 'true'} : Bool; // Reset the
ramp back to start pt
CfcReset : Bool; // Allow cfc
logic to reset

END_VAR

VAR_OUTPUT
Enabled {S7_m_c := 'true'} : Bool; // Hold logic
Equal {S7_m_c := 'true'} : Bool; // Input equals output
Held {S7_m_c := 'true'} : Bool; // Ramp is held last output

Output {S7_m_c := 'true'} : Real; // Output signal
ITerm {S7_m_c := 'true'} : Real; // Out changes by this much


END_VAR

VAR_TEMP
// Temporary Variables

Diff : Real;
TOut : Real;

MyFalse : Bool;
SetEqual : Bool;
MySampleTime : Real;


END_VAR

VAR
// Static Variables


ETime : Real;
TimeOut : Bool;
XReset : Bool;


END_VAR

BEGIN
XReset := Reset or
CfcReset;
If(Enable) Then
MySampleTime := SampleTime;
If(SampleTime < ScanTime) Then
MySampleTime := ScanTime;
End_If;


ETime := Etime + ScanTime;
Timeout := (ETime >= MySampleTime);
If(TimeOut) Then
ETime := 0.0;
End_If;

// Allow ramp to be reinitialized

If(XReset) Then
OutPut := StartOut; // Restart the ramp
End_If;
If(Enable and Not(Enabled)) Then
Output := StartOut;
End_if;

If(TimeOut) Then
ITerm := (RampRate / Conversion) * MySampleTime;
Diff := (Setpoint - Output);
Tout := Output;
If(Hold) Then
ITerm := 0.0;
End_If;
If(Diff < 0.0) Then
Tout := Output - Iterm;
If(Tout < Setpoint) Then
Tout := Setpoint;
End_If;
Else
Tout := Output + Iterm;
If(Tout > Setpoint) Then
Tout := Setpoint;
End_if;
End_If;

Output := Tout;
End_if;
SetEqual := (Output = Setpoint);
Equal := SetEqual and Enable;
Held := Hold;
End_if;

Reset := False;
Enabled := Enable;


;

END_FUNCTION_BLOCK
 
The modern digital motor drives have a ramp generator. Depend of Motor Drive and PCL manufacturer you can control the parameter of the ramp (delay time, init time, stop time, etc). Therefore maybe you don't need to implement your
own ramp generator, instead of that, you can use the Motor Drives itself. I used the Siemens S7-200 to control parameters of the Siemens Micromaster, Midimaster, etc motor drives via USS protocol using the serial interface RS-485. Is possible that you can do some thing like that with other manufacturer motor drives.

Luis Rios
 
Hi:

Time ago, I implemented a ramp generator in a very easy way. It is not sophisticated but maybe useful in some applications. Using the scan cycle time, you can increase or decrease a variable by "1" or more, changing in this way the rate of variation of this variable. Complementary programming to prevent overflows and so on, and it works!

Hope be useful data.

Aquilino Rodriguez

Festo Spain
 
Top