I’ve always had a bit of a love/hate relationship with computers, so it is not uncommon for me to go a few months feeling a bit apathetic towards them. Recently, I have been getting more into electronics and microcontrollers (it seems like the perfect next step after computers). So, here is what is, hopefully, the first of many posts on electronics.
I was working on a digital thermometer the other day, based on the MCP9701A (and an ATmega88 AVR and LCD display). This device (described as a low power, linear, active thermistor) provides an output voltage that varies linearly with temperature (in this case, Vout = 400mV + 19.53mV/°C). Testing the device with a multimeter on an isolated circuit gave the expected results (around 1V output on a 30°C day). Strangely though, when connected the microcontroller and LCD display, the output (both as read by the ATmega’s ADC and by a multimeter) was in the range of 2.5V to 4V (which corresponds to 105°C to 185°C) – obviously inaccurate (at those temperatures, I wouldn’t be around to write this).
Another interesting symptom I noted was that, even in the absence of the thermistor, the ADC still read values in excess of 2V. I tried a few approaches, with varying degrees of success:
- I initially thought that perhaps the ACD pins were configured as an output – this was completely erroneous (in retrospect, it doesn’t even seem logical – both in terms of the values being obtained, and the fact that the ADC was reading values from the pin).
- Use a pull-down resistor (around 10kΩ, to ground) on the ADC pin – this mostly eliminated the voltage when the thermistor was not connected (readings between 0mV – 15mV), but had no effect when it was connected.
- Use a small capacitor (2.2nF) between the Vout and ground of the thermistor – no effect on the voltage, but did stabilize the values somewhat.
The problem turned out to be something a bit different. I power my setup using a 7.5V (1A, DC) adapter and a 7805 voltage regulator. Being rather new to the world of electronics (although, I have worked with more ‘traditional’ electrical circuits for years), I hooked up my 7805 and tested it without a load – and got an output voltage between 4.99V and 5.01V, which I was quite happy with. Connected to my microcontroller and LCD though, the voltage dropped to about 4.6-4.7V. Now this seemed a bit peculiar to me, but since everything was running acceptably, it wasn’t something I put much thought into. (Additionally, to me, given a lower input voltage to the thermistor, I would expect a lower output voltage, not one that is significantly higher).
The solution, simply entailed adding a filter capacitor to the voltage regulator. I tried both a 0.1µF and a 1µF capacitor between both Vin and ground and Vout and ground (and both together). All seemed to have essentially the same result – output voltage stabilized in 4.99V to 5.01V range, and the MCP9701A started yielding a reasonable output. (That said, it was still off by a few degrees, but adjusting the formula to assume a higher offset voltage (about 515mV instead of 400mV) seemed to give much more accurate temperatures. There is definitely much more to learn, and many other approaches to improving accuracy, some of which I may explore at a later date, but so far, it seems that, much like with computers, the small things (overlooking a capacitor) are the hardest to diagnose.
- MCP9701A Data Sheet – Microchip Technology Inc. [PDF]