#2208 - 02/28/05 02:15 AM
negative temperature display
|
Brew
newbie
Registered: 08/31/04
Posts: 20
|
I am converting to "degrees C" using -132 *5 /9. But when the reslut is less that zero Cmax does not display the result as a negative number. I understand why but can someone help me reslove the problem? I have searched the board for a solution and found one other identical question, but it was not answered.
|
|
Top
|
|
|
|
#2210 - 02/28/05 04:52 AM
Re: negative temperature display
|
Brew
newbie
Registered: 08/31/04
Posts: 20
|
Guy, I have the following code that will not display as a negative number when the data from the bobcat is less than 132 (zero degrees F).
: IF Data for Module# 1 is < 256 //always true THEN Temp_Variable = Data for Module# 1 THEN Temp_Variable - 132 THEN Temp_Variable * 5 THEN Temp_Variable / 9 //Converted to C THEN Outside_Temp = Temp_Variable //////////////////////////////////////// Leopard display object for Outside_Temp is formatted as %3d
If the bobcat data is say 129 then the first part of the conversion, 129-132 is -3 or internally for Cmax "65533" so now the rest of the calculation is screwed up.
Am I right? If this is true I cannot think of the solution, mind you, I was never very good at Math.
|
|
Top
|
|
|
|
#2212 - 02/28/05 06:17 AM
Re: negative temperature display
|
Brew
newbie
Registered: 08/31/04
Posts: 20
|
EXCELLENT!!!
That did the trick. Simple solution once you know. Guy you are worth your weight in gold!
Now just have to get it to do decimal places...for which I will also use your recommendation post on this board. What would we do without you?
|
|
Top
|
|
|
|
#2213 - 02/28/05 07:09 AM
Re: negative temperature display
|
Guy Lavoie
Beyond All Hope
   
