取消
显示结果 
搜索替代 
您的意思是: 

Serial communication with thermometer

See if this gives you some ideas.  It was my best shot just looking at what Christian posted from the manual.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
31 条消息(共 34 条)
585 次查看

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. 

JDSuper_0-1682606952262.png

 

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 

JDSuper_1-1682607063272.png

 

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!

0 项奖励
32 条消息(共 34 条)
568 次查看

@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?

 

 

0 项奖励
33 条消息(共 34 条)
562 次查看

@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.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
34 条消息(共 34 条)
552 次查看