FUNCTION_BLOCK FB200
VAR_INPUT
bResetRamp:BOOL;
bRampUp:BOOL;
bRampDown:BOOL;
rRampTimeInSecs:REAL;
rInterruptTimeInSecs:REAL;
END_VAR
VAR_OUTPUT
iAnaloguePQW:INT;
rRampMonitorPerCent:REAL;
END_VAR
VAR
rRampStore:REAL;
END_VAR
VAR_TEMP
rRampIncrement:REAL;
wFC106Return:WORD;
END_VAR
BEGIN
rRampIncrement:= 100.0 * rInterruptTimeInSecs/rRampTimeInSecs;
IF bRampUp THEN rRampStore:=rRampStore + rRampIncrement; END_IF;
IF bRampDown THEN rRampStore:=rRampStore - rRampIncrement; END_IF;
IF bResetRamp THEN rRampStore:=0.0; END_IF;
IF rRampStore > 100.0 THEN rRampStore:=100.0; END_IF;
IF rRampStore < 0.0 THEN rRampStore:=0.0; END_IF;
rRampMonitorPerCent:=rRampStore;
wFC106Return:= FC106(IN := rRampStore
,HI_LIM := 100.0
,LO_LIM := 0.0
,BIPOLAR := FALSE
,OUT := iAnaloguePQW
);
END_FUNCTION_BLOCK
PeterW said:Not sure of the application where the ramp itself needs contolling, but I would assume you would set the drive ramp to maximum to enable the PLC to do this control, or at least a value which would ensure that the ramp is limited.
I have had applications, powder filling onto loadcells for example, where the speed would change as you get closer to the target, but the ramp rate was fixed in the drive.
Might make it easier if you spec'd a few things, like max/min time values, the step change (or linear if calc'd).
The 0-100% I am assuming is the drive speed.
10BaseT. said:Wouldn't you set the drive ramp to minimum in this case ?
10BaseT. said:I personally prefer an "S" curve function - but this is a straightforward ramp function :-
please declare ALWAYS_ON in your symbol table , and make it tru all of the time . If you wish an "S" curver ramp , let me know .
Is there any reason why you don't set the ramp time in the drive over profibus (assuming you are using this for comms) ?
FUNCTION "RAMP" : VOID
TITLE =
AUTHOR : AD
VERSION : 0.1
VAR_INPUT
ENABLE : BOOL ; //ENABLE RAMP
PULSE : BOOL ; //PULSE
TARGET : REAL ; //TARGET RAMP VALUE
INCREMENT : REAL ; //INCREMENT VALUE
END_VAR
VAR_IN_OUT
ACTUAL_VALUE : REAL ; //ACTUAL RAMP VALUE
END_VAR
VAR_TEMP
RAMP_UP : BOOL ;
RAMP_DOWN : BOOL ;
END_VAR
BEGIN
NETWORK
TITLE =If Ramp not enabled set actual value to target
AN #ENABLE;
JNB _001;
L #TARGET;
T #ACTUAL_VALUE;
_001: NOP 0;
NETWORK
TITLE =Check whether to ramp up or down
A #ENABLE;
= L 1.0;
A L 1.0;
A( ;
L #TARGET;
L #ACTUAL_VALUE;
<R ;
) ;
= #RAMP_DOWN;
A L 1.0;
A( ;
L #TARGET;
L #ACTUAL_VALUE;
>R ;
) ;
= #RAMP_UP;
NETWORK
TITLE =Ramp UP to Target Value
A #ENABLE;
A #RAMP_UP;
A #PULSE;
JNB _002;
L #INCREMENT;
L #ACTUAL_VALUE;
+R ;
T #ACTUAL_VALUE;
_002: NOP 0;
NETWORK
TITLE =Ramp DOWN to Target Value
A #ENABLE;
A #RAMP_DOWN;
A #PULSE;
JNB _003;
L #ACTUAL_VALUE;
L #INCREMENT;
-R ;
T #ACTUAL_VALUE;
_003: NOP 0;
NETWORK
TITLE =Limit ramp value to target and set flag when ramp done
A "ALWAYS_ON";
= L 1.0;
A L 1.0;
A #RAMP_UP;
A( ;
L #ACTUAL_VALUE;
L #TARGET;
>=R ;
) ;
JNB _004;
L #TARGET;
T #ACTUAL_VALUE;
_004: NOP 0;
A L 1.0;
A #RAMP_DOWN;
A( ;
L #ACTUAL_VALUE;
L #TARGET;
<=R ;
) ;
JNB _005;
L #TARGET;
T #ACTUAL_VALUE;
_005: NOP 0;
END_FUNCTION