MAX6675

Mark.R

Member
Morning all, below is the code I use in a little temp measure project and have a question.

Code:
; Picaxe 08M2 to Max6675 thermocouple

Symbol CS = C.2           ' connect pin6 to pin 6 MAX6675
Symbol SCK = C.1          ' connect pin4 to pin 5 MAX6675
Symbol MISO = PinC.3         ' connect pin5  to pin 7 MAX6675
Symbol CONF = C.4            ' output pin for flame confirmed
Symbol Val = W1
Symbol I = B1

' Directives

#COM 31                'specify serial port
#picaxe 08M2            'specify procesor
#no_data                'reduces download time
#terminal 4800            'specify terminal baud rate


init:
    pause 2000
    High CONF

Main:
GoSub MeasTemp
GoSub DisplayTemp
GoSub ControlOut


Pause 500        ' allow Max6675 to finish

Goto Main

MeasTemp:
High CS        ' deselect the 6675
Low SCK
Low CS            ' start conversion
Val = 0        ' initialize temperature variable
For I = 1 to 16    ' serial clock in 16 bits
High SCK
Val = Val * 2 + MISO 'clock in the bits into a word
Low SCK
Next I
High CS        ' deselect the 6675
Val = Val / 32    ' use only the 11 most sig bits (val = deg Celsius)

    Return


