![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
Increasing precision of Input Capture... |
Posted: Fri Feb 20, 2015 7:01 pm |
|
|
Hi,
I've been reading and trying to modify the CCS example (ex_capture.c) to give me frequency instead of period lengths in uS.
However, i'm not very experienced with this kind of area.
I'm trying to read the frequency of a small flow meter (YF-S401)
The equation is according to the flow meters spec is:
Code: |
Frequency: F = 98 * Q (Q is flow L / min) error: ± 5% 5880 pulse per liter of water
Frequency calculation = constant * unit flow (L / min) * time (seconds)
Flow Range :0.3-6L / min
|
I tried converting period to hz but I get garbage values every time...
Code: |
printf("\r\r%1.9f Hz",(((float32)Time*64)/100000));
|
This what I've modified in the example but it's wrong.
I have a scope and the Freq range of the flow meter is 0 to 200 hz
Any clue? _________________ Regards,
Laurent
-----------
Here's my first visual theme for the CCS C Compiler. Enjoy! |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Fri Feb 20, 2015 8:18 pm |
|
|
Are you using the sensor as the input for testing? If so, I wouldn't.
Instead, either use 1/2 wave and full wave line frequency (60Hz and 120Hz, here in Canada, eh !) as two test frequencies OR use a second PIC as the 'frequency generator' with say 25, 50, 100, 150, 200 Hz as outputs on 5 pins.
Simple delay_ms() should be good enough' for test loops.
This way you KNOW what the input is and can then pull your hair out 'getting the math' right.
hth
Jay |
|
![](templates/subSilver/images/spacer.gif) |
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
|
Posted: Fri Feb 20, 2015 8:33 pm |
|
|
temtronic wrote: | Are you using the sensor as the input for testing? If so, I wouldn't.
Instead, either use 1/2 wave and full wave line frequency( 60Hz and 120Hz ,here in Canada,eh !) as two test frequencies OR use a second PIC as the 'frequency generator' with say 25,50,100,150,200 Hz as outputs on 5 pins.
Simple delay_ms() should be good enough' for test loops.
This way you KNOW what the input is and can then pull your hair out 'getting the math' right.
hth
Jay |
I see the value live on my scope and I can tell you it's not good
But I found out that it's better and easier just to count the pulses to know how many mL have passed thru!
Thanks! _________________ Regards,
Laurent
-----------
Here's my first visual theme for the CCS C Compiler. Enjoy! |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|