Instrument gain and offset settings
Archiver
Posts: 46,084
Hi all,
Still working on my altimeter project. I was wondering how best to
implement a gain and offset setting into the program in order to take
care of imperfections in the circuitry and in weather. The program
I'm following as an example is located here:
http://www.qsl.net/xq2fod/Electron/Vario/vario.html
This design has a gain and offset setting, but because of my lack of
knowledge of circuits, I can't really understand what's happening in
the program. Plus, this design reads in meters and seconds, and
although I'm all for the metric system, it would be beneficial to read
in feet (plus other people want that). Basically, I'm trying to write
my own version of software rather than copy someone else (and
understand what is actually happening).
The gain is for taking care of circuit imperfections. The
mentioned design uses a word size value to represent the gain. The
offset is the altitude when the instrument is first turned on so that
it has a starting reference and to take care of variations in the
weather.
I realize this is probably a hard question, but I'm hoping there
are people out there who know this. I could ask the guy who made the
program, but I've already bugged him enough times and I don't want to
wear out my welcome. Thanks for the help!
David
Still working on my altimeter project. I was wondering how best to
implement a gain and offset setting into the program in order to take
care of imperfections in the circuitry and in weather. The program
I'm following as an example is located here:
http://www.qsl.net/xq2fod/Electron/Vario/vario.html
This design has a gain and offset setting, but because of my lack of
knowledge of circuits, I can't really understand what's happening in
the program. Plus, this design reads in meters and seconds, and
although I'm all for the metric system, it would be beneficial to read
in feet (plus other people want that). Basically, I'm trying to write
my own version of software rather than copy someone else (and
understand what is actually happening).
The gain is for taking care of circuit imperfections. The
mentioned design uses a word size value to represent the gain. The
offset is the altitude when the instrument is first turned on so that
it has a starting reference and to take care of variations in the
weather.
I realize this is probably a hard question, but I'm hoping there
are people out there who know this. I could ask the guy who made the
program, but I've already bugged him enough times and I don't want to
wear out my welcome. Thanks for the help!
David
Comments
wrote:
> Hi all,
> Still working on my altimeter project. I was wondering how best
to
> implement a gain and offset setting into the program in order to
take
> care of imperfections in the circuitry and in weather. The program
> I'm following as an example is located here:
>
> http://www.qsl.net/xq2fod/Electron/Vario/vario.html
>
> This design has a gain and offset setting, but because of my lack of
> knowledge of circuits, I can't really understand what's happening in
> the program. Plus, this design reads in meters and seconds, and
> although I'm all for the metric system, it would be beneficial to
read
> in feet (plus other people want that). Basically, I'm trying to
write
> my own version of software rather than copy someone else (and
> understand what is actually happening).
> The gain is for taking care of circuit imperfections. The
> mentioned design uses a word size value to represent the gain. The
> offset is the altitude when the instrument is first turned on so
that
> it has a starting reference and to take care of variations in the
> weather.
> I realize this is probably a hard question, but I'm hoping there
> are people out there who know this. I could ask the guy who made
the
> program, but I've already bugged him enough times and I don't want
to
> wear out my welcome. Thanks for the help!
>
> David
Hi David,
hope you don't mind but I used your post to detail some stuff in a
beginners sort of way. I'm assuming you have most of this covered,
but everybody may not.
One thing is that regardless what you do in software, often the
output is 0-5 volts and nothing else. not to be blunt, but meters
per hour as a 0-5 volt signal can be considered mm per second or
inches per minute, or pretty much any reading (prasec's per light
year?). all that changes is what 5 volts means. Any conversion
program would show that if it were 1 meter per minute, it could also
be about 39 inches per minute. see where I'm going ?
That said, gain will allow you to adjust that 5.0000 volts to exactly
1.0000 meters per minute, or with a tweak, to 40.000 inches per
minute to use a different unit with something you like to see better.
I might be wrong, but what I see most often are the terms zero and
span. Offset might also be zero. Gain, might be span.
Here is an odd case. Say you have a temperature sensor that is
sending out a signal of 0-5 volts linear to 0 to 212 degrees F.
and you want to convert that to 0 to 100 deg C.
since 0-5 is the output, we could label it 0 to 212 deg F or -17 to
100deg C. the only change is the label. In software the calculation
could be the same or different, but the results would be identical.
The reading would start at -17.7 deg C so that is no good for 0 to
100C.
You could set the offset so as to start at -.8 volts. that way, at
zero volts, the reading was 0 deg C or 32 deg F.
A word of caution, is that changing one value will often change the
other, so you need to go back and check them few times.
A tip is that a span change of a value is often a zero change of 1/4
that value. say you got -4 deg and 100 deg. then set to 0, 100
would move up to maybe 16, so you bring that down to 100 and zero
becomes -3 you follow with 115 / -2 / 110 /-1 / 105 / -.5..... see
how that can be a PITA ? if you note down the interaction, you
should be able to predict where the best setting would be to get the
other close. in this case, if you set to say, 140, it might bring
the zero up to 10, so you bring that back to 0 and get 101, or
something really close.
I really rounded off the math, but I hope this gives you an idea.
Also, there are a bunch of places you can do this. the best is in
the raw signal if possible. then an op-amp before the ADC, then
scaling of the ADC signal, and so on, the closer you get to the
output, the greater the error may be introduced. the closer to the
raw signal, the higher the resolution may be.
staying with temperature, an RTD may offer a 0 to 100 degree range,
figure that to an ADC. a Thermocouple may offer a 2,000 degree
range. figure 1% error so, 1% of 2,000 is 20 degrees off the bat.
or divide 2,000 by 256 and you 7.81 degrees per step change. see how
the raw sensor error effect output ?
Dave
It is an interesting design, using an RC scheme with exponential
charging to give a pulse width proportional directly to altitude,
rather than pressure. I agree that the circuit and the program are
hard to follow, but pretty clever.
When p9 turns from a high output into an input, it starts a sequence
that generates a delayed pulse on p8, which the program measures with
a PULSIN command. (Seems to me that p9 should be inited high at the
top of the program, but it is hard to follow.) It takes 6 readings
in a row and comes up with an average of the six. Then it does a
little double precision math to multiply times the gain factor. The
component values were chosen so that the numbers returned by the
PULSIN command should be altitude directly in meters. What the
double precision math does, essentially, is multiply the number that
comes out of the PULSIN times the fraction, gain/32768. So a
"gain" of 32768 is really a correction factor of *1. That would mean
that the component values of the timing resistor and capacitor and
the sensor output are right on their factory nominal specs. If the
component tolerances are off nominal (most likely), then you might
end up with, say, gain=31000, which would be a correction factor of
31000/32768. The program burns the gain into eeprom during the
calibration, so you only have to set it once. The offset factor is
simply added in, to set your takeoff or landing altitude.
It might be that you could make the timing resistor variable, and do
the calibration in hardware, instead of firmware, but that would take
some back-of-envelope calculations to choose the needed adjustment
range.
You could build the project exactly as shown there, and stick with
the program as written to get meters. Then convert meters to feet if
that is the big gripe. 1 meter = 3.281 feet. In Stampese:
feet = (meters * 3) + (meters ** 18405)
meters = feet ** 19975
(0.281 = 18405/65536)
He says the pressure sensor he used is obsolete, and he suggests the
motorola MPX4100A as a substitute, but he doesn't say much about
attendant changes. It doesn't matter too much, as that should come
out in the wash during calibration, so long as they are not too
different.
I hope that helps a little bit. Thanks for the URL reference.
That's an interesting site overall.
-- Tracy
>Hi all,
> Still working on my altimeter project. I was wondering how best to
>implement a gain and offset setting into the program in order to take
>care of imperfections in the circuitry and in weather. The program
>I'm following as an example is located here:
>
>http://www.qsl.net/xq2fod/Electron/Vario/vario.html
>
>This design has a gain and offset setting, but because of my lack of
>knowledge of circuits, I can't really understand what's happening in
>the program. Plus, this design reads in meters and seconds, and
>although I'm all for the metric system, it would be beneficial to read
>in feet (plus other people want that). Basically, I'm trying to write
>my own version of software rather than copy someone else (and
>understand what is actually happening).
> The gain is for taking care of circuit imperfections. The
>mentioned design uses a word size value to represent the gain. The
>offset is the altitude when the instrument is first turned on so that
>it has a starting reference and to take care of variations in the
>weather.
> I realize this is probably a hard question, but I'm hoping there
>are people out there who know this. I could ask the guy who made the
>program, but I've already bugged him enough times and I don't want to
>wear out my welcome. Thanks for the help!
>
>David
http://geocities.com/SiliconValley/Orchard/6633/altimeter.html