CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Increasing precision of Input Capture...

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ELCouz



Joined: 18 Jul 2007
Posts: 427
Location: Montreal,Quebec

View user's profile Send private message

Increasing precision of Input Capture...
PostPosted: Fri Feb 20, 2015 7:01 pm     Reply with quote

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!
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Feb 20, 2015 8:18 pm     Reply with quote

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
ELCouz



Joined: 18 Jul 2007
Posts: 427
Location: Montreal,Quebec

View user's profile Send private message

PostPosted: Fri Feb 20, 2015 8:33 pm     Reply with quote

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 Smile

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!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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