System Features
VL-EPICs-36 Reference Manual
25
while
(
keypressed
!=
ESC
)
{
if
(
kbhit
())
{
keypressed
=
getch
();
}
/* Read FanTach1 LSB first, latches MSB. */
outp
(
Bindex
,
FANTACHREG
);
//Fantach 1 LSB
FTraw
=
inp
(
Bdata
);
outp
(
Bindex
,
FANTACHREG
+
1
);
//Fantach 1 MSB
FTraw
+=
inp
(
Bdata
)
<<
8
;
/* FTraw now contains the number of 90KHz pulses it took to find 5 tach edges.
(5 edges = 2 tach pulses = 1 revolution) */
/* Convert Raw to RPMs...
RPM = 1 / (FTraw * 11.11uS / 2) * 60 */
fanRPM
=
FTraw
*
0.00001111
;
fanRPM
/=
2
;
fanRPM
=
1
/
fanRPM
;
_settextposition
(
4
,
1
);
if
(
fanRPM
>
0
)
{
printf
(
"FanTach 1: %5.0fRPMs \n"
,
fanRPM
*
60
);
delay
(
100
);
}
else
{
printf
(
"FanTach 1: Stalled! \n"
);
delay
(
100
);
}
}
exit
(
0
);
}