_Leo
January 19, 2013, 10:30am
1
Hi everyone,
today I did some tests with a sensor in temperatures below 0 Celsius.
Unfortunately I made the mistake in declaring the temperature variable with uint32_t instead of int32_t.
Arduino shows these 3 measurements:
167771.20
167771.18
167770.95
Can anyone tell me what minus values these are? It should be somewhere around -1 Celsius or so.
Thanks.
Leo
pYro_65
January 19, 2013, 11:21am
2
Read this: http://arduino.cc/forum/index.php/topic,97455.0.html
You'll have to post some code as 167771.20 is neither an unsigned or signed integer.
_Leo
January 19, 2013, 11:32am
3
You are correct. The ones I posted are converted to float values (/100).
The int vlaues are:
16777120
16777118
16777095
Sorry about that.
pYro_65
January 19, 2013, 11:56am
4
If the values you posted are unsigned and you need signed, then there is no conversion. 16777120 will not overflow a signed 32-bit int. Which also means the reverse is true.
_Leo
January 19, 2013, 12:02pm
5
Thank you very much for the help and opening my eyes!
I am now realizing that it's a lot more complicated than I had thought.
I'm going to reverse engineer my code to find the correct value.
If that doesn't work then no big deal. It was only a "nice to have" for knowing.
I found the error in my code which is the most important thing.
Thanks again.
the numbers sound like a 24 bit int - can that be possible?
Can you tell more about the sensor ?
Link datasheet?
16777216 = 2^24
=>
16777120 = -96
16777118 = -98
16777095 = -121
If the number is to be interpreted with 2 decimals it would be -0.96, -0.98, -1.21 which looks like a stable T measurement
Post your code if you need help with reverse engineering,
_Leo
January 19, 2013, 4:53pm
8
PaulS:
I'm going to reverse engineer my code to find the correct value.
Why?
Because I'm nosey.
PaulS:
Unfortunately I made the mistake in declaring the temperature variable with uint32_t instead of int32_t.
So, fix the mistake.
There is a saying: "He who can read has a clear advantage"
This thread isn't to long. Give it a try.
_Leo
January 19, 2013, 4:58pm
9
robtillaart:
the numbers sound like a 24 bit int - can that be possible?
Can you tell more about the sensor ?
Link datasheet?
16777216 = 2^24
=>
16777120 = -96
16777118 = -98
16777095 = -121
If the number is to be interpreted with 2 decimals it would be -0.96, -0.98, -1.21 which looks like a stable T measurement
Post your code if you need help with reverse engineering,
Thanks Rob. I think you may have goten it! I will verify.
Again, knowing the values was only a "nice to know" for me. I've already corrected my code. Problem is sovled.
Case closed.
_Leo
January 19, 2013, 5:37pm
10
Rob, if I could I'd send you some Bavarian beer.
I just verified your numbers with my code -> Bull's-eye
Thanks!
Rob, if I could I'd send you some Bavarian beer.
I'll drink one here on your health,
Still open question:
Can you tell more about the sensor ? I really want to know what does 24 bit
Link datasheet?