Maharashtra HSC Electronics Technology (Vocational) study materials
Maharashtra HSC Electronics Technology (Vocational) study resources

Noisy LM35 Reading and a Relay That Resets the 8051

Maharashtra HSC Electronics Technology (Vocational) · Put your knowledge to work in context.

All case studies

Noisy LM35 Reading and a Relay That Resets the 8051

An AT89S52 board reads an LM35 temperature sensor through an ADC0804 and switches a 5 V relay when the temperature exceeds 60 °C. The LM35 output is 250 mV at 25 °C and reaches the ADC input through a 300 mm unshielded wire. Vref for the ADC is taken from the same 7805 that supplies the relay, and port pin P1.0 drives the relay through a BC547 with a 1 kΩ base resistor. During testing, the displayed temperature jumps between 23 °C and 31 °C with the relay off, and when the relay pulls in the display freezes and sometimes resets. The relay coil measures 70 Ω; the 7805 output drops from 5.0 V to 4.6 V for a few milliseconds at switch-on. There is a 100 nF decoupling capacitor near the 8051 but none near the ADC or relay driver; the relay coil has no diode.

1. Calculate the ADC resolution in °C per bit and explain the 23–31 °C jumps. List changes that would reduce the uncertainty, with a quantitative estimate for at least one.

Read the worked answer

With Vref = 5 V, one ADC0804 LSB is 5/256 = 19.5 mV. The LM35 gives 10 mV/°C, so 1 LSB = 1.95 °C. A jump from 23 to 31 °C is about 8 °C, or roughly 4 LSB, which is too large for normal sensor noise alone; it suggests ground bounce and noise on Vref. The relay shares the 7805, and the 300 mm unshielded wire picks up digital and mains noise. Improve by taking Vref from a separate 2.5 V reference: resolution becomes 2.5/256 = 9.8 mV = 0.98 °C/LSB. Add a 100 nF capacitor from the LM35 output to analog ground and a 10 kΩ/100 nF RC filter at the ADC input (fc ≈ 160 Hz). Run the LM35 wires as a shielded twisted pair with the shield grounded at the ADC end only. Star-ground the analog and digital returns at the 7805, and add 100 nF at the ADC's Vref and supply pins. Average 8 or 16 readings and use 2 °C hysteresis so the relay does not chatter; averaging 16 readings reduces random noise by about √16 = 4.

2. Examine the relay driver. Calculate the base current with the 1 kΩ resistor, compare it with what the 8051 port can source, and recommend a reliable driver. Include the coil current and the purpose of a flyback diode.

Read the worked answer

Coil current is 5 V/70 Ω = 71 mA, so the BC547 with a 100 mA maximum is only just adequate; a 2N2222 or ULN2003 channel is better. For saturation, base current should be at least Ic/10 ≈ 7 mA. With a 1 kΩ resistor, the current would be (5 − 0.7)/1000 = 4.3 mA, and that assumes the port can source 4.3 mA at about 4.3 V. The 8051 quasi-bidirectional port sources only about 60 µA in the high state, although it sinks about 10 mA in the low state, so the transistor is not driven into saturation; the relay may chatter or the port pin may be pulled out of its high state. Use a PNP driver with emitter to +5 V, base to the port through 1 kΩ, and collector to the relay, or use a ULN2003 buffer so the MCU only sinks current. Add a 1N4007 across the coil, cathode to +5 V, to clamp the inductive kick, a 100 nF capacitor at the relay supply, and a 470 µF bulk capacitor at the 7805 output. Mount the flyback diode close to the coil. The 4.6 V dip indicates current limiting or shared wiring; separate the relay supply track and use a star ground.