04-27-2023 07:46 AM
See if this gives you some ideas. It was my best shot just looking at what Christian posted from the manual.
04-27-2023 09:52 AM
Hi, thanks for your reply. I was just coming to post my progress since yesterday. Please see the attached.
I have successfully fixed the case structure to look for T1, T2, T3, T4 etc by masking a bit and setting the cases to the correct values 0, 1, 2, 3 (previously the cases were 1, 2, 3, 4 however this code was written by a forum member without access to the manual at the time).
Below image shows T1 in LN2 (temp is off slightly), T2 at ambient in our lab and T3 at my laptop exhaust.
As this unit will be used to measure cryogenic temps, I tried several methods to isolate the Fahrenheit integer, sign and decimal. Including checking if the 8th bit in byte 7 was set and performing some math on the Fahrenheit integer if so. However, it seems that setting byte 5&6 to I16 returns a signed value... which I don't understand...
The only remaining issue with the code is that at negative F temperatures byte 7 returns a 1 and the decimal value. So my temps in C are out by about 10 deg C.
See Temp Dec here is 13 instead
How can I mask/isolate only the first 4 bits of byte 7 to give only the decimal value?
So far this has been a great learning experience!
I will take a look at your file now and see what I can learn from it. If you could provide a solution for my masking issue I would be greatful!
04-27-2023 10:08 AM
@crossrulz wrote:
See if this gives you some ideas. It was my best shot just looking at what Christian posted from the manual.
Byte 7 AND x07 seems to have done the trick to remove the unwanted 1 when the temps are below 0 F. Would you mind explaining what x07 means to someone who is fairly new to this kind of work?
04-27-2023 10:57 AM
@JDSuper wrote:
@crossrulz wrote:
See if this gives you some ideas. It was my best shot just looking at what Christian posted from the manual.
Byte 7 AND x07 seems to have done the trick to remove the unwanted 1 when the temps are below 0 F. Would you mind explaining what x07 means to someone who is fairly new to this kind of work?
AND is a way to "clear" (ie set to 0/low) bits inside of a number. 0x07 = 0b00000111. Any bit with a 1 in the mask will remain the same while those with a 0 will be forced to be 0. So Byte 7 AND 0x07 will result in a value with only the lowest 3 bits remaining unchanged.
You can do a search for Boolean Logic if you want more details.