286/317
10 - Second Application: a Sailing Computer
10 SECOND APPLICATION: A SAILING COMPUTER
The aim of this application is to build a calculator for optimizing the steering of a yacht when
going against the wind. In this situation, sailors have to make tacks, that is, sail close to the
wind alternately on the port side then on the starboard side. The problem is to position the boat
the best way. Most sailors rely on they own experience to choose the right angle so that the
projection of the boat speed in the eye of the wind is the greatest possible but it is difficult to
estimate it accurately, because that speed is a combination of the boat speed and the wind di-
rection.
The calculator described here takes into account the boat's speed, as given by the speedom-
eter, the wind speed, using a wind gauge and the relative wind direction, as given by the
weather vane. Using this data, a relatively simple trigonometric computation gives the compo-
nent of the boat speed that is parallel to the real wind direction, called V
mg
, which is what we
need. In addition, the absolute speed and direction of the wind are displayed, as it is useful in
all cases. This is also relevant when sailing before the wind.
In this application, the ST7 peripherals are used as follows:
A timer is used for measuring the period of the digital signal supplied by the speedometer.
This a square signal with a frequency proportional to the speed. The edges of the signal
trigger the timer capture function.
The same timer is used for the wind gauge, that supplies the same kind of signal as the
speedometer; the other capture input is used the same way as above.
The Analog to Digital Converter reads the voltage at the cursor of a potentiometer, whose
shaft is driven by the weather vane. It also reads the push-buttons that are wired so that a
different voltage is produced for each button pressed. In addition, three trimmer
potentiometers provide the necessary calibration values using the Analog to Digital
Converter.
The Serial Communication Interface sends the information to a computer that can display
the situation graphically. This part of the software falls outside the scope of this book and will
not be described here.
The Serial Peripheral Interface connects to a liquid-crystal display using only two wires (not
counting the power supply), so that the display can be placed remotely from the computer's
enclosure.
For this application, the ST72311 is chosen, since it has a built-in Serial Communication Inter-
face. A memory size of 16 Kbytes of ROM is necessary to accommodate the program, and the
512 bytes of RAM are used for a large part of it.
The block diagram is as follows:
Содержание 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 ...