Common ground causing issues

Thread Starter

nirbec89

Joined Feb 25, 2021
36
Hi All,
I programmed a microcontroller to read NTC thermistor value, and send the temperature value to the PC with serial interface using USB cable.
I connected the NTC thermistor using voltage divider configuration as i found it very common online and its working OK.
(3.3V->Resistor->Thermistor->GND, while reading the voltage between the Thermistor leads)

In addition, I have another microcontroller that is completely separated from the first one, and it needs to send data through USB serial to the PC as-well.
Once I connect the second microcontroller, the temperature readings of the first microcontroller completely change to non reasonable values.

If I understand correctly, by connecting both USB cables to the PC, I'm actually connecting both microcontrollers GND's and it cause problem with the thermistor reading as the GND potential is not the same anymore.

Is there any way to isolate the thermistor's microcontroller GND, isolate the USB GND, or connect the thermistor differently to the microcontroller so it will not be affected by the second microcontroller?

Thanks in advance.
Nir.
 

Ian0

Joined Aug 7, 2020
5,504
It should be no problem provided that the 3.3V to the resistor is connected close to the microcontroller’s AVdd pin and the thermistor connects to ground close to the microcontroller’s Vss pin, and nowhere else.
If not, then you are reading the voltage drop across some ground track somewhere.
If close connection to the AVss/AVdd pins isn‘t possible then you need a differential amplifier to refer the signal to the AVss pin.
Do you have a filter capacitor across the thermistor?
Are you averaging the readings over a number of samples to remove noise?
 

Thread Starter

nirbec89

