Calculating control output

For this example, we will use a very simple formula to compute the expected control output: we will turn the relay on, if motion is detected when it's dark, which we interpret as when the (ambient) light sensor reports a light of less than 25%. The relay is turned off when there's no motion, or when it's not dark anymore:

if (RecalcOutput && this.motion.HasValue && this.light.HasValue) 
{ 
   bool Output = this.motion.Value && this.light.Value < 25; 
Care must be taken when installing the light sensor, so that it is not affected by, say, a lamp, connected to the relay. The expected output should also have a time component, to avoid intermittent blinking states.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset