291/317
10 - Second Application: a Sailing Computer
They apply for Alpha ranging from zero included to 360° excluded. The angles are counted
clockwise, according to nautical usage.
10.2 INTERFACING THE MEASUREMENT DEVICES
There are three measurement devices to interface: the speedometer, the wind gauge and the
weather vane. The first two work on the same principle: they close a switch periodically, at a
frequency that corresponds to the speed. The weather vane is attached to the shaft of single
turn potentiometer without mechanical stops.
10.2.1 Frequency-type devices: speedometer and wind gauge
Since these devices work on the same principle, they will be interfaced the same way; the only
difference will come from their different calibration coefficients.
10.2.1.1 Interfacing the speedometer
The speedometer used, which is a typical one, supplies a square signal with a frequency of
7.5 Hz per nautical knot (a knot is a speed of 1.852 km/h). The range of speeds measured is
within 0.1 to 20 knots, that is 0.75 Hz to 150 Hz and the required accuracy is + or -0.1 knot.
At the bottom of the range, the frequency is only 0.75 Hz. Measuring this frequency with suffi-
cient accuracy would mean taking one measurement every three seconds or more. This is
much too slow for practical use. Thus, instead of measuring the frequency directly, we shall
measure the period of the signal. This will allow us to perform at least one measurement every
1/0.75 = 1.33 s, for the lowest speed; this pace may increase at higher speeds.
The easiest way to perform this measurement is by using the input capture of a 16-bit timer.
On each capture, the contents of the free-running counter is copied into the capture register.
This generates an interrupt request, that is served by an appropriate service routine.
The difference between the current value and the previous value gives the period in the timer's
ticks units. If the new value is less than the old one, this means that the free-running counter
has overflowed, and the calculation formula must take this case into account. To achieve the
required accuracy, a clocking frequency of at least 30 kHz is required, so as to produce a
count of 200 points or more at the highest speed, meeting the required resolution of 0.1 knot.
10.2.1.2 Interfacing the wind gauge
The wind gauge works exactly the same way, but with different values: the frequency is 1.28
Hz per nautical knot. The range of speeds measured is within 1 to 80 knots, that is 1.28 Hz to
102.4 Hz, and the required accuracy is + or -5% knot.
Содержание 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 ...