Hysteresis, manages hysteresis on a value
Permette di gestire soglie di isteresi sul superamento HThreshold o sul ripiegamento LThreshold di un valore IValue rispetto al valore di riferimento Reference attivando di conseguenza le uscite OHigh e OLow.
Descrizione
| Parametro | Tipo | Descrizione |
|---|---|---|
| IValue | REAL | Valore da controllare. |
| Reference | REAL | Valore di riferimento. |
| LThreshold | REAL | Livello di soglia inferiore isteresi. |
| HThreshold | REAL | Livello di soglia inferiore isteresi. |
| OLow | BOOL | Valore da controllare inferiore oltre al valore di soglia rispetto al valore di riferimento. |
| OHigh | BOOL | Valore da controllare superiore oltre al valore di soglia rispetto al valore di riferimento. |
Esempi
Come utilizzare gli esempi.
Nel programma viene acquisito un ingresso analogico e gestita una flag di allarme se il valore supera il set point definito.
LogicLab (Ptp114, ST_Hysteresis)
PROGRAM ST_Hysteresis
VAR
Alarm : BOOL; (* Alarm flag *)
AInp : SysGetAnInp; (* Analog input acquisition *)
AHys : Hysteresis; (* Alarm hysteresis *)
END_VAR
// *****************************************************************************
// PROGRAM "ST_Hysteresis"
// *****************************************************************************
// Acquires a voltage from A/D converter and active an alarm on high value.
// -----------------------------------------------------------------------------
// -------------------------------------------------------------------------
// INITIALIZATION
// -------------------------------------------------------------------------
// Configure the analog input acquisition and alarm hysteresis.
IF (SysFirstLoop) THEN
AInp.Address:=255; //Module address
AInp.Channel:=0; //Module channel
AInp.Mode:=AD_VOLT_0_10_COMMON; //Acquisition mode
AHys.Reference:=5.0; //Reference value
AHys.LThreshold:=0.1; //Low threshold
AHys.HThreshold:=0.1; //High threshold
END_IF;
// -------------------------------------------------------------------------
// ALARM MANAGEMENT
// -------------------------------------------------------------------------
// Acquires the voltage and manage histeresis on it.
AInp(); //Analog input acquisition
AHys(); //Alarm hysteresis
// If analog value becomes greather than 5.1 volt the alarm is set.
// Alarm remains set until the voltage drops under 4.9 volts.
IF (AHys.OLow) THEN Alarm:=FALSE; END_IF;
IF (AHys.OHigh) THEN Alarm:=TRUE; END_IF;
// [End of file]