52 lines
1.2 KiB
C
52 lines
1.2 KiB
C
/*=====================================================================================
|
|
File name: RMP3CNTL.C (IQ version)
|
|
|
|
Originator: Digital Control Systems Group
|
|
Texas Instruments
|
|
|
|
Description: The ramp3 down control
|
|
|
|
=====================================================================================
|
|
History:
|
|
-------------------------------------------------------------------------------------
|
|
04-15-2005 Version 3.20
|
|
-------------------------------------------------------------------------------------*/
|
|
#include "dmctype.h"
|
|
#include "IQmathLib.h" // Include header for IQmath library
|
|
|
|
#include "rmp_cntl_v1.h"
|
|
|
|
|
|
#pragma CODE_SECTION(rmp_cntl_v1_calc,".fast_run");
|
|
void rmp_cntl_v1_calc(RMP_V1 *v)
|
|
{
|
|
_iq tmp;
|
|
|
|
tmp = v->DesiredInput - v->Out;
|
|
|
|
if (tmp > (_iq)v->RampPlus)
|
|
{
|
|
//v->RampDoneFlag = 0;
|
|
v->Out += v->RampPlus;
|
|
if (v->Out > v->RampHighLimit)
|
|
v->Out = v->RampHighLimit;
|
|
}
|
|
else
|
|
{
|
|
if (tmp < (_iq)v->RampMinus)
|
|
{
|
|
//v->RampDoneFlag = 0;
|
|
v->Out += (_iq)v->RampMinus;
|
|
if (v->Out < v->RampLowLimit)
|
|
v->Out = v->RampLowLimit;
|
|
}
|
|
else
|
|
{
|
|
v->Out = v->DesiredInput;
|
|
//v->RampDoneFlag = 0x7FFFFFFF;
|
|
}
|
|
}
|
|
}
|
|
|
|
|