![]() |
Forum Index : Microcontroller and PC projects : K-Type Thermocouple help Please
![]() ![]() |
|||||
Author | Message | ||||
jman![]() Guru ![]() Joined: 12/06/2011 Location: New ZealandPosts: 711 |
Tested and working on a MX170 with V5.04.08 '''''''''''''''''''''''''''''''''''''''' 'Max 31855 Dim temp(4) Start: '''''''''''''''''''''''''''' 'Spi Read 32 bits WatchDog 5000 SetPin 4, Dout Pin(4) = 1 SPI Open 40000, 0, 8 Pin(4)=0 Temp(0) = SPI(0) Temp(1) = SPI(0) Temp(2) = SPI(0) Temp(3) = SPI(0) SPI CLose Pin(4)=1 Err = temp(3) And &B111 'Error check If err <> 0 Then Print "Thermocouple Error" Pause 1000 GoTo Start EndIf TempMSB = Temp(0)*16 TempLSB = ShiftR(Temp(1),4) TempDP = (ShiftR(Temp(1),2) And &B00000011) * .25 Temperature = TempMSB + TempLSB + TempDP Print "Temperature ";Temperature TempIntMSB = Temp(2) TempIntLSB = ShiftR(Temp(3),4) TempIntDP = TempintLSB * 0.0625 TempInt = TempIntMSB + TempIntDP Print "Internal Temperature ";TempInt Pause 1000 GoTo Start Function ShiftR(byte_in, shift) If shift <1 Or Shift > 7 Then Error "Invalid shift value" ShiftR = (byte_in \ 2 ^ shift) End Function Regards Jman |
||||
bigmik![]() Guru ![]() Joined: 20/06/2011 Location: AustraliaPosts: 2950 |
Hi Jman, Thanks for that, I tried your code and it’s the same.. I get 2048 for the hot end and 127.938 for the cold junction. I even swapped the CS onto pin4 (min was on pin 15) but no change, Remove the CS and I get thermocouple error.. Something is rotten in my setup for sure.. Regards, Mick Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
bigmik![]() Guru ![]() Joined: 20/06/2011 Location: AustraliaPosts: 2950 |
Hi All, Well I bought a MAX6675 module which arrived today. ![]() Using the code that Phil23 posted I get intelligible readings, seems a few degrees low but responds as expected, I havent compared to a thermometer yet but I reckon its about 15C in my room and the code returns about 10.5C, heating with a lighter increased the temperature rapidly till I stopped at about 70C.. I tested all of my Thermocouples and they read the same more or less. At this stage all I can say is to stay clear of these MAX13855 Modules.. ![]() I bought 3 from different Chinese and Australian based sellers and not one returns sensible readings, they also have Pins 1&2 shorted which GNDs one of the Thermocouple's legs. I have of course tried with that GND short in and out of circuit. My next step is to buy a MAX31855 fro RS (assuring a genuine chip) and trying with that. Thank you all for your help. Kind Regards, Mick Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
Agree with that. Played with these as a high-temp alternative to the 18B20 and I found the temperature was not as accurate as I expected. I put it down to the thermoelectric effect producing tiny voltages but offering quite a big range (1000c no problem). Putting a small capacitor across the cold end made no difference so it's not like the signal was getting swamped by noise. Also difficult to calibrate using the melting ice method due to the 0c cut-off. In my eyes it's a trade off of precision over range - if you are looking at 600C a few degrees either way won't matter for most things I guess. |
||||
isochronic Guru ![]() Joined: 21/01/2012 Location: AustraliaPosts: 689 |
Now I see why you cut the ground connection, the 31855 doc says expressly to not connect the thermocouple to ground, the 6675 schematic and pcb has it deliberately connected ! Weird - looks like they stuck the 31855 ic on a pcb designed for the 6675. Commiserations Mik. ![]() |
||||
bigmik![]() Guru ![]() Joined: 20/06/2011 Location: AustraliaPosts: 2950 |
Hi All, I played a little more before we had to go out to watch “Priscilla Queen of the Desert” (Great show by the way, WE had front row seats).. If I change the SPI mode from mode 2 to mode 0,1 or 3, the readings (at room temperature only tested) were within 1.5degrees.. I used a cheapa$$ electronic thermometer that showed my room was 19.3C (making the original code 9C low.. way too far out..) with either of the other 3 modes it returned 21 +- 0.5C. I will need to throw my head into the spec sheet to work out which mode should be best for the MAX6675. Regards, Mick Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
BrantB Newbie ![]() Joined: 27/10/2017 Location: CanadaPosts: 40 |
I know I am coming late to the game here, after several veterans have already weighed in ... but, if you're like me, these types of unresolved issues will haunt you. (At least, I know I have that character flaw; I envy you if you don't. ![]() I see from the datasheet that CS can be taken high at any point (i.e., it is not necessary to clock the entire 32 bit stream). I also see that, according to the datasheet, the first bit is presented to the SO (MISO) pin based on the falling edge of the CS (not necessarily correlated to the clock signal, if I read that correctly). I don't recall many (any?) other SPI streams being described this way, so part of me thinks that this may be significant. Having said that, I must admit I have only ever used SPI chips which have MISO and MOSI (as opposed to something like this one, which is most definitely output-only). Armed with those observations and the results that you have so far been getting, I would be very tempted to write my own bit-banging routines so that I could control every aspect of every step of the SPI process, and examine all of the pertinent results (at each individual step) with PRINT statements. I have resorted (successfully) to this sort of technique before - but in another environment (using the BASCOM compiler with Atmel's AVRs and/or Xmegas). And, I would only bother looking at the first 14 bits, since they are all that would be required to gain sufficient insight, and ultimately show success. I don't have one of the MAX31855 chips/boards, otherwise I would happily whip up some routines and dig into it a "bit" myself (I obviously could not resist the bad pun ![]() Sorry if that doesn't end up helping much, but I wanted to at least try to contribute something to towards your trials and tribulations. We've all been there at some point (probably more than once), and sometimes the eureka moment comes from left field ... so, consider this a wild pitch. ![]() Good Luck! Brant |
||||
bigmik![]() Guru ![]() Joined: 20/06/2011 Location: AustraliaPosts: 2950 |
GDay Brant, I suspect that you may be right there. I have got the MAX6675 working and doing what I needed (but my project has stalled due to time constraints) so I have shifted to that chip. If you PM me your address I am more than happy to send you a PCB and thermocouple to play with.. I have 3 here and they all do the same.. I cannot believe that all 3 boards are faulty (I may have killed one by plugging 5V in instead of 3v3). Let me know if interested.. They are of no use to me with no working software. Regards, Mick Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
BrantB Newbie ![]() Joined: 27/10/2017 Location: CanadaPosts: 40 |
Hi Mick, Time constraints ... boy, I know exactly what you mean. In fact, funny you should mention that. I am quite happy to take a crack at this if you send me a board, provided you're not in a rush. It will likely be a little while before I can have a look at it, but I will work on it. I'll also post back my findings (along with working code, hopefully). Although (still) a newbie to the forum and to the MM family, I have a great deal of respect for the high functioning of this forum. Members are respectful of, and helpful to, each other, and everyone seems to work towards the greater good. I will be happy to make a contribution to the ecosystem. I'll PM you with my address. And no need to panic on my account. Cheers! Brant |
||||
![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |