Notifications
Clear all

[Solved] Problems reading from MAX81855-K

26 Posts
3 Users
7 Reactions
201 Views
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 8047
 

@timo88 Google it first to see if anything pops up.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 8047
 

@timo88 Good news, lots of mentions of the MAX6675.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
Timo88 reacted
ReplyQuote
Timo88
(@timo88)
Member
Joined: 2 years ago
Posts: 26
Topic starter  

Posted by: @zander

@timo88 Google it first to see if anything pops up.


Yes, I already did that 🙂

 


   
ReplyQuote
TFMcCarthy
(@tfmccarthy)
Member
Joined: 8 months ago
Posts: 329
 

Posted by: @zander

That is a common hobbyist error. I suspect you like me spent a long professional career filling pages of code with exception checking.

Error handling is a full topic with design strategies, e.g., return value vs. function parameter vs global error state, etc. And programmers of all levels overlook it such that it's become an idiom: "Always check the error codes." Early error detection is usually the better option. Detailed reporting is great when you can afford it; else, report the raw error code.

The one who has the most fun, wins!


   
Ron reacted
ReplyQuote
TFMcCarthy
(@tfmccarthy)
Member
Joined: 8 months ago
Posts: 329
 

Posted by: @timo88

OK even with extra error checking I still get mostly "OK" as a status and 0 value.

"Mostly OK"? Like, "slightly pregnant"? In any event, not a good sign. 

The algorithm is a little askew.

void printStatusMessage(int statusCode);

start = micros();
  int status = thermoCouple.read();
  stop = micros();

...

At this point you only want to process data if the status is OK. Otherwise, you want to output the error.

if (status != OK) {
    printStatusMessage(statue);
    return;
}

// staus is OK, get the temp...

The idea here is not to make additional calls to the device when there's an outstanding error. Some devices and code can "lose their minds" if you do that and it's inefficient to "push on the door marked PULL".

You want to pay attention to those error messages to get an idea what's going wrong. You may encounter the same error with a different device. This where the "mostly OK" comes in.

What are the errors when it's not OK?

This may be an indicator that the code is querying the device too fast, and it can't keep up or become stable. You may need to impose a delay between reads.

The one who has the most fun, wins!


   
Ron reacted
ReplyQuote
Timo88
(@timo88)
Member
Joined: 2 years ago
Posts: 26
Topic starter  

@tfmccarthy I understand what you are saying, but I'm in the "testing stage".
I had other code, which didn't work and then decided to go back to one of the examples to first try to make that work.
I'll add more delay and see if that helps.


   
ReplyQuote
Timo88
(@timo88)
Member
Joined: 2 years ago
Posts: 26
Topic starter  

It works now.
I removed everything from the breadboard and plugged it all in again.
I get logical reading now.
I have no idea what's different from before as I already checked my wiring 10 times.

Readings are now:

-------------

time: 56
stat: OK
raw: 0000 0001 0010 1000 0001 0100 1001 0000
internal: 20.562
temperature: 18.500

time: 56
stat: OK
raw: 0000 0001 0010 1000 0001 0100 1001 0000
internal: 20.562
temperature: 18.500

time: 56
stat: OK
raw: 0000 0001 0010 1000 0001 0100 1001 0000
internal: 20.562
temperature: 18.500

time: 56
stat: OK
raw: 0000 0001 0010 1000 0001 0100 1001 0000
internal: 20.562
temperature: 18.500

time: 56
stat: OK
raw: 0000 0001 0010 1000 0001 0100 1001 0000
internal: 20.562
temperature: 18.500

time: 56
stat: OK
raw: 0000 0001 0001 1000 0001 0100 1001 0000
internal: 20.562
temperature: 17.500

--------------

 

Delay 1 second.
Thank you for your feedback 🙂


   
ReplyQuote
TFMcCarthy
(@tfmccarthy)
Member
Joined: 8 months ago
Posts: 329
 

Posted by: @timo88

It works now.
I removed everything from the breadboard and plugged it all in again.
I get logical reading now.
I have no idea what's different from before as I already checked my wiring 10 times.

Murphy's Law or Magic, take your pick.

Rebuilding the circuit is my "last resort" and I'm embarrassed to admit that's when I find an obvious circuit error.

Great though.

The one who has the most fun, wins!


   
Timo88 reacted
ReplyQuote
Timo88
(@timo88)
Member
Joined: 2 years ago
Posts: 26
Topic starter  

This is a good video about both sensors, in case someone lands on this thread via search:


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 8047
 

@timo88 There are only a couple of boards that have anywhere close to reliable connectors. I have a few of the ones that don't cost a lot more. The other 'secret' is to only use Silicone wires. They are limp and put NO pressure on the pins in the board. Are they foolproof, not quite but they are much more reliable than the alternative.

Glad to hear you are now moving forward.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
Timo88 reacted
ReplyQuote
Timo88
(@timo88)
Member
Joined: 2 years ago
Posts: 26
Topic starter  

OK one last update..
Al seemed to be working until I moved the breadboard.
After watching the video above, it's now clear that my Chinese sensor board is missing a 10nf capacitor.

See also:

When I added the capacitor to the MAX31855K board (as in the video), the readings seem stable.
I guess the position of the board made a difference in how much noise was picked up by the Thermocouple.


   
ReplyQuote
Page 2 / 2