Temperature Controller Disturbed by Fan Startup
A team builds a classroom temperature controller with an ATmega328P board, a 5 V relay module, and a 12 V DC fan. The sensor is a 10 kΩ NTC thermistor in a voltage divider with a 10 kΩ resistor, connected to ADC0. The relay module has an optocoupler and a flyback diode. When the fan starts, the ADC reading jumps by 8–12 counts and the relay sometimes drops out; the board resets occasionally. The 12 V fan supply and the 5 V board supply come from the same 12 V 2 A adapter, with a 7805 regulator on the board. The sensor cable is 2 m long and runs parallel to the fan cable for 1 m. The ADC reference is the 5 V rail. The code uses a 10 ms ADC sample and a threshold of 30 °C with 1 °C hysteresis. The fan current is 0.6 A at 12 V, and the board draws 150 mA from 5 V.
1. Identify the likely coupling paths for the ADC jump and relay dropout when the fan starts. Distinguish supply sag from ground bounce and radiated coupling.
Read the worked answer
The fan is a 0.6 A load with a much higher start-up surge. Sharing one 12 V adapter means the 12 V rail droops during start; the 7805 input falls, so the 5 V rail and the ADC reference move together, changing the count. Shared ground wiring creates ground bounce: fan return current develops a voltage between the sensor ground and the MCU ground, which adds to the thermistor signal. The 2 m sensor cable running parallel to the fan cable for 1 m also forms a pickup loop for switching transients. An 8–12 count jump at 5 V/1024 ≈ 4.9 mV per count is about 40–60 mV, consistent with ground shift or reference sag rather than a sensor failure. The relay dropout and occasional reset point to the same supply/ground disturbance.
2. Propose a prioritized fix list. Include one measurement that would confirm each main hypothesis.
Read the worked answer
Prioritized: (1) Give the fan/relay a separate supply or at least a dedicated short return to the adapter, and use a star ground at the adapter; measure the 5 V rail and the voltage between sensor ground and MCU ground during fan start. (2) Add bulk capacitance: 470 µF on the 12 V rail and 100 µF on the 5 V rail, close to the regulator. (3) Reroute the sensor cable away from the fan cable, twist the pair, and add a 10 kΩ/100 nF RC filter at ADC0. (4) Only then add software filtering. The first fix should be supply/ground separation because it explains the ADC jump, relay dropout and resets together. If a scope is unavailable, use the DMM in min/max mode on the 5 V rail while switching the fan.
3. Calculate the 7805 power dissipation when the board draws 150 mA. Is a heatsink advisable, and does this explain the fan-start disturbance?
Read the worked answer
7805 dissipation: (12 − 5) V × 0.150 A = 1.05 W. A bare TO-220 in free air has a junction-to-ambient rise of roughly 65 °C/W, so 1.05 W gives about 68 °C rise; from a 30 °C classroom this approaches 100 °C junction, and a fan-start brownout worsens it. A small heatsink is advisable, and the input capacitor should be close to the regulator. This does not by itself explain the ADC jump, but it is a reliability issue.