311/317
10 - Second Application: a Sailing Computer
The three calibration parameters are read from the position of the three trimmers. The three
voltages are read and converted into the proper numeric values to work appropriately when
used in the calculations. These parameters are produced by the following function:
void InitCalibration ( void )
{
ADCSR = ( 1 << ADON ) | WIND_CALIB_CHANNEL ;
while ( ( ADCSR & ( 1 << COCO ) ) == 0 ) ;
/* Wait for end of
conversion */
WindFactor = ( ( ( (float)ADCDR - 128.0 ) / 640.0 ) + 1 ) *
NOMINAL_WIND_FACTOR ;
ADCSR = ( 1 << ADON ) | BOAT_CALIB_CHANNEL ;
while ( ( ADCSR & ( 1 << COCO ) ) == 0 ) ;
/* Wait for end of
conversion */
BoatFactor = ( ( ( (float)ADCDR - 128.0 ) / 640.0 ) + 1 ) *
NOMINAL_BOAT_FACTOR ;
ADCSR = ( 1 << ADON ) | VANE_CALIB_CHANNEL ;
while ( ( ADCSR & ( 1 << COCO ) ) == 0 ) ;
/* Wait for end of
conversion */
VaneAdjust = ( (signed char)ADCDR - 128.0 ) / 4 ;
}
The first two parameters vary from one end of the trimmer to the other end from 0.8 to 1.2
times the nominal calibration parameter. The second varies from -32 to +32 which represents
-45° to +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 ...