Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DS18B20 FAHRENHEIT ACCURACY
31-10-2015, 02:33 PM,
#21
RE: DS18B20 FAHRENHEIT ACCURACY
(31-10-2015, 09:52 AM)brikker Wrote: Hi Derf,

you were right, I didn' t thought on it.
See this page: http://wiki.pinguino.cc/index.php/Data_types
if ifar is u16 then the max value for the multiply is 65535
then if you consider the max temperature which can be read by the sensor (125C), will return 125*100*9= 112500 which is bigger then the value limit of 65535.
You can change the declaration of ifar to u32 or doing as you did above.

I still do not understand why you make calculation before reading the sensor:
t.sign, t.integer and t.fraction are available after the reading of the sensor.
If you call them before, at first powerup you will get some wrong value, then you are going to display the previous value.
The actual temperature is dispalyed only on next cycle.
Correct me if I am wrong.

Luca
luca
i moved my calculation to after the sensor reading.
thank you 
fred
Reply
31-10-2015, 02:50 PM,
#22
RE: DS18B20 FAHRENHEIT ACCURACY
thank you all i we now have a good accurate temperature sketch for the pinguino.i will send this to regis to upload in the next revision.
thank you
fred
Reply
31-10-2015, 06:53 PM, (This post was last modified: 31-10-2015, 06:55 PM by pingotg.)
#23
RE: DS18B20 FAHRENHEIT ACCURACY
This is ugly and non-portable:
Code:
if (t.sign) {

             temp_sign = 45;                      // ascii "-"
         } else {
             temp_sign = 43;                      // ascii "+"
         }



better to use:
if (t.sign) {
             temp_sign = '-';
         } else {
             temp_sign = '+';
         }

or just:
             temp_sign = t.sign ? '-' : '+';

John
Reply
01-11-2015, 12:58 AM,
#24
RE: DS18B20 FAHRENHEIT ACCURACY
(31-10-2015, 06:53 PM)pingotg Wrote: This is ugly and non-portable:

Code:
if (t.sign) {

             temp_sign = 45;                      // ascii "-"
         } else {
             temp_sign = 43;                      // ascii "+"
         }



better to use:
if (t.sign) {
             temp_sign = '-';
         } else {
             temp_sign = '+';
         }

or just:
             temp_sign = t.sign ? '-' : '+';

John
John,
 thank you for your input i have modified with your line of code update. this works .

fred 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)