Can't quite make heads or tails of this Arduino thermistor circuit - Page 1
Forum section: electronics / projects

author: salfter
author_rank: Contributor
timestamp: July 30, 2018, 04:32:01 am
content: So I've put together a RAMPS-FD interface for my next 3D printer:https://github.com/bobc/RAMPS-FD/tree/devI built it myself because the Chinese cloners that are the usual providers of such things are only producing an older version with documented flaws. The version I built is supposed to be fixed. I went with this design instead of some of the others that are also available because it's modular, it offers a 32-bit upgrade path, and it provides support for six stepper-motor outputs (for X, Y, Z, and up to three extruders) and has enough MOSFET outputs to drive the bed heater, fans, and up to three hotends (to go with the extruders).So far, I've gotten the stepper-motor outputs and endstop inputs working. I have Marlin up and running on an Arduino Mega for testing, and I think I have it patched to talk to the hardware (various things are moved around, compared to the RAMPS from which it was derived). However, I'm having trouble with the thermistor inputs. No matter what resistance I put on an input (even if I put a jumper on it to short it out), Marlin reads out the same fairly high temperature.The attached schematic covers that part of the circuit. Part of the complexity is that the board needs to work with both the 5V Arduino Mega and the 3.3V Arduino Due (which will ultimately provide a 32-bit upgrade path). AREF is either 5V or 3.3V, depending on what type of Arduino is plugged in. I've measured 3.45V at the positive side of C1001...perhaps a touch high, but probably not by too much for even an Arduino Due.What I can't quite make heads or tails of is the rest of the thermistor circuit. One end of a (usually 100K) thermistor is connected to any one of THERM[0-3], with the other end connected to ground. The usual method of connecting a thermistor to an Arduino is to connect a thermistor and a 4.7K resistor across 5V and take the center connection to an analog input...a voltage divider, basically. The RAMPS-FD leaves the Arduino's AREF input disconnected and there's no call to analogReference() in Marlin, so the analog input range is from 0 to whatever the supply voltage is (5V for the Mega, 3.3V for the Due). I can't quite wrap my head around what the diodes and 1K resistor are supposed to be doing. The 1K resistor looks like a pullup, but the diodes look like they're connected in reverse. I thought maybe it was some sort of analog level-conversion voodoo, but with AREF=V_LOGIC, there shouldn't be any level conversion going on. What am I not getting about how this thing's supposed to work?

author: salfter
author_rank: Contributor
timestamp: July 30, 2018, 05:51:19 am
content: I think I might've figured out the diodes...input protection:http://www.designer2k2.at/mods/arduino/63-arduino-io-protectionIt looks like the input gets clamped to no more than OV_REF. At room temperature and with AREF=5V, I think the input from the voltage divider exceeds OV_REF. Marlin is reporting ~157°C. The datasheet for the thermistor says its resistance should be somewhere between 1.360K (at 150°C) and 1.064K (at 160°C). It looks like the thermistor and the 1K resistor are a voltage divider across AREF, and that the signal passes through the 4.7K resistor and some protection circuitry on the way to the Arduino's analog-input pin. If the thermistor resistance is high enough (temperature is low enough), the voltage tapped off it exceeds OV_REF, causing an erroneously high reading.With Marlin configured for a 1K pullup, it's now reading 233°C. Did some number crunching...still not sure if I should select 1K or 4.7K pullup. The numbers don't seem to add up for 1K, where they're somewhat in the ballpark for 4.7K.I then took a voltage reading where the diodes are connected together...got 3.94V at room temperature. It didn't budge when I pinched the thermistor between my finger and thumb. Shorting out the thermistor input dropped the voltage to near-zero, as expected. At room temperature, I should be seeing somewhere around 4.78V (4.7K pullup) or 4.95V (1K pullup).I'm beginning to wonder if this part of the RAMPS-FD isn't quite as multi-voltage capable as intended. It probably works with the intended Arduino Due just fine, but maybe it was never tested with the Arduino Mega and I'm running into problems as a result. I was hoping to verify functionality with an Arduino Mega to avoid frying a more expensive Arduino Due with an assembly screwup, but it looks like I might need to bite the bullet and swap in an Arduino Due. I haven't blown anything up yet, so I think I'm OK.