Still problems max31855

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Post Reply
User avatar
Crimson0087
 
Posts: 24
Joined: Thu Jul 28, 2022 1:52 pm

Still problems max31855

Post by Crimson0087 »

I know this things supposed to be sensitive but I opened up my setup and secured EVERY wire. and I ran code to check temp of basically the air every 3 seconds and after less than a minute it says either "thermocouple not connected" or "short circuit to ground" BUT NOTHING HAS CHANGED physically. Nothing is disconnected. Nothing is shorted to ground....is there something wrong with the actual thermocouple? Something wrong with the max31855 chip?

User avatar
Crimson0087
 
Posts: 24
Joined: Thu Jul 28, 2022 1:52 pm

Re: Still problems max31855

Post by Crimson0087 »

I have noticed that is occurs when there is ANY sort of movement of the thermocouple....it seems movement at the end where the temp is sensed is throwing the error....

User avatar
adafruit_support_carter
 
Posts: 24414
Joined: Tue Nov 29, 2016 2:45 pm

Re: Still problems max31855

Post by adafruit_support_carter »

Please post a photo of your setup showing how everything is connected.

User avatar
Crimson0087
 
Posts: 24
Joined: Thu Jul 28, 2022 1:52 pm

Re: Still problems max31855

Post by Crimson0087 »

Heres the image. Everything secure and it still craps out....


[img]


[/img]

User avatar
adafruit_support_bill
 
Posts: 84669
Joined: Sat Feb 07, 2009 10:11 am

Re: Still problems max31855

Post by adafruit_support_bill »

Your photos are not showing up. To post photos, use the "choose file" and "add the file" buttons below the edit window. There is a size limit. 800x600 images generally work best.

.it seems movement at the end where the temp is sensed is throwing the error..
What are you measuring and what type of movement is triggering the error?

User avatar
Crimson0087
 
Posts: 24
Joined: Thu Jul 28, 2022 1:52 pm

Re: Still problems max31855

Post by Crimson0087 »

I am using it for a violin rib bending iron. The thermocouple is housed inside a metal pipe that is stuffed with aluminum foil. The thermocouple should not be moving much inside the pipe but I am always moving around the pipe itself a little. But sitting here running my program that is just getting a temp every 3 seconds with nothing touching anythying it will run for a few minutes then throw the error. I setup my code to bypass the error and keep going but id still like to figure this out...Im working on pictures. Also when i calibrate it by putting it in boiling water the water instantly throws the code. Im working on pictures

User avatar
Crimson0087
 
Posts: 24
Joined: Thu Jul 28, 2022 1:52 pm

Re: Still problems max31855

Post by Crimson0087 »

Heres pic
Attachments
box smnall.jpg
box smnall.jpg (117.33 KiB) Viewed 62 times

User avatar
Crimson0087
 
Posts: 24
Joined: Thu Jul 28, 2022 1:52 pm

Re: Still problems max31855

Post by Crimson0087 »

This is how im calibrating...This throws lots of errors namely"

"thermocouple not connected"
Attachments
boil small.jpg
boil small.jpg (59.77 KiB) Viewed 62 times

User avatar
Crimson0087
 
Posts: 24
Joined: Thu Jul 28, 2022 1:52 pm

Re: Still problems max31855

Post by Crimson0087 »

Here is the code

Code: Select all

from machine import SPI, Pin
import utime    
import ustruct
import math

class MAX31855:
    """
    Driver for the MAX31855 thermocouple amplifier.
    MicroPython example::
        import max31855
        from machine import SPI, Pin
        spi = SPI(1, baudrate=1000000)
        cs = Pin(15, Pin.OUT)
        s = max31855.MAX31855(spi, cs)
        print(s.read())
    """
    def __init__(self, spi, cs):
        self.spi = spi
        self.cs = cs
        self.data = bytearray(4)

    def read(self, internal=False, raw=False):
        """
        Read the measured temperature.
        If ``internal`` is ``True``, return a tuple with the measured
        temperature first and the internal reference temperature second.
        If ``raw`` is ``True``, return the values as 14- and 12- bit integers,
        otherwise convert them to Celsuius degrees and return as floating point
        numbers.
        """

        self.cs.low()
        try:
            self.spi.readinto(self.data)
        finally:
            self.cs.high()
        # The data has this format:
        # 00 --> OC fault
        # 01 --> SCG fault
        # 02 --> SCV fault
        # 03 --> reserved
        # 04 -. --> LSB
        # 05  |
        # 06  |
        # 07  |
        #      > reference
        # 08  |
        # 09  |
        # 10  |
        # 11  |
        # 12  |
        # 13  |
        # 14  | --> MSB
        # 15 -' --> sign
        #
        # 16 --> fault
        # 17 --> reserved
        # 18 -.  --> LSB
        # 19   |
        # 20   |
        # 21   |
        # 22   |
        # 23   |
        #       > temp
        # 24   |
        # 25   |
        # 26   |
        # 27   |
        # 28   |
        # 29   |
        # 30   | --> MSB
        # 31  -' --> sign
        if self.data[3] & 0x01:
            power_led.low()
            controller.low()
            raise RuntimeError("thermocouple not connected")
        if self.data[3] & 0x02:
            power_led.low()
            controller.low()
            raise RuntimeError("short circuit to ground")
        if self.data[3] & 0x04:
            power_led.low()
            controller.low()
            raise RuntimeError("short circuit to power")
        if self.data[1] & 0x01:
            power_led.low()
            controller.low()
            raise RuntimeError("faulty reading")
        
        temp, refer = ustruct.unpack('>hh', self.data)
        refer >>= 4
        temp >>= 2
        if raw:
            if internal:
                return temp, refer
            return temp
        if internal:
            return temp / 4, refer * 0.0625
        return temp / 4       
        
        
spi = machine.SPI(0, baudrate=80_000_000, polarity=0, phase=0, bits=8, sck=Pin(6), mosi=Pin(7), miso=Pin(4))
cs = Pin(5, Pin.OUT)
s =MAX31855(spi, cs)


#Variables for pin numbers
relay=22
powerLed=0
tempLed=1
maxtemp=145
mintemp=135
#Initialize pins

controller=machine.Pin(relay,machine.Pin.OUT)
power_led=machine.Pin(powerLed,machine.Pin.OUT)

temp_led=machine.Pin(tempLed,machine.Pin.OUT)

def blink_led():
    power_led.high()
    utime.sleep(.5)
    power_led.low()
    utime.sleep(.5)
    power_led.high()
    utime.sleep(.5)
    power_led.low()
    utime.sleep(.5)
    power_led.high()
    utime.sleep(.5)
    power_led.low()
    utime.sleep(.5)
    power_led.high()
    utime.sleep(.5)
    power_led.low()
    utime.sleep(.5)
    power_led.high()

power_led.high()
temp_led.low()
controller.low()
print(s.read())




# controller.high()= off
#controller.low()=on
while True:
    
    try:
        current_temp=s.read()
        corrected_temp=((((current_temp-0) * 98.88) / 50) + 0)
        print(corrected_temp)
    except Exception as e:
        print('error occurred: ', e)
        s=MAX31855(spi,cs)
        controller.low()
        blink_led()
    if current_temp>45:
        temp_led.high()
    else:
        temp_led.low()
    if current_temp<mintemp:
        controller.high()
    elif current_temp>maxtemp:
        controller.low()
    utime.sleep(3)

and my output

98.3856
error occurred: thermocouple not connected
error occurred: thermocouple not connected
error occurred: short circuit to ground
error occurred: thermocouple not connected
99.8688
98.3856
38.0688

User avatar
adafruit_support_bill
 
Posts: 84669
Joined: Sat Feb 07, 2009 10:11 am

Re: Still problems max31855

Post by adafruit_support_bill »

An induction cooktop is an extremely effective source of EMI. It will induce currents in nearby unshielded wiring as well as in the cooking vessel. I'd choose a different heat source for testing.

User avatar
Crimson0087
 
Posts: 24
Joined: Thu Jul 28, 2022 1:52 pm

Re: Still problems max31855

Post by Crimson0087 »

Ok!

User avatar
Crimson0087
 
Posts: 24
Joined: Thu Jul 28, 2022 1:52 pm

Re: Still problems max31855

Post by Crimson0087 »

Could this cartridge heater be introducing EMI?
Attachments
cart.jpg
cart.jpg (10.52 KiB) Viewed 59 times

User avatar
adafruit_support_bill
 
Posts: 84669
Joined: Sat Feb 07, 2009 10:11 am

Re: Still problems max31855

Post by adafruit_support_bill »

How is the cartridge heater powered? If it is powered via AC, there could be significant EMI. If DC, probably not.

Post Reply
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”