Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Marlin 1.0.0 b1] Temperature reading #19

Closed
justjoheinz opened this issue Nov 25, 2011 · 23 comments
Closed

[Marlin 1.0.0 b1] Temperature reading #19

justjoheinz opened this issue Nov 25, 2011 · 23 comments

Comments

@justjoheinz
Copy link

I operate a Makerbot with a Ramps 1.2 board and just switched to Marlin 1.0.0 b1.I suspect that there is something wrong with the way that the bed and extruder temps are read. Both temperatures always increase or decrease, when the bed is being turned on and the heater is off (measured with voltmeter).

I changed my pins in the according setup as follows:

ifdef RAMPS_V_1_0 // RAMPS_V_1_0

#define HEATER_0_PIN 12 // RAMPS 1.0
#define HEATER_1_PIN -1 // RAMPS 1.0
#define FAN_PIN 11 // RAMPS 1.0

else // RAMPS_V_1_1 or RAMPS_V_1_2

#define HEATER_0_PIN 10 // RAMPS 1.1
#define HEATER_1_PIN 8 // RAMPS 1.1
#define FAN_PIN 9 // RAMPS 1.1

endif

define HEATER_2_PIN -1

define TEMP_0_PIN 2 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!

define TEMP_1_PIN 8 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!

define TEMP_2_PIN -1 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!

endif

Note the the bed TEMP_1_PIN is set to analog pin 8!
i switched PID of in the configuration.h file

Obeserved output (despite the fact that only the bed is turned on):
ok T:51.70 B:50.00
ok T:52.16 B:51.00
ok T:53.15 B:52.00
ok T:54.59 B:53.00
ok T:56.15 B:55.00

This used to work in Marlin Non Gen6 by the way!

I can provide other information if desired. Thanks Markus

@bkubicek
Copy link
Contributor

sorry, I don't really understand what you mean. Can you please try to describe it again? Maybe its also lack of coffee..

@ahmetcemturan
Copy link

Could you post your whole config file somewhere? Maybe some werid value in PID control.. You could test without PID to see if its the reading or the control...

@ahmetcemturan
Copy link

Ahhh well and " Both temperatures always increase" does that refer to the reading or do they really increase?

@justjoheinz
Copy link
Author

Hmm, I can't see where I can add files. Let me try to explain again.
In Marlin 0.9.10 everything works fine. I can control the temp of the bed and extruder and they both read correctly and heat up correctly.

So now for the Marlin 1.0.0 b config:

  • I uses Thermistors in my setup:
    #define THERMISTORHEATER_0 1
    //#define THERMISTORHEATER_1 3
    #define THERMISTORBED 1

#define HEATER_0_USES_THERMISTOR
//#define HEATER_1_USES_THERMISTOR
//#define HEATER_0_USES_AD595
//#define HEATER_1_USES_AD595

// Select one of these only to define how the bed temp is read.
#define BED_USES_THERMISTOR

  • Pid Temp is turned off.
    // PID settings:
    // Uncomment the following line to enable PID support.

//#define PIDTEMP
#ifdef PIDTEMP

  • Min Max Temp is turned off.
    //// The minimal temperature defines the temperature below which the heater will not be enabled
    //#define HEATER_0_MINTEMP 5
    //#define HEATER_1_MINTEMP 5
    //#define BED_MINTEMP 1

// When temperature exceeds max temp, your heater will be switched off.
// This feature exists to protect your hotend from overheating accidentally, but NOT from thermistor short/failure!
// You should use MINTEMP for thermistor short/failure protection.
//#define HEATER_0_MAXTEMP 275
//#define HEATER_1_MAXTEMP 275
//#define BED_MAXTEMP 150

So now for the scenarios:
I turn the bed on. The bed temp rises (both in the monitor and for real). So does the monitored temp of the extruder, although it does not go up for real.
I turn the bed off.
I set the extruder temp to something. The extruder starts to heat up in reality but the monitored temp stays at the lvel it is. No increase in temp is monitored but in reality the heater is heating up. As I mentioned before this working perfectly fine in Marlin 0.9.10.

@bkubicek
Copy link
Contributor

so there is no method at all where you get a correct extruder temperature right now?
If I understand correctly, thats 100% independent of the bed, right?

@bkubicek
Copy link
Contributor

oh, ah you aware that
#define THERMISTORHEATER_0 1
and
#define THERMISTORBED 1
seem so share the same PIN?

@justjoheinz
Copy link
Author

Huh? These settings are for the pins? I thought they were to choose the 100k thermistor table. Do they override what is configured in pins.h.
Well I try TERMISTORBED 8 as soon as I am back on the printer and report back.

@ErikZalm
Copy link
Contributor

berhard,

The number is the thermistor table not the pin.

justjoheinz can you put your configuration.h on gist. Then I can take a look at it. It works ok for other ppl but i don't understand why it is not working for you.
Your settings seems to be ok.

