293/317
10 - Second Application: a Sailing Computer
unchanged when the trimmer is at the center; the values are decreased or increased by 20%
when the trimmer is at one end or the other, respectively.
The trimmers are only read once at power on.
10.2.2 Interfacing the weather vane
The weather vane can occupy any angular position in a full circle. Using a potentiometer with
no mechanical stop, this will translate into a voltage on the slider that ranges from 0 to 100%
of the supply voltage. This voltage can then be fed into the Analog to Digital Converter, pro-
ducing a reading from 0 to 255.
Actually, there are three problems.
The resolution needed is one degree, that is, 360 conversion points.
There is a small angle where the wiper makes no contact.
The potentiometer is set to a rough position when installed at the top of the mast; it is
necessary to recalibrate the reading by electronic means when tuning the system.
The first problem can be solved by providing a numeric-type low-pass filtering of the voltage
read. In any case, the various movements of the boat will add a rather high amount of noise to
the reading that must be filtered out. This filtering involves computing the mean of a certain
number of readings. The effect of doing so is twofold: it reduces the variation speed of the
reading, and it increases the resolution, since the converter's smallest increment is divided by
a certain number. Here, we only need to increase the resolution by a factor of two; thus this is
very easy to perform.
The second problem is easily solved by adding a pull-down resistor from the wiper to the
ground. All readings when the shaft is within that dead angle will read zero.
The third problem is easily solved by adding a certain constant to the reading, then rolling over
any result greater than 360 (that is, taking the value modulo 360). This constant is read from
the Analog to Digital Converter, using a trimmer as above, but the range of the adjustment is
now + or - 45°.
Содержание ST7 Series
Страница 1: ...ST7 8 BIT MCU FAMILY USER GUIDE JANUARY 1999 1 ...
Страница 238: ...238 317 8 C Language and the C Compiler 08 Burn bmp Then use the EPROMer programmer software as described in Chapter 7 ...
Страница 289: ...289 317 10 Second Application a Sailing Computer 10 befor Bs Rw Vw VMG AlphaR AlphaV Before the wind ...