8
\$\begingroup\$

Rt is thermistor. Rb is bias resistor, which value I need to calculate. The temperature that I'm interested in is giving Rt resistance range of 4k...115k. What I want is to scale this to whole ADC resolution, which is 10 bit ie 0...1023. So when Rt = Rb ADC will convert it to 511. Not sure if it's possible, but ideally I would like to get 0 ADC reading when Rt = 4k and 1023 when Rt = 115k (or the other way).

Internally in MC I have lookup table, which will convert ADC value to temperature, according to curve described in thermistor datasheet.

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Why not have a potentiometer so you can change the value? \$\endgroup\$ – Dean Dec 21 '12 at 12:09
  • \$\begingroup\$ Why would I need to change the value for the given parameters and ranges? I think Rb should be very certain value. \$\endgroup\$ – Pablo Dec 21 '12 at 12:19
  • \$\begingroup\$ It would allow you to set the value more accurately, and I wasn't thinking of a POT with a long knob but a preset resistor instead. \$\endgroup\$ – Dean Dec 21 '12 at 12:24
  • \$\begingroup\$ Once I know how to calculate the value of Rb, it's good idea to put preset resistor. \$\endgroup\$ – Pablo Dec 21 '12 at 12:29
7
\$\begingroup\$

If \$R_T\$ lowest resistance is 4k, then you can easily calculate the resistance required to make a voltage divider. If you select an ADC reference voltage from the internal band gap (usually 2V56 or 1V1), you can use almost whole ADC range. Thus (provided \$V_{CC}\$ is constant):

$$ U_{REF} = U_{IN,MAX} = \frac{R_{B}}{R_{B}+R_{T,MIN}} × V_{CC} $$ $$ R_B = \frac{U_{REF}×R_{T,MIN}}{V_{CC} - U_{REF}} $$

And round \$R_B\$ down, so you will never hit full scale on the ADC. Once you have \$R_B\$ you should be able to calculate the lowest input voltage that you can reach. Knowing this is valuable because you can do two sanity checks in your program:

  1. When the ADC-value is (near) 1023, this indicates that the sensor failed short circuit (bad wiring, ...);
  2. When the ADC-value is (near) 0, this indicates that the sensor failed open (not attached, broken wire, ...)

Based on these two checks you can make your program decide what to do: Eg. set an error output high, remove power from a load, ...

Mind you that with this resistive voltage divider, resolution of your measurement will vary widely along the scale.

Eg. with band gap reference set to 1V1 and supply voltage 5V: $$ R_B = \frac{1.1V×4k\Omega}{5V-1.1V}= \frac{4.4k}{3.9}= 1.13k\Omega $$ Rounded down to first available E12 value makes \$1k\Omega\$

$$ U_{IN,MIN} = \frac{1k\Omega}{1k\Omega+115k\Omega}×5V = 43mV $$

$$ U_{IN,MAX} = \frac{1k\Omega}{1k\Omega+4k\Omega}×5V = 1000mV $$

The advantage of using the 1V1 reference is that it is pretty easy to predict an approximate ADC value range: 43 - 1000

\$\endgroup\$
  • \$\begingroup\$ ADC reference voltage is equal to VCC. Do you think average resolution along the scale will make around 1 degree C tolerance? \$\endgroup\$ – Pablo Dec 21 '12 at 12:54
  • \$\begingroup\$ What controller do you use and are you sure you don't want to change to the band gap reference? \$\endgroup\$ – jippie Dec 21 '12 at 13:01
  • \$\begingroup\$ ATMega328P. I thought AVCC reference gives me better resolution. Certainly I can setup to work with 1.1 VBG reference if it would give me better results. \$\endgroup\$ – Pablo Dec 21 '12 at 13:05
  • \$\begingroup\$ Just make sure your Vcc is stable, as it is part of the equation. Of course you can measure Vcc with the same ADC (using a second voltage divider) and correct the measurements for varying Vcc. \$\endgroup\$ – jippie Dec 21 '12 at 13:09
  • \$\begingroup\$ Rb = Constant Current. That will double it's effectiveness, add some linearity to the output, and provide isolation from voltage fluctuations. \$\endgroup\$ – Optionparty Dec 21 '12 at 14:33
9
\$\begingroup\$

With a simple resistive divider, you won't be able to stretch the range of output voltages to cover the full range of the ADC input, but you'll get the best overall resolution by setting your bias resistor to the geometric mean of the minimum and maximum resistance values of your sensor (for the temperature range of interest).

For your specific setup, that would be \$ \sqrt{4K * 115K} = 21.447K \$

You could select a 21.5K 1% resistor or a 22K 5% resistor. The voltages you get will run from 15.7% to 84.3% of the ADC input range.

To get output voltages that cover the full range of the ADC, you'll need an active (e.g., op-amp) circuit that has gain and offset capability.

\$\endgroup\$
  • \$\begingroup\$ your solution also worked. I wish I could accept more than one answer. \$\endgroup\$ – Pablo Dec 21 '12 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.