-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
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
[BUG] Incorrect temperature scaling of AD595 on 3.3 volt boards like BTT SKR 3 #26010
Comments
This has come up a few times and in #11658, adding a config define like #define ADC_REFERENCE_VOLTAGE <value> |
I'm not sure how these device works/are connected but each HAL already has HAL_ADC_VREF |
Thanks for reviving this question. It was not resolved clearly the last time it was raised and no one submitted the simple patch until now. If we can be assured that the ADC reference voltage is also the one used to supply voltage to the thermocouple amplifier then we can just use I'll do a quick review on the PR and make sure it's easier to see that for a 5V input the 8495 returns a scale of 5mV/°C and the 595 returns a scale of 10mV/°C. The current use of |
According to the datasheets, you cannot even use an AD595 with a 3.3V supply voltage; the minimum is 5V. For a 3.3V ADC you must use AD8495 instead, since it allows for an input as low as 2.7V. Do we know that to be the case for all AD595 amplifiers, or is that just a limitation of the AD595 that I linked to? |
Originally I used an AtMega 2560 which is a 5 volt board and a 5 volt ADC reference. I additionally added a DC/DC converter to generate -5 volts so the AD595 had +/-5 volt supplies to be able to drive the analog input with the 4.7k pull up resistor for the thermistor still installed. |
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. |
Did you test the latest
bugfix-2.1.x
code?Yes, and the problem still exists.
Bug Description
The temperature reading from an AD595 thermocouple amplifier connected to a K type thermocouple (Temperature sensor type -1) reads high by (5 / 3.3 * actual temperature) on a controller board with a 3.3 volt ADC reference. For instance, 25C will display as 38C. This sensor works perfectly on a 5 volt board.
The problem is located in
temperature.cpp
line 1974 in2.1.2.1
or line 2145 ofbugfix-2.1.x
:Marlin/Marlin/src/module/temperature.cpp
Line 2145 in 1fbeac7
The "5.0" is the ADC reference voltage for a 5 volt board like the Arduino MEGA 2560. When replaced with a board like the BTT SKR 3 which uses a 3.3 volt ADC reference, the temperature reads incorrectly.
To fix the problem I changed the line to this:
The ideal fix isto have a parameter that defines the ADC reference voltage for each board instead of having to hard code it in temperature.cpp
Bug Timeline
Discovered by replacing Arduino MEGA 2560 with BTT SKR 3
Expected behavior
A temperature of 25.0C should display reasonably close to 25.0C
Actual behavior
25.0C displays as 37.6C.
Steps to Reproduce
Connect a AD595 with thermocouple (Temperature sensor type -1) to input E0.
For a temperature of 25.0C the display will show 37.6C. If you multiply 37.6 * (3.3/5) you get 24.8 which is close to 25.0 with only 10 bits of ADC resolution.
Instead of connecting an actual thermocoupe to E0, you can simulate it by applying 0.250 V to E0 thermister input.
Configuration.zip
Version of Marlin Firmware
2.1.2.1
but exists in all versions of MarlinPrinter model
Custom Prusa i3 mk2 style
Electronics
BTT SKR 3 board
Add-ons
AD595 thermocouple amplifier and E3D K type probe
Bed Leveling
UBL Bilinear mesh
Your Slicer
Prusa Slicer
Host Software
OctoPrint
Don't forget to include
Configuration.h
andConfiguration_adv.h
.Additional information & file uploads
A similar problem exists for anyone using an AD8495 on a 5 volt board because the 3.3 volt reference is hard coded on the line below the AD595.
Marlin/Marlin/src/module/temperature.cpp
Line 2146 in 1fbeac7
The "6.6" is actually 2 * 3.3 volts. I was done that way because the AD8495 output is only 5mv/C compared to 10mv/C on the AD595. Like the issue I described above, the ADC reference voltage should be defined in the board data instead of being hard coded.
The text was updated successfully, but these errors were encountered: