|
|
View previous topic :: View next topic |
Author |
Message |
Calamar
Joined: 07 Sep 2003 Posts: 60 Location: Buenos Aires (Argentina)
|
Tabulation |
Posted: Mon May 29, 2006 7:24 am |
|
|
Someone know how to improve this:
(clock = 10 mhz, pulseTicks = width pulse,
rateFactor = 1 * 2 500 000
or
rateFactor = 60 * 2 500 000
or
rateFactor = 3600 * 2 500 000
or
rateFactor = 86400 * 2 500 000)
Code: | if(timeUnitBuffer != timeUnit)
{
timeUnitBuffer = timeUnit;
switch(timeUnit)
{
case 0:
rateFactor = 250000000.0 / kFactor;
break;
case 1:
rateFactor = 150000000000.0 / kFactor;
break;
case 2:
rateFactor = 900000000000.0 / kFactor;
break;
case 3:
rateFactor = 21600000000000.0 / kFactor;
break;
default:
break;
}
}
rate = rateFactor / (float) pulseTicks;
if( rate > 99999.0 )
sprintf(strLineB," 99999 %s/%c", strVolumeUnit[volumeUnit], strTimeUnit[timeUnit]);
else
if( rate >= 1000.0 )
sprintf(strLineB," %5.0f %s/%c",rate, strVolumeUnit[volumeUnit], strTimeUnit[timeUnit]);
else
if (rate >= 100.0)
sprintf(strLineB," %3.1f %s/%c", rate, strVolumeUnit[volumeUnit], strTimeUnit[timeUnit]);
else
if (rate >= 10.0)
sprintf(strLineB," %2.2f %s/%c", rate, strVolumeUnit[volumeUnit], strTimeUnit[timeUnit]);
else
if (rate > 0.0009)
sprintf(strLineB," %1.3f %s/%c", rate, strVolumeUnit[volumeUnit], strTimeUnit[timeUnit]);
else
sprintf(strLineB," 0 %s/%c", strVolumeUnit[volumeUnit], strTimeUnit[timeUnit]);
} |
_________________ Best Regards
Daniel H. Sagarra
La Plata (Argentina) |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon May 29, 2006 3:41 pm |
|
|
Tell us what your goal is, or what your project is about.
Also, Microchip floating point only has about 7 digits of resolution.
I'm not sure, but it looks like you may be assuming that it has 15
digits of resolution. |
|
|
Calamar
Joined: 07 Sep 2003 Posts: 60 Location: Buenos Aires (Argentina)
|
|
Posted: Mon May 29, 2006 4:58 pm |
|
|
I'm currenty using a capture module to measure
frecuency (10Mhz clock), the resolution requiered
is 0.1Hz, range 1.0 - 999.9 Hz --> 5 digits
Code: | #INT_TIMER3
void tmr3_isr()
{
rollOver++;
if(rollOver == 20) pulseTicks = 0;
}
#INT_CCP2
void ccp2_isr()
{
static int16 startTime, endTime;
endTime = CCP_2;
pulseTicks = ( 0x10000 * rollOver ) - startTime + endTime;
startTime = endTime;
rollOver = 0;
} |
f = 2 500 000 00 / pulseTicks
^
|---------- Frecuency scaled * 100
but..... the measure could be represented in: seconds, minutes, hours, days
f = f * 1 or
f = f * 60 or
f = f * 3600 or
f= f * 86400
after that I divide f by kFactor (int32 type it was scaled by 100)
r = f / kFactor
(rate = frecuency * 100 / factor * 100)
now what I want is a right tabulation with 5 digit for any value of r,
for example
17456
1344.3
785.31
34.444
1.3546
0.0008 _________________ Best Regards
Daniel H. Sagarra
La Plata (Argentina) |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon May 29, 2006 5:45 pm |
|
|
Quote: | I'm currently using a capture module to measure frequency |
Normally, a tachometer displays the speed in RPM (revolutions per minute).
Why do you care about seconds, hours, and days ?
Is this a tachometer project ? What device are you measuring ? |
|
|
Calamar
Joined: 07 Sep 2003 Posts: 60 Location: Buenos Aires (Argentina)
|
|
Posted: Tue May 30, 2006 5:54 am |
|
|
it's a flow computer, the signal
may come from a few diferents
types of sensors: TTL/CMOS, HALL,
COIL, take a look at:
http://www.fluidwell.com/f010.html?fseries _________________ Best Regards
Daniel H. Sagarra
La Plata (Argentina) |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|