5
\$\begingroup\$

I am working on an AVR project that involves measuring tempereture with an analog sensor (TMP36) and switching a heater on and off through relay to keep the temperature at desired level.

However, I've noticed that every time I switch the relay on, it causes the output voltage of the sensor to instantly drop, quite consistently by 0.01V to 0.02V (it's up to 2°C difference, so not negligible). To check whether that's AVR related problem or not I have constructed a simple test circuit, shown below. I simply enable the transistor by pushing down the button and observe voltage readings at sensor pins with a multimeter. It still shows the same behavior as with the AVR - switching on relay causes the same voltage drop.

enter image description here

Max current of my power supply is 5A, so it shouldn't be a power related problem.

Another important fact is that it doesn't matter if there's anything connected to relay's switching pins - this behavior seems only to depend on the relay coil being switched on and off.

\$\endgroup\$
6
  • \$\begingroup\$ Does the sensor output stay lower after energizing the relay coil? Does the 3.3V power change at all? \$\endgroup\$ Commented Jan 25, 2019 at 18:03
  • \$\begingroup\$ No, the sensor output goes back to normal level instantly when I switch the relay off. The 3.3V seems to stay quite stable and not affected by relay state. \$\endgroup\$
    – Arxair
    Commented Jan 25, 2019 at 18:10
  • \$\begingroup\$ How confident are you that the 3v3 line isn't affected? Have you measured with a scope. Your power capacitor seems small for the size of the load you drive. \$\endgroup\$
    – user109388
    Commented Jan 25, 2019 at 18:12
  • \$\begingroup\$ Something doesn't add up...a change of 0.2V at the sensor output would correspond to 20°C, not 2°C. Can you clarify this? How are things connected together physically? Do you have a solid ground plane? \$\endgroup\$ Commented Jan 25, 2019 at 18:16
  • \$\begingroup\$ 3.3V seems to be rock solid, I have checked at several points. And yes Elliot, my mistake, the voltage changes by 0.01 - 0.02V. There is only one, common ground plane, connected to power supply's ground wire. Excuse me if I'm saying something stupid, I am pretty much a beginner. \$\endgroup\$
    – Arxair
    Commented Jan 25, 2019 at 18:29

1 Answer 1

-1
\$\begingroup\$

There is only one, common ground plane, connected to power supply's ground wire.

This is where your problem is, very likely: a common ground between high-power signal path (inductive relay and 3-A heater), and a sensitive sensor which output is referenced to common ground. The effect frequently happens when power and signal ground are shared and routed improperly. This is called "ground bounce". It is not that the signal changes by 10-20 mV, it is the shift in ground potential between the sensor and MCU due to return current flowing form power part of the design.

To avoid parasitic interference of high-current into sensor readings, the grounding should be done as something along the following lines:

enter image description here

The following ground routing is bad: the MCU will read the actual Vout (which is the true value relative to sensor IC ground) plus the parasitic voltage drop along the power plane.

enter image description here

\$\endgroup\$
6
  • \$\begingroup\$ Thank you for your answer. However I am not sure if I understand it correctly - are you suggesting that ground outputs of different components should physically "meet" each other in the same point of the ground plane? \$\endgroup\$
    – Arxair
    Commented Jan 25, 2019 at 19:16
  • 1
    \$\begingroup\$ The ground circuit should be arranged so that the current from the power electronics to the power supply cannot possibly flow through the ground conductor from the sensor to the MCU. The schematic shown is one commonly accepted way to do it. \$\endgroup\$
    – TimWescott
    Commented Jan 25, 2019 at 20:09
  • \$\begingroup\$ I think I'm starting to understand this. I will try out some different setups and wirings on a breadboard when I'll be able to, but in conclusion - it is possible for me to keep only one power supply for the entire circuit and get correct temperature readings if I manage to make it the smart way? I would rather not have to rethink the entire project and use separate power supplies for power electronics and sensors/MCU. \$\endgroup\$
    – Arxair
    Commented Jan 25, 2019 at 20:41
  • \$\begingroup\$ @Arxair, single power supply is OK, you just need to route the sensor ground properly/separately, without having the relay in the path. \$\endgroup\$ Commented Jan 25, 2019 at 20:46
  • 1
    \$\begingroup\$ @Arxair the routing of wires makes difference because they are diffenrent.. your error is considering the wires as an ideal component (0 resistence, 0 inductance, 0 capacitance). Often this effects are pronounced with high frequencies (radio frequencies) but if they give problems at slow speed you have to consider a better topology on your circuit. Breadboards have high capacitance, and you square waves becomes not squared anymore. \$\endgroup\$
    – gino
    Commented Sep 27, 2021 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.