i've installed a oxs in my heli an tryed to get correct values from a rpm-sensor (hall-sensor TLE4905, two magnets on maingear).
Actual i have some problems to understand the code inside oXs_general.cpp
Code: Select all
ISR( TIMER1_CAPT_vect, ISR_NOBLOCK )
{
uint16_t elapsed ;
uint32_t eventTime ;
uint32_t difference ;
if ( ++RpmCounter > 3 )
{
cli() ;
uint16_t time = ICR1 ; // Read timer 1
sei() ;
elapsed = time - lastTimerValue ;
#if F_CPU == 20000000L // 20MHz clock
#error Unsupported clock speed
#elif F_CPU == 16000000L // 16MHz clock
eventTime = TotalMicros + ( elapsed >> 4 ) ;
#elif F_CPU == 8000000L // 8MHz clock
eventTime = TotalMicros + ( elapsed >> 3 ) ;
#else
#error Unsupported clock speed
#endif
//eventTime = TotalMicros + ( elapsed >> 4 ) ;
RpmCounter = 0 ;
difference = eventTime - lastEventTime ;
lastEventTime = eventTime ;
if ( difference > 200 )
{
RpmValue = 4000000 / difference ;
}
else
{
RpmValue = 0 ;
}
RpmSet = true ;
}
}
#endif // MEASURE_RPM
calculate the difference betwen now and the time of the former calculation,
when it is bigger than 200 then "RpmValue = 4000000 / difference".
Why 4.000.000? I've compared the shown value on Taranis screen and a frequence-meter (signal from hall-sensor) and thats (nearly) the same. But not rotations per minute, the value is in Hz.
I've tryed to understand this number, but it's to high for me.
From my point of view this is my favorit code:
RpmValue = 60*1000/(difference)*RpmCounter
Best regards
Christoph (from Germany)