Thursday, March 20, 2014

Even Better Fix for the Temperature Shifts

As I discovered previously, the load of the relay coil was causing Vcc (which is used as the analog reference voltage by default) to droop when the coil was being driven to provide power to the heating pad.  This caused a shift in the measured temperature whenever the coil opened or closed. The problem was significant when the Arduino Uno was powered by USB and less but still noticeable when powered through the DC jack.

There's an even better fix, though, and it hinges on the fact that the temperature sensor I'm using, the TMP36, has the same output over a wide voltage range (2.7V to 5.5V).  By default, the Uno uses the 5.0V regulated voltage as the ADC reference voltage (AREF).  It is possible, though to wire an external voltage to the AREF pin and use that voltage as the ADC reference.  As it so happens, the Uno has a second regulated voltage on-board: a 3.3V supply.  I verified that whether the relay is open or closed, the supply provides 3.3V.  

It was a simple matter to make the hardware change and wire the 3.3V pin to the AREF pin. I also added a capacitor across AREF and ground to help stabilize the voltage, something I should have done before.  I left the temperature sensor on 5V; it puts out the same voltage whether powered by 3.3V, 4.93V, or 5.03V. The software changes were also straight-forward: tell the Uno to use the externally provided voltage on the AREF pin as the ADC reference and change one line of code used in converting the ADC value, having it use 3.3V instead of 5.0V in the calculation.

The proof is in the pudding, as they say:



No big shift when the green trace hits the temperature control limits. Looks like the problem is solved.



1 comment:

  1. Trevor, does anybody understand this? As a faithful mom I read it, but I don't really get it.

    ReplyDelete