[time-nuts] uC ADC resolution (was: Poor man's oven)
Poul-Henning Kamp
phk at phk.freebsd.dk
Sat Jun 10 19:06:29 UTC 2017
--------
In message <3897C09A-D76C-474C-8907-9EA25F8C3451 at n1k.org>, Bob kb8tq writes:
>The “limited range” part of it is why the op-amp makes so much
>sense. If the ADC can “see” +/-10C that’s way more than will ever be useful.
Most uC's have a pile of mux'ed ADC inputs, so do all of the above:
AI0 = Full range
AI1 = +/- 10C
AI2 = +/- 2C
A big upside to this is that you will not need to invent heuristics
for clamped inputs in your PI(D) controller, something which is a bit
harder than most people realize.
Assuming a 10-bit ADC, the code will look something like this:
double
get_temp(void)
{
T = read_AI2();
if (T > 50 && T < 975) {
T += T2_offset;
T *= T2_scale;
return (T);
}
T = read_AI1();
if (T > 50 && T < 975) {
T += T1_offset;
T *= T1_scale;
return (T);
}
T = read_AI0();
if (T > 50 && T < 975) {
T += T0_offset;
T *= T0_scale;
return (T);
}
abort("You have problems...");
}
--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
More information about the Time-nuts_lists.febo.com
mailing list