![]() |
|
Practical Temp Control Using SCS - Printable Version +- Comfort Automation/ Security System Forums (https://www.comfortforums.com) +-- Forum: Products (https://www.comfortforums.com/forum-3.html) +--- Forum: Scene Control Switches (OBSOLETE) (https://www.comfortforums.com/forum-57.html) +--- Thread: Practical Temp Control Using SCS (/thread-777.html) |
- garym999 - 09-01-2007 Never been good at maffs and cannot see the answer for looking...Trying to get Comfort to turn an output on or off based on the temperature of the SCSSensor and comparision to a counter containing the setpoint. Obviously the counter can only contain a value of 0-255, no negative numbers. So how do I work out wether to turn the output on or off, using if statements or subtracting counters? - admin - 01-03-2009 Sorry we missed this question 16 months is still not that bad for an answer ![]() This code is a suitable example Get SensorRegister 8 Subtract Counter001 If LastActionValue <128 Then Do IR1Output1 End If It compares sensor 8 with the value in counter 1 If <128 (equivalent to > 0) then it does something Note that counter values 0 to 255. If a comparison result is negative the value in the counter is > 128 eg Counter 1 =100 Counter 2 = 200 Counter 1 - Counter 2 gives a value in the counter of 100-200+256 = 156 This is because counters have positive values and dont directly support signed arithmetic You can add the Else condition if the sensor is less than the counter value |