Closed derletztename closed 8 years ago
The most likely thing getting stuck related to that thermocouple is the reading of the MAX31855
itself. The loop which reads the bits will stick if it never gets all 4 bytes. So perhaps it's an issue of timing. The read speed for the MAX31855 is 4x the rate of the MAX6675, so possibly the initial delay is too large. Try editing the method Temperature::read_max6675
in temperature.cpp
and removing one of these two "nop" lines…
// ensure 100ns delay - a bit extra is fine
asm("nop");//50ns on 20Mhz, 62.5ns on 16Mhz
asm("nop");//50ns on 20Mhz, 62.5ns on 16Mhz
I am not a coder and I have no idea what it really means that you just told me, but I will try this out and post my experiences. Thank you :)
I hear ya – I've never been to Moscow. Let me know if the suggestion helps.
It did not change anything at all, as it seem :(
Actually both ICs look very similar: https://cdn-shop.adafruit.com/datasheets/MAX31855.pdf https://cdn-shop.adafruit.com/datasheets/MAX6675.pdf
The only easy to see difference is: MAX6675 The data is output in a 12-bit resolution, SPI™-compatible, read-only format. MAX31855 The data is output in a signed 14-bit, SPI-compatible, read-only format.
Also the MAX6675 can only work with type-K thermocouples and the MAX31855 works with several thermocouple types, which is why I am trying to use it...
Is this a problem for Marlin somehow, that it treats both ICs the same? 12-bit resolution and signed 14-bit?
Here are two Arduino Librarys for the MAX6675 and the MAX31855. Maybe the difference in the code helps fixing the Marlin Issues? https://learn.adafruit.com/thermocouple/using-a-thermocouple
The MAX31855 code is twice the lines than the MAX6675. Also it looks different. Nevertheless it's still russian to me :(
In temperature,cpp line 1293
You can try changing SPR1 to SPR0. This increases the clock rate for the MAX31855, but you may end up with erranous values at times.
Can you please post your configuration.h file.
Also if you are in a particuarly noisy location, you may have spikes on the data/clock lines or even the thermocouple itself. Also note that that you need to plug in the 5V from RAMPS to the 5V pin on the MAX31855 board, not the 3V3 rail, as that is an output .
I am not using the IC directly, I am using the Adafruit breakout board https://www.adafruit.com/index.php?main_page=product_info&products_id=269&zenid=516505f41182f3a344fea2f8955968e0
This line should be uncommented
//#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders
This line should be a lower value
#define HEATER_0_MAXTEMP 1650
K type typically has a 500 degree upper limit, what thermocouple are you actually using?
I'm printing Steel, it's very experimental ;) For the first experiments I only used a small amount of power and therefore it's heating up very slow. That's a problem for the thermal runaway...
The System can melt steel easily, but I wasn't able to measure higher temperatures above 1350°C, as I can't get that stupid MAX31855 to work :(
@derletztename what thermocouple are you using?
This from the adafruit site Works with any K type thermocouple Will not work with any other kind of thermocouple other than K type
started with a thermocouple type k, and now i am trying to use a thermocouple type s, which only works with the MAX31855. I have the breakout board with a thermocouple type k for testing, but also changed the IC on another board and try to use it with a chinese thermocouple type S...
Here is a picture of the system melting steel wire:
https://datasheets.maximintegrated.com/en/ds/MAX31855.pdf
package for S type thermocouple should be MAX31855SASA+T
I asked the adafruit technicans. They say if you change the chip (solder, unsolder) it's suppose to work. Nevertheless it's not even working with the type k thermocouple without changing anything. I bought 2 breakout boards to tests this
I postet the same pdf^^
The max6675 also has an alternate type of package
on the SO8 it should read MAX31855S whereas the original chip marking reads MAX31855K The K and S are the cold junction offsets within the device
Can you also please post a photo of your thermocouple boards?
https://cdn-shop.adafruit.com/datasheets/MAX6675.pdf says it's only reading type K thermocouples. Or how do you mean alternate type of package?
I use the adafruit board. https://www.adafruit.com/index.php?main_page=product_info&products_id=269&zenid=516505f41182f3a344fea2f8955968e0 and plugged it in as said on their site
My mistake, I thought there was another variant of the 6675 for different thermocouples
Man, you brought up hopes :( Is there hope to get the MAX31855 running?
Indeed, I suggest first using an unmodified MAX31855 board and use a fresh copy of the Marlin firmware
I did. I bought 2 breakout boards and only modified one. I am trying to get it working with the unmodified board and I hardly changed anything in the Marlin RC and RCBugFix edition. The error also happens without the RAMPS plugged in the Arduino. But the error do not happen without the -3 for the MAX31855 board set. So it must be an error in the Marlin code I guess
Just try this, download a new copy of Marlin and compile it with the -3 for the MAX31855 and see if you can connect to your Arduino afterwards. For me it don't work with pronterface nor with the Arduino software itself anymore. The only workaround is to upload another code just after plugging the Arduino in
I can't try that out till late tonight when I get home from work
Might not bee very interesting for your problem. To make negative temperature readings correct with a MAX31855, these chanes are needed. Shifting right a negative unsigned will not shift in the needed 1s but always 0s (what makes them high positives).
@@ -1295,16 +1295,16 @@ void Temperature::disable_all_heaters() {
#if ENABLED(HEATER_0_USES_MAX6675)
#define MAX6675_HEAT_INTERVAL 250u
#if ENABLED(MAX6675_IS_MAX31855)
- uint32_t max6675_temp = 2000;
+ int32_t max6675_temp = 2000;
#define MAX6675_ERROR_MASK 7
#define MAX6675_DISCARD_BITS 18
#define MAX6675_SPEED_BITS (_BV(SPR1)) // clock ÷ 64
#else
- uint16_t max6675_temp = 2000;
+ int16_t max6675_temp = 2000;
#define MAX6675_ERROR_MASK 4
#define MAX6675_DISCARD_BITS 3
#define MAX6675_SPEED_BITS (_BV(SPR0)) // clock ÷ 16
#endif
@@ -1347,11 +1347,11 @@ void Temperature::disable_all_heaters() {
if (max6675_temp & MAX6675_ERROR_MASK)
max6675_temp = 4000; // thermocouple open
else
max6675_temp >>= MAX6675_DISCARD_BITS;
- return (int)max6675_temp;
+ return max6675_temp;
}
#endif //HEATER_0_USES_MAX6675
For analysing the problem
@@ -1343,11 +1343,31 @@ void Temperature::disable_all_heaters() {
}
WRITE(MAX6675_SS, 1); // disable TT_MAX6675
if (max6675_temp & MAX6675_ERROR_MASK)
- max6675_temp = 4000; // thermocouple open
+ #if ENABLED(MAX6675_IS_MAX31855)
+ if (max6675_temp & 1) {
+ SERIAL_ERROR_START;
+ SERIAL_ERRORLNPGM("Temp measurement error! MAX31855 Open Circuit");
+ }
+ if (max6675_temp & 2) {
+ SERIAL_ERROR_START;
+ SERIAL_ERRORLNPGM("Temp measurement error! MAX31855 Short to GND");
+ }
+ if (max6675_temp & 4) {
+ SERIAL_ERROR_START;
+ SERIAL_ERRORLNPGM("Temp measurement error! MAX31855 Short to VCC");
+ }
+ #else
+ if (max6675_temp & 4) {
+ SERIAL_ERROR_START;
+ SERIAL_ERRORLNPGM("Temp measurement error! MAX6675");
+ }
+ #endif
+ //max6675_temp = 4000; // thermocouple open
+ max6675_temp = 25; // JUST TO AVOID THE KILL!!! Don't use in production.
else
max6675_temp >>= MAX6675_DISCARD_BITS;
return (int)max6675_temp;
}
might help.
Wo bist den Du in Deutschland?
Nähe Köln/Bonn. Über Support vor Ort würde ich mich seeehr freuen ;)
endif
+ //max6675_temp = 4000; // thermocouple open + max6675_temp = 25; // JUST TO AVOID THE KILL!!! Don't use in production. else max6675_temp >>= MAX6675_DISCARD_BITS;
--> leads to an error because the "#endif" ends the "if loop" and than there is an else without an if. Is the position, how much the line is indented (eingerückt) important for Arduino Code? Or should this be solved by the "#"? I hate to have no idea about coding :(
leads to an error because the "#endif" ends the "if loop"
Try this:
if (max6675_temp & MAX6675_ERROR_MASK) {
SERIAL_ERROR_START;
SERIAL_ERRORPGM("Temp measurement error! ");
#if MAX6675_ERROR_MASK == 7
SERIAL_ERRORPGM("MAX31855 ");
if (max6675_temp & 1)
SERIAL_ERRORLNPGM("Open Circuit");
else if (max6675_temp & 2)
SERIAL_ERRORLNPGM("Short to GND");
else if (max6675_temp & 4)
SERIAL_ERRORLNPGM("Short to VCC");
#else
SERIAL_ERRORLNPGM("MAX6675");
#endif
//max6675_temp = 4000; // thermocouple open
max6675_temp = 25; // JUST TO AVOID THE KILL!!! Don't use in production.
}
else
max6675_temp >>= MAX6675_DISCARD_BITS;
At least this is compiling, going to test this on the machine soon :)
I've completely same trouble as @derletztename. Arduino MEGA2560 + RAMPS 1.4 EFB + Adafruit MAX31855. I doubted that my hardware is broken at 2 month ago, but now I setup new MEGA2560 + new RAMPS, same trouble still alive.
It continuously reboots (freeze) when using MAX31855 without SDSUPPORT
.
When freezing, red LED on RAMPS is flashing.
It can be reproduced without real thing of MAX31855.
When I enable SDSUPPORT
, MINTENP Err is occurs on every startup.
Try this:
Unfortunately any message of those was shown.
// ensure 100ns delay - a bit extra is fine - asm("nop");//50ns on 20Mhz, 62.5ns on 16Mhz - asm("nop");//50ns on 20Mhz, 62.5ns on 16Mhz + //asm("nop");//50ns on 20Mhz, 62.5ns on 16Mhz + //asm("nop");//50ns on 20Mhz, 62.5ns on 16Mhz
- uint32_t max6675_temp = 2000; + int32_t max6675_temp = 2000;
- uint16_t max6675_temp = 2000; + int16_t max6675_temp = 2000;
- return (int)max6675_temp; + return max6675_temp;
These weren't also solved problem unfortunately.
And, I'm seeing interesting result.
With this setting, MINTENP Err is occurs on startup.
But with this setting, MAXTEMP Err and MAX31855 Open Circuit Err are occurs on startup.
It seems that something of other setting is affecting to result.
Edit: My mistake of test. Results are same. Above Open Circuit Err occurred when MAX31855 was not connected.
Still searching, but this setting and dirty hack works fine for some reason.
#if ENABLED(HEATER_0_USES_MAX6675)
- #if DISABLED(SDSUPPORT)
+ //#if DISABLED(SDSUPPORT)
OUT_WRITE(SCK_PIN, LOW);
OUT_WRITE(MOSI_PIN, HIGH);
SET_INPUT(MISO_PIN);
- WRITE(MISO_PIN,1);
- #else
+ WRITE(MISO_PIN, HIGH);
+ //#else
OUT_WRITE(SS_PIN, HIGH);
- #endif
+ //#endif
OUT_WRITE(MAX6675_SS, HIGH);
#endif //HEATER_0_USES_MAX6675
I tried compiling RC7 a few days ago, not RCBugFix, with Max31855 thermocouple and I just get a compiling error. DIODIO_MISO had not defined in this scope. It was referring to pin 53 not being defined, possibly due to a conflict with SDCard, it read like it was a typo. DIODIO_MISO should be DIO_MISO
I hadn't tried yet with RCBugFix, I've not had a good week.
So, this hack (same as above) works fine with SDSUPPORT
too, but there is a conditional.
When SDCard or microSD - SDCard adaptor is already inserted in card slot at bootup of Marlin, it causes freeze and LED flashing.
But SDCard or microSD - SDCard adaptor is inserted to card slot after bootup of Marlin, both SDCard and MAX31855 works fine.
#if ENABLED(HEATER_0_USES_MAX6675)
- #if DISABLED(SDSUPPORT)
+ //#if DISABLED(SDSUPPORT)
OUT_WRITE(SCK_PIN, LOW);
OUT_WRITE(MOSI_PIN, HIGH);
SET_INPUT(MISO_PIN);
- WRITE(MISO_PIN,1);
- #else
+ WRITE(MISO_PIN, HIGH);
+ //#else
OUT_WRITE(SS_PIN, HIGH);
- #endif
+ //#endif
OUT_WRITE(MAX6675_SS, HIGH);
#endif //HEATER_0_USES_MAX6675
Then, I guess that initialize process of Marlin has some kind of problem...
Recently we shifted the initialisation of the thermal manager in front of the initialisation of the display/SDcard, because of uncontrolled heaters during the boot screens.
@esenapaj Your 'hack' makes perfect sense to me. The SPI interface has to be initialized here.
My final result at this time: https://github.com/esenapaj/Marlin/commit/a76393d6a0c3fc844359c424b562765cdafca4e8
In Marlin_main.cpp
lcd_init();
#if ENABLED(SHOW_BOOTSCREEN)
#if ENABLED(DOGLCD)
safe_delay(BOOTSCREEN_TIMEOUT);
#elif ENABLED(ULTRA_LCD)
bootscreen();
- lcd_init();
+ #if DISABLED(SDSUPPORT)
+ lcd_init();
+ #endif
#endif
#endif
This second lcd_init()
causes freeze when SDSUPPORT
(and MAX31855) is enabled for some reason.
But when SDSUPPORT
is disabled, this doesn't causes freeze, moreover if this second lcd_init()
is removed, displaying of LCD is broken.
In tmperature.cpp
#if ENABLED(HEATER_0_USES_MAX6675)
- #if DISABLED(SDSUPPORT)
- OUT_WRITE(SCK_PIN, LOW);
- OUT_WRITE(MOSI_PIN, HIGH);
- SET_INPUT(MISO_PIN);
- WRITE(MISO_PIN,1);
- #else
- OUT_WRITE(SS_PIN, HIGH);
- #endif
+ OUT_WRITE(SCK_PIN, LOW);
+ OUT_WRITE(MOSI_PIN, HIGH);
+ SET_INPUT(MISO_PIN);
+ WRITE(MISO_PIN, HIGH);
+ OUT_WRITE(SS_PIN, HIGH);
OUT_WRITE(MAX6675_SS, HIGH);
#endif //HEATER_0_USES_MAX6675
By test, these all the writing process are needed whether SDSUPPORT
is enabled or not.
If one of those lack, MINTEMP Err or freeze occures.
I wonder that why OUT_WRITE(SS_PIN, HIGH)
is also needed when SDSUPPORT
is disabled.
This result is still bit unstable (broken displaying or slow bootup or MAXTEMP Err occures once in a while when bootup), but in that case, remove a SDCard then reset or completely power off / on the machine, it restore stability.
@derletztename
I prepared a test branch that it's based on newest RCBugFix.
Please try it if you'd like.
https://github.com/esenapaj/Marlin/tree/succeed
So great, i absolutely will test this. Thanks
Your code is working on my arduino, it doesn't freeze anymore, but I got an Mintemp error and Marlin stops working immediately. I checked the wiring again and everything is fine. Any Ideas about that?
I guess that maybe your wiring of K thermocouple is inverted. K thermocouple has polarity. When start heating with inversely wired K thermocouple, measured temperature isn't increased but decreased, finally it go below the mintemp.
And this is information: my wiring
Actually it was at first, but after changing it, the error stayed the same. Also it's popping up just after booting Marlin via Pronterface. So I have no chance to see where the temperature would go to (up or down). It's just killing the Process with an error. Maybe I could upload a screenshot...
This is mine.
I'd like to see your Configuration.h
, Configuration_adv.h
, and pins_RAMPS.h
.
If you rename those files to Configuration.txt
, Configuration_adv.txt
, and pins_RAMPS.txt
, and drag & drop to Comment window in this thread, those files are uploaded.
I can test your setting on my machine, because we has same hardware (RAMPS and MAX31855 by Adafruit).
When I try to use Marlin on my RAMPS 1.4 EFB with the MAX31855 thermocouple board and the thermocouple after compiling and uploading, Marlin goes into some kind of loop and I can't connect with pronterface. Also I can't upload anything again unless I upload just in the tiny moment after plugging the Arduino into my PC. This happens with Marlin RC7 and RCBugFix on every Arduino I tested with and without RAMPS. And it only happens when I compile Marlin with the "-3" for MAX31855 support. Maybe someone could figure out, what is wrong? I'm printing metal, I need to measure high temperatures :(