Joined Feb 25, 2021
36
Hi Ian,
Thanks for your quick response,
Actually the thermistor is connected by 1 meter wire, so it is not close to the electrical AVdd and ground connections,
at first, the long wiring added lots of noise, so i added 2.2uF capacitor parallel to the thermistor, and with that the signal is very smooth, no averaging is needed.
(link to the thermistor : https://www.digikey.com/short/bmhr2pm1 )

It's important to note that without the second microcontroller connected to the PC, the thermistor readings are good and stable,
only when i connect the other microcontroller that is completely separated from the first one, the readings gets wrong.
 

Ian0

Joined Aug 7, 2020
5,504
The length of wire doesn't matter unless it is a very low resistance thermistor, it’s where the wire connects to the circuit. It must be close to the AVss pin, not to a ground track way over the other side of the board. Post a screen shot of your pcb layout.
 

Thread Starter

nirbec89

Joined Feb 25, 2021
36
The length of wire doesn't matter unless it is a very low resistance thermistor, it’s where the wire connects to the circuit. It must be close to the AVss pin, not to a ground track way over the other side of the board. Post a screen shot of your pcb layout.
Understood regarding wire length,
The board is actually a perfboard so there is a soldered wire of ~4-5cm between the thermistor low side and microcontroller gnd pin.
 

Ian0

Joined Aug 7, 2020
5,504
Understood regarding wire length,
The board is actually a perfboard so there is a soldered wire of ~4-5cm between the thermistor low side and microcontroller gnd pin.
Does that wire connect to anything else? (such as the power supply) Or is it just used by the thermistor?
 

Thread Starter

nirbec89

Joined Feb 25, 2021
36
Does that wire connect to anything else? (such as the power supply) Or is it just used by the thermistor?
I'll be able to check and verify it only on Sunday,
But I still can't understand why thermistor readings works fine until I plug to the PC another USB cable from a different microcontroller (that does something else).
I thought that maybe once both USBs are connected both microcontroller GNDs get connected and maybe the 'GND' value is not the same anymore so readings changes.

does it make sense?
 

seanstevens

Joined Sep 22, 2009
144
So two independent MCUs connected to one PC via two USB ports - Are both powered from the PC USB ports, or does any have its own power adapter? And readings are affected when both are connected? Does the other MCU's out put show any issues, is it just the one with the thermistor showing a problem? It just doesnt make much sense.
 

BobTPH

Joined Jun 5, 2013
5,227
How do the values change? Is it a consistent shift up or down, or is it random noise? Is the temperature signal completely lost or just degraded?

Bob
 

k1ng 1337

Joined Sep 11, 2020
584
My Arduinos sometimes go crazy when I have 2 connected on different com ports (separate cables). I narrowed it down to both trying to use serial begin / access the serial monitor. Have you tried the Putty solution to monitor multiple ports at the same time?

Try commenting out the serial begin command on the first uC while leaving it powered via the USB. If that works I would try Putty for your second serial monitor.
 

DickCappels

Joined Aug 21, 2008
8,812
Measuring the voltage drop along both the ground wire to the thermistor and the 3.3 volt going into the series dropping resistor will probably tell you a lot.

You description sounds like classic cross-talk (or ground loop) problems that show up when two or more circuits use the same ground path, such as when going back to the power supply.
 

djsfantasi

Joined Apr 11, 2010
8,390
Are you also powering the microcontrollers with the USB cable? Have you tried powering one or both with a different power source? Use a wall wart or battery instead of the USB connection.
 

Thread Starter

nirbec89

Joined Feb 25, 2021
36
Thank you for the answers,
- Both mcu are powered from the usb port.
- Only one mcu having trouble with the thermistor voltage drop reading, the other mcu works fine, but i'm not measuring any voltages there, and again the thermistor reading goes wrong only when the second usb cable is connected.
- temperatures readings are getting higher approximately multiplied by 10, by the 'resistance to temperature' formula it means that the voltage readings also increases.

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

- im connected to both mcu with Putty, but i checked and found out that this is not serial communication issue/mixed up values caused by two com ports connected together, it is real change in reading.

- I'll measure voltages on Sunday as DickCappels suggested, and try to power one or both mcu from different power source and keep usb only for data.

In addition,
I prepared a schematic sketch of what i trying to do.
 

Attachments

djsfantasi

Joined Apr 11, 2010
8,390
Thank you for the answers,
- Both mcu are powered from the usb port.
- Only one mcu having trouble with the thermistor voltage drop reading, the other mcu works fine, but i'm not measuring any voltages there, and again the thermistor reading goes wrong only when the second usb cable is connected.
- temperatures readings are getting higher approximately multiplied by 10, by the 'resistance to temperature' formula it means that the voltage readings also increases.

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

- im connected to both mcu with Putty, but i checked and found out that this is not serial communication issue/mixed up values caused by two com ports connected together, it is real change in reading.

- I'll measure voltages on Sunday as DickCappels suggested, and try to power one or both mcu from different power source and keep usb only for data.

In addition,
I prepared a schematic sketch of what i trying to do.
I strongly recommend powering one or both MCUs from a source of power other than the USB port.
 

Thread Starter

nirbec89

Joined Feb 25, 2021
36
Just a thought… Have you tried swapping the USB ports on the PC? One could be having a problem.
yep, i tried swapping the USB ports in several combinations and i actually even tried another PC, issue remain the same.
I'll try powering one or both mcu from external power source asap.
 

MisterBill2

Joined Jan 23, 2018
12,399
There are three possibilities here, the more common source of problems is that some other current is flowing in a conductor that is part of the measurement loop. That is why measurement loops should be kept separate. Of course the common conductor might even be on the processor board. Another possibility is that the second board is disrupting the supply voltage for the first board. The third possibility is that it is a software/program issue of some sort. Three different areas.
 

k1ng 1337

Joined Sep 11, 2020
584
Thank you for the answers,
- Both mcu are powered from the usb port.
- Only one mcu having trouble with the thermistor voltage drop reading, the other mcu works fine, but i'm not measuring any voltages there, and again the thermistor reading goes wrong only when the second usb cable is connected.
- temperatures readings are getting higher approximately multiplied by 10, by the 'resistance to temperature' formula it means that the voltage readings also increases.

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

- im connected to both mcu with Putty, but i checked and found out that this is not serial communication issue/mixed up values caused by two com ports connected together, it is real change in reading.

- I'll measure voltages on Sunday as DickCappels suggested, and try to power one or both mcu from different power source and keep usb only for data.

In addition,
I prepared a schematic sketch of what i trying to do.
Your diagram is showing PSU1 ground is connected to uC1 and PSU2 ground is connected to uC2. If the uC's are powered by USB, why do they have grounds connecting to the PSU's? I see two ground loops from what you presented that don't make sense to me.
 

Thread Starter

nirbec89

Joined Feb 25, 2021
36
Your diagram is showing PSU1 ground is connected to uC1 and PSU2 ground is connected to uC2. If the uC's are powered by USB, why do they have grounds connecting to the PSU's? I see two ground loops from what you presented that don't make sense to me.
Your correct, my scheme is confusing,
There is no dedicated wire between PSUs GND to the MCUs,
But for the right side of the scheme, PSU1 GND is connected to the H-Bridge to provide power for the TEC module, and the MCU1 GND is connected to the logical side of the H-bridge to provide power for the logic.
I'm not sure if both power inputs to the Hbridge are GND connected. that's the link to the H-bridge
https://www.pololu.com/product/1451

For the left side PSU2 GND is connected to the i2c sensor to provide power, and the mcu GND is connected to the i2c sensor to support the i2c communication, in this case the PSU2 and MCU2 GND's are connected,

but again, there is no dedicated GND line between the PSUs and the MCUs in both cases, my scheme is misleading , sorry for that.
 
Top