Common ground causing issues

Ian0

Joined Aug 7, 2020
9,817
Going back to my original thoughts about its being caused by the voltage drop along a power track - this could happen if there is an increase of current when both devices are connected, probably caused by increased USB activity.

I don't quite follow how
inline double NTC_Thermistor::readResistance() {
return this->referenceResistance / (this->adcResolution / readVoltage() - 1);
}
gives you the resistance, because it doesn't look anything like the Steinhart-Hart formula to me. Are you using a lookup table? As thermistors don't generally read much above 100°C, I don't see how you could be getting 10 x the real reading.
Could you fill in a little more detail?
 

Thread Starter

nirbec89

Joined Feb 25, 2021
37
Going back to my original thoughts about its being caused by the voltage drop along a power track - this could happen if there is an increase of current when both devices are connected, probably caused by increased USB activity.

I don't quite follow how

gives you the resistance, because it doesn't look anything like the Steinhart-Hart formula to me. Are you using a lookup table? As thermistors don't generally read much above 100°C, I don't see how you could be getting 10 x the real reading.
Could you fill in a little more detail?
the code i posted was only part of the library i'm using :
https://github.com/YuriiSalimov/NTC_Thermistor

basically it reads voltage drop on the thermistor with reference to GND

inline double NTC_Thermistor::readVoltage() {
return analogRead(this->pin);

then calculate the resistance:

inline double NTC_Thermistor::readResistance() {
return this->referenceResistance / (this->adcResolution / readVoltage() - 1);
}

while referenceResistance is the value of the resistor that forms the voltage divider together with the thermistor.
then the thermistor resistance goes into the Steinhart-Hart formula :

inline double NTC_Thermistor::resistanceToKelvins(const double resistance) {
const double inverseKelvin = 1.0 / this->nominalTemperature +
log(resistance / this->nominalResistance) / this->bValue;
return (1.0 / inverseKelvin);
}

and finally it converts kelvin to celcius:

inline double NTC_Thermistor::kelvinsToCelsius(const double kelvins) {
return (kelvins - 273.15);
}

somehow when i connect the second mcu the readings are immediately changes from ~25degC to ~140degC.
When i unplug the second mcu, the readings comes back to ~25degC.
As far as i understand the only thing can go wrong and suddenly change is the voltage reading in the first function.
 

Ian0

Joined Aug 7, 2020
9,817
I see now! As I'm probably living in the past and assuming that my processor is less capable than it is, I use a 8-bit lookup table with a 12-bit ADC and feed-forward error correction to interpolate - it takes 13 ARM instructions and therefore executes in about 850ns at 16MHz. I can't help thinking that calculating the Hart-Steinhart equation with all its exponentials, logarithms and divisions every time you take a reading might be taking up a lot of processor time.

I'll make a few assumptions here:
1. Your pull-up resistor is about the same value as the 25°C resistance of your thermistor

2. Your ADC is between 8 and 12 bits.

If that is the case, then 140°C corresponds the data being read from the ADC being the lowest value than can be read - in other words, like shorting the thermistor to the supply, open-circuiting the pull-up resistor or there being some fault in the reading process such that it briefly reads zero.
 

k1ng 1337

Joined Sep 11, 2020
960
What is the ADC referenced to? I didn't see which uC you are using. For example the Pi Pico uses a power converter to produce a stable 3.3V reference.
 

Thread Starter

nirbec89

Joined Feb 25, 2021
37
I see now! As I'm probably living in the past and assuming that my processor is less capable than it is, I use a 8-bit lookup table with a 12-bit ADC and feed-forward error correction to interpolate - it takes 13 ARM instructions and therefore executes in about 850ns at 16MHz. I can't help thinking that calculating the Hart-Steinhart equation with all its exponentials, logarithms and divisions every time you take a reading might be taking up a lot of processor time.

I'll make a few assumptions here:
1. Your pull-up resistor is about the same value as the 25°C resistance of your thermistor

2. Your ADC is between 8 and 12 bits.

If that is the case, then 140°C corresponds the data being read from the ADC being the lowest value than can be read - in other words, like shorting the thermistor to the supply, open-circuiting the pull-up resistor or there being some fault in the reading process such that it briefly reads zero.
I haven't tested timing but i didn't ran into any time issues, i don't need such a speed since i'm controlling the temperature on relatively large copper block so temperature changes are not that fast anyway, but my mcu for sure work harder than yours while calculating this temperature :).

Both of your assumptions are correct, the pull-up resistor is 10K same as the thermistor and i'm working with STM32 mcu with 12bits ADC.

On Sunday i will print out the raw adc readings , it will be more useful then the calculated temperature..
 
Last edited:

Thread Starter

nirbec89

Joined Feb 25, 2021
37
What is the ADC referenced to? I didn't see which uC you are using. For example the Pi Pico uses a power converter to produce a stable 3.3V reference.
this is the board:
https://stm32-base.org/boards/STM32F411CEU6-WeAct-Black-Pill-V2.0.html

I'm just using one of the 3v3 pins.

on the schematic it looks like there is some voltage regulator to reduce the USB 5v to 3.3v, not sure about stability.
https://stm32-base.org/assets/pdf/boards/original-schematic-STM32F411CEU6_WeAct_Black_Pill_V2.0.pdf

Edit:
they do mention the regulator p/n:
https://stm32-base.org/assets/pdf/regulators/AP7343.pdf

but its chinese board so i guess none can really know...
 

Thread Starter

nirbec89

Joined Feb 25, 2021
37
Hi All,
I just came back to the office today and verified everything again,
I don't have a better way to say it... it was only a mechanical issue.:(
The thermistor wires were pressed under aluminium jig that created a short with the I2C sensor that is connected to the second mcu.

Sorry for all the trouble, and as always thank you very much for your professional help!
 

Attachments

Top