DisplayTemp:
    sertxd("Temp=",#val,"  ",13,10)        'display text

Return


ControlOut:
    if val <= 120 then LockOut            'flame not confirmed
    if val >= 130 then Confirmed           'flame confirmed

    Return


LockOut:
    sertxd("Lock_Out"," ",13,10)        'display text
    Pause 100                   'wait for period
    High CONF                          'turn on output
    Pause 100                   'wait for period

    Return

Confirmed:
    sertxd("Flame_Confirmed", " ",13,10)    'display text
    Pause 100                       'wait for period
    Low CONF                             'turn off output
    Pause 100                       'wait for period

    Return

The data sheet on the internet talks about bit D2 from the MAX6675 is used to detect if the thermocouple has gone Open as at the moment all my code does is return its max temp of 1024. I could do with monitoring this bit as well as the temp as I already have but can't work out how to go about it. Any help appreciated.
 

hippy

Technical Support
Staff member
The MAX6675 returns a single 16-bit value which includes the D2 bit. So before you do your 'val = val / 32' to get a temperature you need something which extracts the D2 from that. Change -
Code:
High CS        ' deselect the 6675
Val = Val / 32    ' use only the 11 most sig bits (val = deg Celsius)
to -
Rich (BB code):
High CS        ' deselect the 6675
valid = val / 4 & 1 ^ 1
Val = Val / 32    ' use only the 11 most sig bits (val = deg Celsius)
Your 'valid' variable will be 1 when the probe is not open, that is when D2 is low, will be 0 when it is open / not connected.
 

Mark.R

Member
Hi Hippy, thanks again for you support. I've written that into the code with a few other bits to use it and it complies ok so that's halfway there. Shame I don't really understand from what you've written how it works but I'm sure it will do.
 

hippy

Technical Support
Staff member
Code:
                                Probe connected    Disconnected

Your initial 'val' reading is : -tttttttttttt0--   -tttttttttttt1--

Dividing by 4                 : ---tttttttttttt0   ---tttttttttttt1

Anding with 1                 : ---------------0   ---------------1

Exclusive oring with 1        : ---------------1   ---------------0
 

Mark.R

Member
So its all about getting the bit you want to look at into the correct place, in this instance over to right (dividing by 4) and then does the add 1 or Adding with 1 if different get rid of what you don't want? The Exclusive ORing with 1 looks to invert the final result.
Any of that right or am I miles off?
 

Mark.R

Member
Well that's a start, now I just need to get to a point that when I look at a data sheet knowing what combinations of dividing and Anding ect is needed.
 

hippy

Technical Support
Staff member
Well that's a start
It seems you are well on your way already. Your 'val=val/32' does that bit-shifting to align the integer temperature as you desire, it doesn't need any anding because it is usable as it is after the shift -
Code:
Your initial 'val' reading is : -ttttttttttffv--  t=temp, f=fractional

Dividing by 32                : ------tttttttttt
The /32 throws away bits D4 down to D0. If you wanted to keep the fractional temperature part, D4 and D3, you could divide by 8 then and with 3, binary %11 -
Code:
Your initial 'val' reading is : -ttttttttttffv--  t=temp, f=fractional

Dividing by 8                 : ----ttttttttttff

Anding with 3                 ; --------------ff
Then you could have -
Code:
High CS        ' deselect the 6675
valid = val / 4 & 1 ^ 1
fractional = val / 8 & 3
Val = Val / 32    ' use only the 11 most sig bits (val = deg Celsius)

Select Case fractional 
  Case %00 : SerTxd( "Temp = ", #val, ".0"  ) ; 0
  Case %01 : SerTxd( "Temp = ", #val, ".25" ) ; 1
  Case %10 : SerTxd( "Temp = ", #val, ".5"  ) ; 2
  Case %11 : SerTxd( "Temp = ", #val, ".75" ) ; 3
End Select
As always, the more you do, the easier it becomes in figuring out how to do things, even with things you have never seen before..
 

Mark.R

Member
I didn't know you could do the decimal point part of the temp reading even if it just in quarter jumps.

How do you get it to select the individual Case% from the fractional=
 

Mark.R

Member
So far with I've been using one of these MAX6675 modules on an an 08M2 with I believe bit banging to get the data from it and into the 08, if I went to an X2 part could it be done with less code using the hspiin/out??
 

Mark.R

Member
Evening all, any of you able to tell me why this code will happily run on a 14M2 but when put on a 18M2 or a 20X2 all I get is junk on the serial out to the terminal monitor, I go back to the 14M2 and I get the correct "Temp=VAL". It's really starting to bug me now.

Code:
; Picaxe 20X2 to Max6675 thermocouple

Symbol CS = B.3       
Symbol SCK = B.2       
Symbol MISO = PinB.1   
Symbol Val = w1
Symbol I = b1

#picaxe 20X2
#no_data
#terminal 4800

      
Main:

     GoSub MeasTemp
     GoSub DisplayTemp
     Pause 1000        ' allow Max6675 to finish
     Goto Main

MeasTemp:
     High CS        ' deselect the 6675
     Low SCK
     Low CS            ' start conversion
     Val = 0        ' initialize temperature variable
     For I = 1 to 16    ' serial clock in 16 bits
        High SCK
        Val = Val * 2 + MISO 'clock in the bits into a word
        Low SCK
     Next I
     High CS        ' deselect the 6675
     Val = Val / 32    ' use only the 11 most sig bits (val = deg Celsius)
 
    Return
   
   
DisplayTemp:
    sertxd("Temp=",#w1,"  ")
    
     Return
EDIT: I've just tried it again and it'll work on the 18M2 but not on the 20X2.
 

AllyCat

Senior Member
Hi,

The X2s have a default clock frequency of 8 MHz, so you may need a #TERMINAL 9600. I must admit I'm often "confused" (since I don't use X2s) when the "default" (8 MHz) frequency of the X2 is compatible with the M2's (4 MHz), and when it isn't.

Cheers, Alan.
 

inglewoodpete

Senior Member
Hi,

The X2s have a default clock frequency of 8 MHz, so you may need a #TERMINAL 9600. I must admit I'm often "confused" (since I don't use X2s) when the "default" (8 MHz) frequency of the X2 is compatible with the M2's (4 MHz), and when it isn't.

Cheers, Alan.
SerTxd is bit-banged and was never "upgraded" to run slower on the 8MHz X2s. Users will usually want the fastest data logging rate possible. (Unfortunately, at the cost of compatibility)
 

Mark.R

Member
so what your both saying is the program is running on the X2 chip properly its just the SerTxd back to the terminal monitor that isn't working right, I can live with that but spent hours last night pulling things apart to work it out. Thank you.

Also is this code below the best way of reading three MAX6675's or is there a more elegant way of doing it?

Code:
; Picaxe 18M2 to 3x Max6675 thermocouple

Symbol CS3 = B.4
Symbol CS2 = B.3
Symbol CS1 = B.2        
Symbol SCK = B.1        
Symbol MISO = PinB.0    
Symbol Val1 = w1
symbol Val2 = w2
symbol Val3 = w3
Symbol I = b1
symbol COMMA = ","

#picaxe 18M2
#no_data
#terminal 4800

       
Main:

         GoSub MeasTemp1
   Pause 1000
    GoSub MeasTemp2
   Pause 1000 
    GoSub MeasTemp3
   Pause 1000
     GoSub DisplayTemp
   Pause 1000         ' allow Max6675 to finish
     Goto Main

MeasTemp1:
     High CS1        ' deselect the 6675
     Low SCK
     Low CS1            ' start conversion
     Val1 = 0        ' initialize temperature variable
     For I = 1 to 16    ' serial clock in 16 bits
        High SCK
        Val1 = Val1 * 2 + MISO 'clock in the bits into a word
        Low SCK
     Next I
     High CS1        ' deselect the 6675
     Val1 = Val1 / 32    ' use only the 11 most sig bits (val = deg Celsius)
  
Return

MeasTemp2:
     High CS2        ' deselect the 6675
     Low SCK
     Low CS2        ' start conversion
     Val2 = 0        ' initialize temperature variable
     For I = 1 to 16    ' serial clock in 16 bits
        High SCK
        Val2 = Val2 * 2 + MISO 'clock in the bits into a word
        Low SCK
     Next I
     High CS2        ' deselect the 6675
     Val2 = Val2 / 32    ' use only the 11 most sig bits (val = deg Celsius)
    
Return
    
MeasTemp3:
     High CS3        ' deselect the 6675
     Low SCK
     Low CS3        ' start conversion
     Val3 = 0        ' initialize temperature variable
     For I = 1 to 16    ' serial clock in 16 bits
        High SCK
        Val3 = Val3 * 2 + MISO 'clock in the bits into a word
        Low SCK
     Next I
     High CS3        ' deselect the 6675
     Val3 = Val3 / 32    ' use only the 11 most sig bits (val = deg Celsius)
    
Return

DisplayTemp:
    
    sertxd ( "Temp1=", #w1, COMMA,"Temp2=", #w2, COMMA,"Temp3=", #w3, CR, LF )
     
Return
 

inglewoodpete

Senior Member
so what your both saying is the program is running on the X2 chip properly its just the SerTxd back to the terminal monitor that isn't working right, I can live with that but spent hours last night pulling things apart to work it out. Thank you.
No, not the case. SerTxd is working correctly. When is doubt, always read the Manual> Command Descriptions> SerTxd
 

AllyCat

Senior Member
Hi,

It's "working right", you just have to select the correct baud rate for the X2 chip! "Garbage" serial communications are nearly always due to an incorrect baud rate or polarity. Inverted RS232 data does need a different Terminal Emulator to that in PE6 (or use hardware inverters), but it's nearly always worth trying the alternative baud rates (far quicker than having to ask the question). ;)

For three sensors, hippy would probably use a MACRO, but there's not much wrong in cut/pasting and editing three versions (which is basically what a Macro does) in a small program like this. But personally, I'd probably use a two-level subroutine, for example (just the basic differences shown, untested) :
Code:
Symbol TempB = b1       ; Temporary / Local byte variable (e.g. to  use within subroutines)
Symbol TempW = w1      ; Temporary / Local word variable  (e.g. to pass parameters to/from subroutines)
Symbol Val1 = w11
symbol Val2 = w12
symbol Val3 = w13
    
Main:
    GoSub MeasTemp1
    GoSub MeasTemp2
    GoSub MeasTemp3
    GoSub DisplayTemp
   Pause 1000             ' allow Max6675 to finish (?)
   Goto Main

MeasTemp1:
     High CS1              ' deselect the 6675   (?)
     Low SCK               ' (?)
     Low CS1               ; start conversion
     Gosub MeasTemp
     High CS1              ; deselect the 6675
     Val1 = TempW
Return
; MeasTemp2 ...... etc.
;
MeasTemp:
     TempW = 0        ' initialize temperature variable
     For TempB = 1 to 16    ' serial clock in 16 bits
        High SCK
        TempW = TempW * 2 + MISO    ; clock in the bits into a word
        Low SCK
     Next TempB
     TempW = TempW / 32       ; use only the 11 most sig bits (val = deg Celsius)
     Pause 1000
Return
DisplayTemp:  
    sertxd ( "Temp1=", #Val1, COMMA,"Temp2=", #Val2, COMMA,"Temp3=", #val3, CR, LF )   
Return
I'm not sure if the three lines with Question marks (?) are needed (or the comment might be wrong). Maybe move the first "High CSx" and "Low SCK" lines into an "Init:" section/routine.

Cheers, Alan.
 
Last edited:

Mark.R

Member
Morning all, me again.

Below is my code for my wood burner monitor to date, put together with shared code from around the forum and this thread. I've got to the point now where the startup display works and then it reads the temperatures from the three MAX6675's and then displays them on the first three lines of the OELD display. The bit I'm having trouble with and tried different things last night is the Thermocouple open circuit detection that would then display the relevant "failed" text in line 4, all the program/display does is cycle through all four EEPROM messages from 160 to 220. Any ideas??

Just to note the are bits in the Symbols and Keys that aren't yet used, they're for the next bit when this problem is sorted, also I'd moved from the 18M2 to the 20X2 which I had due to running out of "W's" would there have been another way of getting around this?

Code:
;Wood Burner Temperature Monitor V3.0


    ;VARIABLES KEY
;b0  = ASCII of W14 (TensThousands)
;b1  = ASCII of W14 (Thousands)
;b2  = ASCII of w14 (Hundreds)
;b3  = ASCII of w14 (Tens)
;b4  = ASCII of w14 (Units)
;b5  = "-" or "+"
;b6  = Warning on LINE 4
;b7  = Line start address
;b8  = 
;b9  = Read from sensors
;b10 = Read eeprom address
;b11 = Read eeprom data
;b12 = EEPROM start address of message
;b13 = Length of message to send
;w8  = MAX6675 No.1 Value (Flue Temp)
;w9  = MAX6675 No.2 Value (Water Flow Temp)
;w10 = MAX6675 No.3 Value (Water Return Temp)
;w11 = MAX6675 No.1 Sensor health 
;w12 = MAX6675 No.2 Sensor health
;w13 = MAX6675 No.3 Sensor health

#picaxe 20X2

Symbol OLED        = B.0
Symbol COM_TX    = C.0
Symbol CS_1        = B.1
Symbol CS_2        = B.2
Symbol CS_3        = B.3
Symbol SCK        = B.4
Symbol MISO        = pinB.5
Symbol I        = b9
Symbol VAL_1    = w8
Symbol VAL_2    = w9
Symbol VAL_3    = w10
Symbol SH_1        = w11
Symbol SH_2        = w12
Symbol SH_3        = w13
symbol BAUD        = N2400


EEPROM  00, ("    Wood Burner     ")     ; store msg 0 in the EEPROM memory
EEPROM  20, ("Temperature Monitor ")     ; store msg 1 in the EEPROM memory
EEPROM  40, ("  xxxxxxxxxxxxxxx   ")     ; store msg 2 in the EEPROM memory
EEPROM  60, ("   xxxxxxxxxxxxxx   ")     ; store msg 3 in the EEPROM memory
EEPROM  80, ("   Flue Temp ")         ; store msg 4 in the EEPROM memory
EEPROM 100, ("   Flow Temp ")         ; store msg 5 in the EEPROM memory
EEPROM 120, (" Return Temp ")         ; store msg 6 in the EEPROM memory
EEPROM 140, (" -WATER TEMP HIGH-  ")     ; store msg 7 in the EEPROM memory
EEPROM 160, ("-FLUE SENSOR FAILED-")    ; store msg 8 in the EEPROM memory
EEPROM 180, ("-FlOW SENSOR FAILED-")     ; store msg 9 in the EEPROM memory
EEPROM 200, ("*RETURN SENS FAILED*")     ; store msg 10 in the EEPROM memory
EEPROM 220, ("....................")     ; store msg 11 in the EEPROM memory

Init:
Pause 200  
  High CS_1
  High CS_2
  High CS_3
  Low  SCK
Pause 200
  Low OLED                ;Initialise OLED output 
Pause 500                 ;Waif for OLED to initialise
  serout OLED,BAUD,(254,1)    ;Clear OELD Display 
Pause 500

Start_Up:        ;Startup Message
    
 b7=128        ;Line 1
 b12=00         ;EEPROM 00
 b13=20        ;Length of message
 gosub msg 
 
 b7=192        ;Line 2
 b12=20        ;EEPROM 20
 b13=20        ;Length of massage
 gosub msg
 
 b7=148        ;Line 3
 b12=40        ;EEPROM 40
 b13=20        ;Lenght of message
 gosub msg
     
 b7=212        ;Line 4
 b12=60        ;EEPROM 60
 b13=20        ;Lenght of message
 gosub msg    
 
 Pause 3000
    
serout OLED,baud,(254,1)
pause 30    
 
Read_Sensors:
 
MeasTemp1:
     
     Low SCK
     Low CS_1                ;start conversion
     VAL_1 = 0                ;initialize temperature variable
     For I = 1 to 16            ;serial clock in 16 bits
        High SCK
        VAL_1 = VAL_1 * 2 + MISO    ;clock in the bits into a word
        Low SCK
     Next I
     High CS_1                ;deselect the 6675
     SH_1 = VAL_1 / 4 & 1 ^ 1        ;Check sensor 1 health
     VAL_1 = VAL_1 / 32            ;use only the 11 most sig bits (val = deg Celsius)

MeasTemp2:
     
     Low SCK
     Low CS_2                ;start conversion
     VAL_2 = 0                ;initialize temperature variable
     For I = 1 to 16            ;serial clock in 16 bits
        High SCK
        VAL_2 = VAL_2 * 2 + MISO    ;clock in the bits into a word
        Low SCK
     Next I
     High CS_2                ;deselect the 6675
     SH_2 = VAL_2 / 4 & 1 ^ 1        ;Check sensor 2 health
     VAL_2 = VAL_2 / 32            ;use only the 11 most sig bits (val = deg Celsius)
    
MeasTemp3:
     
     Low SCK
     Low CS_3                ;start conversion
     VAL_3 = 0                ;initialize temperature variable
     For I = 1 to 16            ;serial clock in 16 bits
        High SCK
        VAL_3 = VAL_3 * 2 + MISO    ;clock in the bits into a word
        Low SCK
     Next I
     High CS_3                ;deselect the 6675
     SH_3 = VAL_3 / 4 & 1 ^ 1        ;Check sensor 3 health
     VAL_3 = VAL_3 / 32            ;use only the 11 most sig bits (val = deg Celsius)

Display_MSG:
 b6=220        ;Clear warning message
 
 w14 = VAL_1    ;Move sensor 1 into w14
 b7=128        ;Line 1
 b12=80         ;EEPROM 00
 b13=12        ;Length of message
 gosub Display_OLED
 
 w14 = VAL_2    ;Move sensor 2 into w14
 b7=192        ;Line 2
 b12=100        ;EEPROM 20
 b13=12        ;Length of massage
 gosub Display_OLED
 
 w14 = VAL_3    ;Move sensor 3 into w14
 b7=148        ;Line 3
 b12=120        ;EEPROM 40
 b13=12        ;Lenght of message
 gosub Display_OLED
 
Sensor_Health:

    if SH_1 = 0 then let b6 = 160 else b6 = 220 endif
  Pause 500    
    if SH_2 = 0 then let b6 = 180 else b6 = 220 endif
  Pause 500    
    if SH_3 = 0 then let b6 = 200 else b6 = 220 endif 
  Pause 500

 b7=212        ;Line 4
 b12=b6         ;Message
 b13=20        ;Length of Message
 gosub msg    
    
    
goto Read_Sensors     
    
Display_OLED:
 
 if w14>127 then let b5="-" let w14=w14-127:else:b5="+":endif    ;Select + or - sign
 
 bintoascii w14, b0,b1,b2,b3,b4    ;Convert temperature to 5 ascii digits
 
 
 if b0=48 then let b0=32:end if  ;Blank leading zeros
 if b0>48 then skip
 if b1=48 then let b1=32:end if  ;Blank leading zeros
 if b1>48 then skip
 if b2=48 then let b2=32:end if
skip:

gosub msg 

 serout OLED, BAUD, (b5,b0,b1,b2,b3,b4,"C")    ;Line data
 
return    
    
    
 ;Read EEPROM messages and send to OLED

msg:

       serout OLED, BAUD, (254,b7)    ;Line select 
       b13=b13+b12
       for b10 = b12 to b13             ;Start a loop
      read b10,b11            ;Read value from EEPROM
      serout OLED,BAUD,(b11)    ;Transmit to serial LCD module
    next b10                ;Next character
return
 

AllyCat

Senior Member
Hi,

How have you planned to test for a thermocouple failue? I can't see how you're testing for the "failure" message to be shown (when appropriate). The code appears to always either jump or fall through to "skip" and that then calls "msg" without any additional show/noshow test.

The M2s have 512 bytes of RAM, so you really shouldn't "run out" of variables, but we can discuss methods when/if other avenues are exhausted. First, you are using w14 >127 to test for a negative (two's complement), but that applies to single byte numbers (a negative word would normally be >32767). Also there are the 6 (unused) System Words (S_W1 to S_W6) which can be used in M2s , but not X2s (because that system uses them).

Cheers, Alan.
 

Mark.R

Member
Hi Alan,

This is explained by Hippy after I asked the question at the top of this (pg2) of this thread, I'd read in the data sheet for the MAX6675 that bit D2 is used to send out that an open sensor had been detected and that's what...

Code:
SH_2 = VAL_2 / 4 & 1 ^ 1        ;Check sensor 2 health
this does, it extracts it from the clocked in data, a not open sensor returns a 1 a failed one returns a 0.

So for example I would have thought that this bit of the code

Code:
if SH_1 = 0 then let b6 = 160 else b6 = 220 endif
for sensor 1 would put the failed message for sensor 1 in EEPROM location 160 into b6 which would then be sent to the display by the next part of the code else it would ether move on or in this trial put EEPROM 220 in which is the clear ................. dots

w14 is used for taking the values through to the part of the code that eventually gets sent to the OLED display, as for this bit and what is used to work out the +/- for and sending data to the display it was lifted straight from this post and I just changed added bits.

Sadly I cant find that thread or project right now but I remember it was for monitoring the temperatures of a pond, if I find it ill add it.


Found it:

 
Last edited:

AllyCat

Senior Member
Hi

Ah, well first, you're using words (w11 to w13) to represent a simple binary (Yes / No) value, which could be stored in a byte, or even better a "flag" (bit) value (for clarity). It should still "work", but it's one of the reasons you've already "run out" of variables. IMHO you've also made the "classic" mistake of using the "low" variables b0, etc. for the first (possibly trivial) part of the program that you wrote. b0 to b3 are particularly "valuable" because they contain 32 flags and personally I (nearly always) reserve b0 for (up to 8) global flags, and b1 to b3 (or b1 and w1) for "important" funtions (e.g. passing values to, and using within, subroutines).

Also, you have some Symbol declarations, but there's a horrible "Tangle" of code using b6 - b13 and I can't see why you set up a value in b6 and then immediately copy it to b12 ? You're also using labels (ending in a colon) effectively as "comments"; it's helpful to be "naming" each section of code, but confusing to anone reading the code to see which are subroutines or a "target" of the GOTO, disliked by many purists. So, they're my "excuses" for not seeing what is happening, and on the face of it I now can't see what is "wrong", except that the line : if SH_1 = 0 then let b6 = 160 else b6 = 220 endif etc., is not strictlly "valid" syntax. It's best written as:
Code:
  if SH_1 = 0 then 
     {let} b6 = 160     ; Pointer to fault string "....." (comment optional)
  else 
      b6 = 220        ; Pointer to ok string "......."
  endif
The curly braces {} around the LET indicates that it is "optional", but each "New-Line" in the above should be represented by a colon ( : ) if writing it on a single line. However, the Program Editor tries to be "helpful" by recognising that a LET probably indicates a New-Line and that the colon has been "forgotten" , IMHO a "bad" idea because it "encourages" users to write poor syntax. In this case you have "forgotten" both the colon and the LET after the ELSE; I don't know if that's the problem but it might be. To put it on one line you could try: if SH_1 = 0 then : b6 = 160 : else : b6 = 220 : endif ( or could the b6 be b12 , or I probably would be using b1 , or a symbol such as tempb (temporary variable) or index or pointer , etc.

Cheers, Alan.
 

Mark.R

Member
Hi Alan,

Thank you for your pointers and your comments. Apologies for the colon ending labels that look like comments at the beginning of sections that don't need it, this is a throwback from a previous design/layout of the code and should have been tidied up. When I can I will get back on it later today after reading your comments again and see how I get on.

Thanks, Mark
 

Mark.R

Member
The curly braces {} around the LET indicates that it is "optional", but each "New-Line" in the above should be represented by a colon ( : ) if writing it on a single line. However, the Program Editor tries to be "helpful" by recognising that a LET probably indicates a New-Line and that the colon has been "forgotten" , IMHO a "bad" idea because it "encourages" users to write poor syntax. In this case you have "forgotten" both the colon and the LET after the ELSE; I don't know if that's the problem but it might be. To put it on one line you could try: if SH_1 = 0 then : b6 = 160 : else : b6 = 220 : endif ( or could the b6 be b12 , or I probably would be using b1 , or a symbol such as tempb (temporary variable) or index or pointer , etc.
I've done this and now get a syntax error shown in the attached screen shot?
pic1.jpg

update: I've taken the { } out and its compiled, still doesn't work right but I'll keep at it.
 
Last edited:

Mark.R

Member
I've just been looking through the data sheet and in order for the open sensor monitor to work on D2 then the T- must be connected to ground, so on the MAX6675 thats connecting pins 1&2 together on the chip, the three new boards I've had do not have this connection (A previous and different one I have dose) and having made a temporary connection things are now better and even the temp reading is better as anything up to 124C was good but anything over 125 on the OLED display was rubbish.

Just thought I'd say in case some else has the same issue with the "Thermocouple open" monitor.


Update: I didn't want to delete this post as it goes to prove that you can easily be caught out if you don't pay full attention so just editing it. I recently bought off ebay and yes from china 3 small boards with MAX6675 chips on and have been having nothing but trouble with them miss reading and the like, turns out they are actually MAX31855's which have totally different measuring ranges and has a 32bit output value and not the 16bit of the MAX6675. I will see if I can change the code to read this or buy the right units.
 
Last edited:

AllyCat

Senior Member
Hi,

I've "translated" (or rather Google has) the French link in that thread, but I would expect reduction of 32 bits to 16 bits data should be quite easy. The resolution of the sensor won't be any better than that), but I have submitted various "32-bit" calculation routines in the "Code Snippets" section of the forum, should they be needed.

Cheers, Alan.
 

PieM

Senior Member
Hi,
For the MAX31855 , no need for 32 bits calculation. bit (0-15) are for internal temperature (cold junction) and bit 16 - 31 for thermocouple temperature and fault bit.

24190
Cheers
 

Mark.R

Member
Thanks guys I had fond the same post (the one in French) but hadn't had the chance to do anything with it yet.

Cheers
 
Top