You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

The Code is implemented in accordens to the requirments given in the function description. Quickly summerized it describes the following,

  • Survey and report the moisture in the air,
  • Sound  an alarm after 10 mintues if the moisture deviates more than +-5%rH away from the setpoint.
  • In case of an alarm, turn on fans to ensure a well ventilated facility


The Code for the Moisture sensor is based on its technical data, where 0v = 0%rH[NOT VERIFIED]  which linearly scales to 10v = 100%rH[NOT VERIFIED]. This means that linear interpolation is utilized to scale the input voltage too an output in %rH.


Linear interpolation is performed with the following function,


This means that the inputs needs to be,

  • sensor_reading:REAL;
  • set_point_in_pRhREAL;
  • alarm_delay:TIME;
  • max_pRh:REAL;
  • max_pRh_in_volts:REAL;
  • min_pRh:REAL;
  • min_pRh_in_volts:REAL;


And the outputs needs to be,

  • pRh_read:REAL;
  • alarm_high:BOOL;
  • alarm_low:BOOL;


With the following internal variables,

  • alarm_since_trig:TIME;
  • alarm_high_trig:BOOL;
  • alarm_low_trig:BOOL;
  • alarm_high_trig_0:BOOL;
  • alarm_low_trig_0:BOOL;


The coded implementation looks like this,


Visually the new function block looks as following,

  • No labels