299/317
10 - Second Application: a Sailing Computer
able pins is not sufficient. This is not the case here, as far as parallel ports are concerned,
however a restriction lies in the fact that the display board is connected to the main board
using a 9-pin connector. To overcome this problem, a different approach has been chosen.
The push-buttons are connected to a voltage divisor made of four resistors; one node is con-
nected to pin PD0, which is configured as an analog input. When no button is pressed, the
voltage at PD0 is +5V. When the three buttons are pressed in sequence, the voltage falls to
the values 2.5 V, 2 V, or 1.25 V, depending on the button pressed. These voltages, once con-
verted, yield the values 255, 127, 101, and 63.
By comparing these values against three thresholds at, for example, 192, 114 and 82, it is
easy to determine whether a button is pressed, and which one. This principle can be extended
for more buttons if necessary.
10.3.3 LED circuit
Each display has a pair of LEDs as an indication of whether the reading is absolute or relative.
The red LED of the pair is lit when the open-drain output that drives it is on. When off, the
green LED is lit as it is in parallel with the red one, but with a diode in series that provides an
additional threshold voltage. To provide enough current, the high-current open-drain outputs
PA4 to PA6 are used.
10.4 INTERFACING THE OPTIONAL PERSONAL COMPUTER
The definition of this project includes the capability to interface a portable personal computer
so that the diagrams above can be drawn on the screen in real time, or the data can be logged
for later analysis. In either case, the same data can be sent to the computer: the raw speed
and direction measurements, the corresponding absolute speeds and direction, and the VMG.
The data are sent on the computer's request. Various commands allow the computer to select
the data it wants. These are:
Parameter Command
Format of
data sent
Range Units
raw boat speed B XX.X 0.0 to 199.9 knots
raw wind speed W XX.X 0.0 to 199.9 knots
raw wind direction D XXX 0to360 degrees
relative wind speed w XX.X 0.0 to 199.9 knots
relative wind direction d XXX 0to360 degrees
VMG V XX.X 0.0 to 199.9 knots