Hopsan
FirstOrderTransferFunction Class Reference

The FirstOrderTransferFunction class implements a first order time discrete transfer function using bilinear transform. More...

Inheritance diagram for FirstOrderTransferFunction:
FirstOrderLowPassFilter

Public Member Functions

void initialize (double timestep, double num[2], double den[2], double u0=0.0, double y0=0.0, double min=-1.5E+300, double max=1.5E+300)
 
void initializeValues (double u0, double y0)
 
void setBackupLength (size_t nSteps)
 Setup the number of backup steps to remember (size of the backup buffer)
 
void setMinMax (double min, double max)
 
void setNum (double num[2])
 
void setDen (double den[2])
 
void setNumDen (double num[2], double den[2])
 
void restoreBackup (size_t nSteps=1)
 Restore the backup at the given step.
 
void backup ()
 Pushes a backup of transfer function states into the backup buffer.
 
double update (double u)
 Updates the transfer function.
 
double updateWithBackup (double u)
 Make a backup of states and then calls update.
 
double value () const
 Read current transfer function output value.
 
double delayedU () const
 
double delayedY () const
 
bool isSaturated () const
 Check if the transfer function is saturated (has reached the set limits)
 

Protected Attributes

double mValue
 
double mDelayedU
 
double mDelayedY
 
double mCoeffU [2]
 
double mCoeffY [2]
 
double mMin
 
double mMax
 
double mTimeStep
 
bool mIsSaturated
 
Delay mBackupU
 
Delay mBackupY
 

Detailed Description

The FirstOrderTransferFunction class implements a first order time discrete transfer function using bilinear transform.

To declare a filter like

\[G=\frac{a_1 s + a_0}{b_1 s + b_0}\]

the syntax is filter.setNumDen(num, den) where $num[0]=a_0$, $num[1]=a_1$ and $den[0]=b_0$, $den[1]=b_1$

Member Function Documentation

◆ backup()

void backup ( )

Pushes a backup of transfer function states into the backup buffer.

Note
Only the delayed states are backed up, not the current value or the coefficients

◆ isSaturated()

bool isSaturated ( ) const

Check if the transfer function is saturated (has reached the set limits)

Returns
true or false

◆ restoreBackup()

void restoreBackup ( size_t nSteps = 1)

Restore the backup at the given step.

Parameters
[in]nStepsThe number of steps backwards in time to restore (1=last step) must be >=1
Note
The function assumes that the backup buffer has been allocated
See also
setBackupLength

◆ setBackupLength()

void setBackupLength ( size_t nSteps)

Setup the number of backup steps to remember (size of the backup buffer)

Parameters
[in]nStepsThe number of steps to remember

◆ update()

double update ( double u)

Updates the transfer function.

Parameters
[in]uThe new input value
Returns
The current transfer function output value after update

◆ updateWithBackup()

double updateWithBackup ( double u)

Make a backup of states and then calls update.

Parameters
[in]uThe new input value
Returns
The current transfer function output value after update

◆ value()

double value ( ) const

Read current transfer function output value.

Returns
The filtered actual value.