In SX Microcontrollers, SX/B Compiler and SX-Key Tool, mgreen wrote: Maybe it's better to not have a fixed length cycle. For each sensor, you keep the last two readings so you know the absolute value and the change from the previous reading. You also have a counter for each sensor that indicates how many cycles (of 8 readings) that you will skip before checking again. You will go through a cycle of 8 sensors as follows: 1) If the "skip count" is > 0, decrease it by 1 and go on to the next sensor 2) Copy the "most recent value" to the "previous value" for this sensor, read the sensor, and save the "most recent value" 3) If the value is < 64, set "skip count" to 3; if < 128, set to 2; if < 192, set to 1; otherwise, set to 0 This prioritizes the readings in favor of sensors already seeing a higher value 4) If the "most recent value" - "previous value" is > 64, set "skip count" to 0 This makes sure we will track a rapidly increasing value even if it's low at present 5) If the "most recent value" is greater than the critical limit, stop the Pump ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=171859#m171878 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)