Registered: 12/21/02
Posts: 6401
Loc: Montreal, QC, Canada
|
Since C-Max only has whole numbers, you cannot get decimal values directly. Instead, you would do similar offset thing where you multiply the temperature reading by a larger number during the conversion to increase the precision. Its the division by 9 that produces the decimal value, so if instead of multiplying by 5 we multiply by 50, the result will be 10 times larger after the multiplication and division. We also now need to subtract an offset of 1000 because of this. We then use divide and modulo to extract the two numbers (whole and decimal). You would need to display the two variables side by side on the Leopard screen, with a text "." between the two fields. Say you want one digit past the decimal point:
IF Data for Module# 1 is < 256 //always true THEN Temp_Variable = Data for Module# 1 THEN Temp_Variable + 80 //increase offset to 180 THEN Temp_Variable - 32 THEN Temp_Variable * 50 // multiply by 50 THEN Temp_Variable / 9 //Converted to C THEN Temp_Variable - 1000 //subtract 1000 offset THEN Outside_Temp_Whole = Temp_Variable / 10 //get whole number part THEN Outside_Temp_Decimal = Temp_Variable % 10 //get the decimal part
For example: 73 degrees F:
bobcat returns 173. If you add 80 and subtract 32, you get 221. Multiply by 50 to get 11050 and divide by 9 to get 1227. Subtract the 1000 offset to get 227.
The whole number is obtained with division by 10, giving 22.
The decimal number is obtained with modulo 10, giving 7 ie: the temperature is 22.7 C.
On the Leopard screen, you would use three objects placed side by side:
"%3d", "." and "%1d". You might need to fiddle around with exact placement to get it just right.
_________________________
"If you don't know what you're doing, do it neatly..."
|
|
Top
|
|
|
|
#21239 - 07/13/09 01:54 AM
Re: negative temperature display
[Re: Guy Lavoie]
|
AlainD
junior
Registered: 02/11/03
Posts: 27
Loc: Paris
|
Hi, I would be also interested to convert °F to °C ... But I did not suceeded to enter these lines through C-Max ...
--- (Guy's suggestion) --- IF Data for Module# 1 is < 256 //always true THEN Temp_Variable = Data for Module# 1 THEN Temp_Variable + 80 //increase offset to 180 THEN Temp_Variable - 32 THEN Temp_Variable * 50 // multiply by 50 THEN Temp_Variable / 9 //Converted to C THEN Temp_Variable - 1000 //subtract 1000 offset THEN Outside_Temp_Whole = Temp_Variable / 10 //get whole number part THEN Outside_Temp_Decimal = Temp_Variable % 10 //get the decimal part ---
Did I missed something with C-Max ??
Thanks.
Alain.
Edited by AlainD (07/13/09 01:57 AM)
|
|
Top
|
|
|
|
#21241 - 07/13/09 11:17 AM
Re: negative temperature display
[Re: Guy Lavoie]
|
AlainD
junior
Registered: 02/11/03
Posts: 27
Loc: Paris
|
Hi Guy, In fact, I would like to use your conversion method and send the result in Homeseer ... But I do not see how to convert your code for this ...
|
|
Top
|
|
|
|
#21243 - 07/13/09 01:45 PM
Re: negative temperature display
[Re: Guy Lavoie]
|
AlainD
junior
Registered: 02/11/03
Posts: 27
Loc: Paris
|
Thanks Guy.
And how to insert "Temp_Variable" key ? It is not accepted and recognized by C-Max ...
Thanks.
Edited by AlainD (07/13/09 01:46 PM)
|
|
Top
|
|
|
|
#22251 - 12/29/10 05:15 PM
Re: negative temperature display
[Re: Guy Lavoie]
|
AlainD
junior
Registered: 02/11/03
Posts: 27
Loc: Paris
|
Hello Guy,
Thanks for this reply. Sorry to come back to you so lately (1,5 year later !) :-)
I use Homeseer. If I want to load the final result of this sequence to HS, how can I do ??
IF Data for Module# 1 is < 256 //always true THEN Temp_Variable = Data for Module# 1 THEN Temp_Variable + 80 //increase offset to 180 THEN Temp_Variable - 32 THEN Temp_Variable * 50 // multiply by 50 THEN Temp_Variable / 9 //Converted to C THEN Temp_Variable - 1000 //subtract 1000 offset THEN Temp_Variable / 10 THEN Outside_Temp_Whole = Temp_Variable
Thanks.
Alain.
|
|
Top
|
|
|
|
#22260 - 12/30/10 02:08 PM
Re: negative temperature display
[Re: Guy Lavoie]
|
AlainD
junior
Registered: 02/11/03
Posts: 27
Loc: Paris
|
Thanks Guy,
In fact, that's I understood at first.
It is a stupid error from my side. When I did the tests with your conversion code, it was on a Bobcat-T unit located outside. The result notified in HS was 0. So, no result according to me. In fact the temperature outside was ... 0°C. It was working fine !
:-)
Thanks a lot !
Happy to have now the results in Celsius.
Alain.
Edited by AlainD (12/30/10 02:14 PM)
|
|
Top
|
|
|
|
#22270 - 01/02/11 02:51 PM
Re: negative temperature display
[Re: Guy Lavoie]
|
AlainD
junior
Registered: 02/11/03
Posts: 27
Loc: Paris
|
Hi Guy,
It seems that when the Bobcat-T reaches the value 132 (under 0°C), the value in HS displayed is 6553 ! Is it normal ?
Here is the conversion used :
0072 - IF Module #6 -BOBCAT-T is < 256 // Bobcat-T Ext. Nord 0073 - THEN Variable #4 = Data for Module# 6 // 0074 - THEN Variable #4 + 80 // 0075 - THEN Variable #4 - 32 // 0076 - THEN Variable #4 * 50 // 0077 - THEN Variable #4 / 9 // 0078 - THEN Variable #4 - 1000 // 0079 - THEN Variable #4 / 10 // 0080 - THEN Variable #2 = Variable #4 //
Thanks.
Alain.
|
|
Top
|
|
|
|
Moderator: Dan Smith, Monte G, ADI Tech Support, Guy Lavoie
|
0 registered
and 26 anonymous users online.
|
|
2747 Members
19 Forums
3835 Topics
22711 Posts
Max Online: 67 @ 08/16/11 03:08 PM
|
|
|
|
|
|
1
|
2
|
3
|
4
|
|
5
|
6
|
7
|
8
|
9
|
10
|
11
|
|
12
|
13
|
14
|
15
|
16
|
17
|
18
|
|
19
|
20
|
21
|
22
|
23
|
24
|
25
|
|
26
|
27
|
28
|
29
|
|
|
|
|
|