Why did you change your temperature pin?

@justjoheinz
Copy link
Author

Hope I did it right: https://gist.github.com/1395694 Included is my Configuration.h and pins.h

I changed the pin to Analog 8 because for the Makerbot Heated Build Platform you need a slightly different configuration on the Ramps 1.2 board. As I said before: the Hardware config works with 0.9.10 flawlessly. There must ( :-) ) be something wrong how the analog pins are read, either my configuration and pins.h or a change in the firmware.

@ErikZalm
Copy link
Contributor

Hello,

your config looks ok. I have no clue what is going wrong.

@justjoheinz
Copy link
Author

There must be some difference in the way analog pins are read from the
Non-GEN6 branch and the V1 branch.

@ErikZalm
Copy link
Contributor

The temperature part is completely rewritten.
But it works for a lot of ppl. The basics are ok.

I don;t know why it is failing for you. Can you measure the analog pins?

On Nov 26, 2011, at 6:42 PM, Markus Klink wrote:

There must be some difference in the way analog pins are read from the
Non-GEN6 branch and the V1 branch.


Reply to this email directly or view it on GitHub:
https://github.com/ErikZalm/Marlin/issues/19#issuecomment-2882784

@justjoheinz
Copy link
Author

hmm, what makes me different to lots of people is that I use pin 8 to read the bed temperature.
And the hardware wiring etc. is fine, because everything works on 0.9.10.

What am I suppose to measure? Given that the analog pins are input pins. If you have a specific idea let me know. I wold be grateful if you could give me the name and location of the function which is responsible for reading the analog pins to get the raw values before converting them to celcius. Maybe I can put some debug statements in the code to figure out what is going on.

@justjoheinz
Copy link
Author

"Fixed" it:

I changed the switch statement in the ISR timer of temperature.cpp to use analogRead instead of using the faster register to read the temperature raw values.

See: https://gist.github.com/1397466

So there seems to be some error how you write to the registers. BTW: I am on a Arduino Mega 2560. I am not very firm with AVR programming, but hope that helps you to solve the problem.

@ErikZalm
Copy link
Contributor

I will check the registers. The analogRead is not usable because it blocks the ISR for a long time.

Thanks for testing. This gives a direction to look.

@justjoheinz
Copy link
Author

I thing I have found the problem:
When an analog pin is > 7 one needs to set the MUX5 bit in ADCSRB, and I just concluded that somewhere we need to unset it again when the pin is <=7.
Additionally when the analog pin is > 7 we need to substract 8 before writing in the ADMUX register (see datasheet p.291, http://www.atmel.com/dyn/resources/prod_documents/doc2549.PDF)
The code should probably like this (repeated for the other case statements). I tried that and it gives reasonable results, but as I said I am not a very practiced avr programmer.

#if(TEMP_1_PIN > -1)
#if (TEMP_1_PIN > 7)
ADCSRB |= _BV(MUX5);
ADMUX = ((1 << REFS0) | ((TEMP_1_PIN - 0x08) & 0x07));
#else
ADCSRB &= ~_BV(MUX5);
ADMUX = ((1 << REFS0) | (TEMP_1_PIN & 0x07));
#endif
ADCSRA |= 1<<ADSC; // Start conversion
#endif
#ifdef ULTIPANEL
buttons_check();
#endif
temp_state = 3;
break;

@ErikZalm
Copy link
Contributor

Thanks for finding this stupid bug. I looked at the code a number of times but could not find it.
I will fix it. Now it is easy.

You are the first one I know who used the upper and lower adc inputs. Most boards only use the upper or lower inputs.

@ErikZalm
Copy link
Contributor

I pushed the fix.

justjoheinz can you test if this fix works. (And close this issue if it is fixed)

@justjoheinz
Copy link
Author

The temperature now seems to work fine! Thanks. Unfortunately I lost my per mm settings while operating with git and hence I did not do a print, but I close the issue anyway.

@knorst
Copy link

knorst commented Apr 26, 2014

Hello, I having the same problem of Markus. Where I can download the fix for this issue?

Regards

@nothinman
Copy link
Contributor

@knorst unlikely the same. this has been fixed 2 years ago. open new issue and describe the problem.

@knorst
Copy link

knorst commented Apr 28, 2014

@nothinman wasn't the same. Just figure out the problem. This firmware use the analog pin number, not the board pin number. This was the mistake.
Regards

rhapsodyv referenced this issue in rhapsodyv/Marlin Jul 10, 2020
script to download mks assets and create the assets folder
kgilliam2 pushed a commit to kgilliam2/Marlin that referenced this issue Oct 29, 2020
tonokip pushed a commit to ultimachine/Marlin that referenced this issue Jan 24, 2022
…47-sl-se-he' into 'master'

Resolve "Wrong firmware title when running M115 on Sidekick 747 SL, SE, HE"

Closes MarlinFirmware#19

See merge request lulzbot3d/marlin!10
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants