Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 16:47 19 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Reading thermocouples.

Author Message
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 11:35am 07 Jun 2017
Copy link to clipboard 
Print this post

Ok, Preamble first.

I used to have an old Pot Belly heater in the outdoor area;
It's air vent at the bottom was operated by a bimetallic coil to regulate the air flow.

Worked brilliantly.

So, Thinking of controlling the air damper on my main heater;
Eliminate all the trips up & down to adjust it's air flow.

I've got a couple of MAX6755 Thermocouple modules & can see how the data string looks.....




I can probably deal with pulling that apart & getting the data.

What I'm not clear on is SPI communications & how I get the 2 bytes from the device.
I know CS has to be pulled low??, will something like the example code in the manual be all I need to retrieve the 2 bytes?

[Code]PIN(10) = 1 : SETPIN 10, DOUT ' pin 10 will be used as the enable signal
SPI OPEN 5000000, 3, 8 ' speed is 5 MHz and the data size is 8 bits
PIN(10) = 0 ' assert the enable line (active low)
junk = SPI(&H80) ' send the command and ignore the return
byte1 = SPI(0) ' get the first byte from the slave
byte2 = SPI(0) ' get the second byte from the slave
PIN(10) = 1 ' deselect the slave
SPI CLOSE ' and close the channel[/code]

Thanks

Phil.

Module I'm using.


 
Justplayin

Guru

Joined: 31/01/2014
Location: United States
Posts: 313
Posted: 12:05pm 07 Jun 2017
Copy link to clipboard 
Print this post

SPI is not mentioned in the data sheet for the MAX6755, is the board an SPI adapter? does it have separate docs?


--Curtis
I am not a Mad Scientist...  It makes me happy inventing new ways to take over the world!!
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 01:30pm 07 Jun 2017
Copy link to clipboard 
Print this post

I would have read SPI on this data sheet.

Phil.
 
redrok

Senior Member

Joined: 15/09/2014
Location: United States
Posts: 209
Posted: 01:45pm 07 Jun 2017
Copy link to clipboard 
Print this post

Hi Curtis
  Justplayin said   SPI is not mentioned in the data sheet for the MAX6755, is the board an SPI adapter? does it have separate docs?
--Curtis
See:Henrysbench
See:MAX6675 Datasheet It seems to say its got SPI.

I've been using the MAX31855 which seems to work similarly and the SPI works for me.
redrok
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3167
Posted: 02:25pm 07 Jun 2017
Copy link to clipboard 
Print this post

Reading from the chip is simple.

You can read the whole 16 bits in one lump:

PIN(10) = 1 ' set the pin to inactive
SETPIN 10, DOUT ' pin 10 is the enable signal
SPI OPEN 100000, 3, 16 ' speed is 100KHz, data size is 16 bits
PIN(10) = 0 ' assert the enable line (active low)
d = SPI(0) ' get the whole 16 bits
PIN(10) = 1 ' deselect the chip
SPI CLOSE ' close the SPI channel


The data will be in d (preferably this is an integer).

PRINT "Thermocouple reading =" d>>3

Because this is a type K thermocouple you can get away with treating its output as linear from 0 to 1000 C. So this should be accurate within a few degrees:

PRINT "Temperature =" d>>5 " degrees C"

I have not tested this but it should work.Edited by Geoffg 2017-06-09
Geoff Graham - http://geoffg.net
 
Zonker

Guru

Joined: 18/08/2012
Location: United States
Posts: 761
Posted: 04:32pm 07 Jun 2017
Copy link to clipboard 
Print this post

Hey Phil...

I use 2 of the MAX31855 IC's in the "round gauge" projects and seems to work well..

Here is the read "snippet" of code... Its taken from the whole main program, so you will need to do the pin init stuff for your hardware..


' the init stuff..

