Example 7.

Implementing Operating Modes

 

Parameters, unlike variables, are set by the user.  Moreover, parameters are saved in non-volatile memory.  This means, their values are preserved even if the controller loses power.  Parameters are useful in implementing various modes of an automated task.  The user may then switch between the modes simply by modifying the parameter value, rather than reprogramming the controller.  The following script is based on Example 6b.

 

 

title  "example 7. maximum or minimum temperature"

input  iT1, iT2;

output oFan1;

var    vT_Min, vT_Max;

par    pMode;

 

if(iT1>iT2)

 {

  vT_Max = iT1;

  vT_Min = iT2;

  }

 else

  {

   vT_Max = iT2;

   vT_Min = iT1;

   }

 

if(pMode==0)

 {

  oFan1=(vT_Min>75);

  }

 else

  {

   oFan1=(vT_Max>75);

   }

 

 

In the example given above, the mode of the task depends on the parameter.  If the value of the parameter pMode is zero, then the minimum temperature is used to trigger the fan.  Otherwise, the maximum temperature is used.

 

 

Also see : Programming, Program Examples, Script Syntax, Automated Tasks

 


© Rigel Corporation iNetGrow 2003-2006.  All rights reserved.