Scaling ADC for higher resolution

jodicalhon

New Member
I'm playing with a simple temperature datalogger using an LM335 temp sensor into an 08M.

The LM335 gives 10mV/degK. Using normal 8bit ADC at 5 volts gives 5000/256 = 19.5 mV/step. So my temperature reading resolution is down to ~2 degC. Not so good.

Using readadc10 gives a resolution of 0.5 degC, so this would be better, but I was unsure about writing and reading datawords to eeprom, though I've taken on board the advice to jhimes in the 'eeprom data storage' thread. Besides, my data memory is limited in the 08M so I'd like to keep my readings to byte values to maximise the number of readings I can make.

Which got me thinking (hang on...nearly there...), I don't need to take measurements over a 50 deg range (5 volts), only about a 15 to 20 deg range.

Is there a way to scale the range the ADC reads? Besides varying the supply voltage that is. Any clever maths? Not so clever maths? Input conditioning?

Any ideas appreciated.
 

Jeremy Leach

Senior Member
One point : I believe that onboard data memory has a limited lifetime in number of writes it can receive.

Secondly, for data storage a simple compression technique could be to just store the difference in temperature between readings. If, say, the maximum rate of change of temperature is expected to never exceed 5 degree per hour then if you're taking hour readings you just need to be able to store a value of 5*2 = 10 if measuring to 0.5 degree resolution.

You would need to record the start temperature accurately, but from then on just record the change. Since a value of 16 fits in 4 bits you could store 2 'delta' readings per byte.
 

ylp88

Senior Member
V(15'C) = 2.88V
V(20'C) = 2.93V
Range = R = 0.05V

I've never done it with with a temperature sensor like this before but I suppose you could use an op-amp to scale your voltages. Unfortunately, no guarantees...

As most chips come with 2 or 4 op-amps in them, you can use one to offset the voltage, and the second to scale the voltage:

OP-AMP 1:
<code><pre><font size=2 face='Courier'>
|\
from sensor ---------|+\
| &gt;------- to op-amp 2
Vref---|-/
|/
</font></pre></code>

Where Vref is connected to a 2.88V reference - via a trimpot, perhaps. You can calibrate the trimpot using a multimeter. Maybe you may wish to calibrate it to 2.08V (or some factor of 10 lots of 10mV [eight in this case], so that there is some overhead from the op-amp's supply rails).

OP-AMP 2:
<code><pre><font size=2 face='Courier'>
|\
from op-amp 1 ---------|+\
| &gt;-+- to PICAXE ADC
+---|-/ |
| |/ |
| |
+--3.3k--+
|
56ohm
|
GND
</font></pre></code>

This should give a non-inverting gain of about 60 (actually, ~59.928. Close enough I think), so the 0.05V range will be amplified by 60 to a range of 3V. This will allow for some space from the voltage rail.

Not sure if this will all work, though. Working with a voltage range of 0.05V is difficult, especially around digital circuits. Good filtering is a MUST! Also, the op-amp should be chosen with a good CMRR and low input offset voltage (ie. less than 10mV). Maybe a LM358 will suffice... The resistors may need to be all scaled up by a factor of 10 or 100 - not sure whether there is a minimum to the ground feedback resistor.

These are all ideas and probably need a lot of refinement, plus it's almost 1:00am here so this is coming from as VERY tired brain... Feel free to comment (good or bad or constuctive...). Apologies if I sound disjointed or this sounds like utter rubbish - it sounded good in my head at the time... ...

<b><i>ylp88 </b> </i>
 

ylp88

Senior Member
Just before I go to bed, I think the offset and gain may need to be adjusted becasue the offset I gave (0.8V) will be too big and will get amplified by the second op-amp which may clip past the rails - I'll look at it tomorrow if I have time.

<b><i>ylp88 </b> </i>
 

triple crown

New Member
over a 50 deg range, you could do a signal condition for this. I use a lm34dz for my applications and the results would be .2 degrees fahrenheit per bit. Setup temp max for 5vdc and the min temp as 0vdc.
 

BeanieBots

Moderator
If you want to stick with the analog sensor, then the offset and gain using op-amps as described by ylp88 is your best bet. You could either use pots to trim to the exact values or get close and fine tune in software. Storing the raw data would help reduce memory requirements because it would already be scaled to fit a byte.
You might like to consider using the DS18B20 sensor. It is digital and can be read using the readtemp command. If you use the readtemp12 command, you get a resolution of 0.06 deg C. This could then be scaled to fit your desired range into a byte value.
 
you should be able to remove any input offset errors using a 10K trim pot track across the two null pins of the op-amp and the wiper to your -VCC. Connect both your inverting and non-inverting to ground and now measure between output and ground until you have 0V dc.

http://www.uoguelph.ca/~antoon/gadgets/741/741.html has quite a nice tutorial on 741 op-amps.

Make sure you have plently of current limiting on your supply to the LM335 - it wants less than 1mA to prevent self-heating.
 

ylp88

Senior Member
It is probably better to use a 358 or 833 than a 741 becasue they have internal offset compensation, plus they have two op-amps in one package.

<b><i>ylp88 </b> </i>
 

goom

Senior Member
I have just gone through this exercise myself whilst designing a thermometer for my car. I ended up with (I think) a workable design using a precision reference and a differential instrument amplifier using op amps. Apart from the complexity, I realised that the accuracy of the ADC conversion is dependant on the accuracy of the +5V Picaxe supply, which (using a conventional regulator) would be poor since the range would be -35&#176;C to +30&#176;C.
The bottom line is that I decided to use the DS18B20 sensor. Solves all of the problems in one fell swoop.
 

ylp88

Senior Member
But in general use, I think it would be interesting to look into this sort of analog condictioning further - some sensors are either exorbitantly expensive or simply unavailable in a digital output version.

<b><i>ylp88 </b> </i>
 

jodicalhon

New Member
Thanks to all for your interest. I was thinking some more overnight, and read your replies today, and will probably have a go at scaling the sensor readout via an opamp.

I'd love to try the digital temp sensor, but don't have easy availability, and I have the LM335 on hand. If it all works out I'll report back.

Cheers.
 
Top