Pin(42)=1 ' set IC4 CS pin high - (deselected)
SetPin 42,dout ' CS pin for IC4 MAX31855 thermocouple chip
SPI open 10000,1,32 ' 10k bits speed, data on falling edge, 32bit transfer

' from somewhere inside the main loop..

read_IC4
If Not temp2_error Then
temp2_avarge=temp2_avarge*0.9
temp2_avarge=temp2_avarge+temp2_F/10
Print Cint(temp2_avarge);
Print temp2_avarge;
Print temp2_C
g2_val=Cint(temp2_avarge)+gauge2_offset
EndIf

' later on in the "subs" section..

Sub read_IC4
Pin(42)=0 ' set IC4 CS pin low - (selected)
temp2_data=SPI(0)
Pin(42)=1 ' set IC4 CS pin high - (deselected)
temp2_error=temp2_data And &B111 ' mask for error codes (bit D3 Reserved =0)
If temp2_error Then
Select Case temp2_error
Case 1 ' probe open
If Not IC4_err_onscreen Then
Text 110,150," ",cm,3,1,RGB(black)
Text 110,140,"Sensor",cm,2,1,RGB(yellow),RGB(red) ' error msg
Text 110,160,"Open",cm,2,1,RGB(yellow),RGB(red) ' error msg
EndIf
Case 2 ' probe gronded
If Not IC4_err_onscreen Then
Text 110,150," ",cm,3,1,RGB(black)
Text 110,140,"Sensor",cm,2,1,RGB(yellow),RGB(red) ' error msg
Text 110,150,"Ground",cm,2,1,RGB(yellow),RGB(red) ' error msg
EndIf
Case 4 ' probe on VCC
If Not IC4_err_onscreen Then
Text 110,150," ",cm,3,1,RGB(black)
Text 110,140,"Sensor",cm,2,1,RGB(yellow),RGB(red) ' error msg
Text 110,1600,"Supply",cm,2,1,RGB(yellow),RGB(red) ' error msg
EndIf
Case Else ' IC is not connected
If Not IC4_err_onscreen Then
Text 110,150," ",cm,3,1,RGB(black)
Text 110,140,"IC Not",cm,2,1,RGB(yellow),RGB(red) ' error msg
Text 110,160,"Found",cm,2,1,RGB(yellow),RGB(red) ' error msg
EndIf
IC4_err_onscreen=1 ' store err msg state
End Select
Else
temp2_internal=temp2_data>>4 And &B111111111111 ' mask for DIE temp (no fault bit)
temp2_ex_quarters=temp2_data>>18 And &B11 ' mask for .25 of degree (D17 Reserved=0)
temp2_ex_quarters=temp2_ex_quarters*.25
temp2_external=temp2_data>>20
temp2_external=temp2_external+temp2_ex_quarters
temp2_C=temp2_external
temp2_F=temp2_C*9/5+32
IC4_err_onscreen=0 ' store err msg state
EndIf
End Sub


I take in the data as 32 bit all at once and then do the shifting to "cut it up"
into the different parts... I also check the internal DIE temp and error bits...
Hope this helps..!
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3167
Posted: 10:09pm 07 Jun 2017
Copy link to clipboard 
Print this post

Zonker, why read 32 bits? As far as I can see the MAX6675 provides 16 bits of data.

EDIT: It might be because Phil's module is using a MAX6675 while you were using a MAX31855 ????

MORE EDIT: On rereading the MAX6675 data sheet, I believe that the SPI open should be:
SPI OPEN 100000, 2, 16 ' speed is 100KHz, data size is 16 bits

ie, sample on the falling clock edge

GeoffEdited by Geoffg 2017-06-09
Geoff Graham - http://geoffg.net
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 10:50pm 07 Jun 2017
Copy link to clipboard 
Print this post

Thanks Geoff,

Will give it a try later....
About to enjoy a beer after the hair tearing.

Interesting, I did look at both the MAX6675 & MAX31855, not sure what lead to the final decision, they were ordered 2 weeks back.

Phil.

 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024