Posts: 1,255
Threads: 219
Joined: May 2007
Reputation:
0
Is it possible to do basic arithmatic on counters?
I have a counter with Temperature in Farenheit but want to convert to Celcius.
ie C= (F-32)x(5/9)
Not currently possible?
Posts: 6,024
Threads: 880
Joined: Apr 2006
Reputation:
3
Multiplication not possible at present
Posts: 629
Threads: 62
Joined: Jan 2007
Reputation:
2
03-29-2009, 02:38 PM
(This post was last modified: 03-29-2009, 02:44 PM by Ingo.)
I have a similar request. I would like to do division of a counter value for a start. EG. Counter02 = (Counter01 / 2). Would these functions be available at some stage?
As an added bonus, would it then be possible to set a CBus command value to the value of a Counter? EG. CBUS Ramp4 2 117 <Counter02>
Posts: 1,200
Threads: 262
Joined: Mar 2007
Reputation:
0
This can be considered but there is a limitation to the use of mulitplication and division operations on counters which are integer values from 0 to 255
Multiplication may end up with overflow, and there may not be an easy way to test for this. Division may end up with a quotient that has a limited range.
Floating point operations are not feasible within this system
What is your application. do you just need a divide by 2 operation?
Posts: 629
Threads: 62
Joined: Jan 2007
Reputation:
2
As a matter of fact, ending with a fraction is of no concern. If it\'s dropped it will still work. My current application is a logic module to dim the Cbus lights to half the original value, the original value can be anything from 1-255. EG. 255/2 = 127 or 128, you choose.
The next step would be to save the original value to a different counter location so when I restore the value I can just use the saved value. I haven\'t tried this so I don\'t know if it\'s possible at all.
Posts: 113
Threads: 14
Joined: Aug 2006
Reputation:
0
I would have thought that this type of automation would be better achieved in Cbus
And just let Comfort kick it off
Mike
Posts: 113
Threads: 14
Joined: Aug 2006
Reputation:
0
I would have thought that this type of automation would be better achieved in Cbus
And just let Comfort kick it off
Mike
Posts: 629
Threads: 62
Joined: Jan 2007
Reputation:
2
Exactly, in CBus it works like a charm but you need a logic unit. Mine (Homegate PC) is not very reliable as it\'s my normal home PC as well (Reboots, hung programs etc.). I\'ve been trying to migrate all my logic to Comfort with varying degrees of success, most of the stuff can be migrated but this one is a sticky one.
Posts: 1,200
Threads: 262
Joined: Mar 2007
Reputation:
0
You can use logic to achieve this for now
If Counter X >= 240 then
set Counter X = 120
Endif
If Counter X >= 224 then
Set Counter X = 112
Endif
etc
This divides the counter values into bands and sets a dim level of 1/2 of the valudof the bands
It may not be perfect and requires a bit of code but may achieve what you want, as our eyes are not so sensitive to the exact dimming level
Posts: 629
Threads: 62
Joined: Jan 2007
Reputation:
2
Hmmmm.... That is an option. How about restorring the original value back. If the light is dimmed and movement is detected I want to restore the light to the original brightess. Is there a way do that as well? Me trying to use Copy Counters and then trying to set a counter value doesn\'t seem to work.