Frequency measurement using PSoC1

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 Can someone tell how do I measure frequency of a incoming sine wave using PSoC 1. I'm following the given procedure given by Dana.

   

At the most basic level you need a gate of known width in time, 

   

and a counter that starts counting when gate is active (high), 
from a known value (255 8 bit,  65535 16 bit), and stops counting
when gate goes low. You read the value of the counter, subtract 
it from start value, and divide by gate period in seconds.

   

16 bit example, .1 sec gate period, f = (65535 – count value) / .1

   

To setup Gate

   

1) Timer, setup for .1 or 1 sec (resolution would be 10 Hz or 1 Hz
respectively). You set up period to be 2X desired gate period, and
compare value 1/2 period, so that high time of compare output =
gate period, low time = gate period.

   

2) Route timer compare out to counter enable.

   

To setup counter

   

1) Route pin, Fin, to counter clock

   

2) Route timer compare out to counter enable

   

Code

   

1) Load counter with its max allowed value, 255 for 8 bit, 65535 for
16 bit

   

2) Start counter

   

3) Enable timer ISR, on terminal count, that means gate is low, counter
not enabled to count

   

3) Start timer

   

When ISR occurs set a flag and return

   

1) If flag true read counter (gate is low so it is not enabling counter)
and compute frequency. Reload counter with its max value.

   

There are other optimizations that can be done, for example stop and reset
timer when ISR occurs so that gate low period is minimized, and measurement
frequency is increased.

   

If the frequencies you are measuring are very low, like less than 1 Hz,
use reciprocal counter technique.

   

 

   

 

   

But I'm unable to comprehend that how do I write the ISR on terminal count.

   

Any help would be appreciated

   


Thanks

0 Likes
6 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

When you type "frequency measure PSoC1" into the "Keyword Search" field at top of this page, yofind at least this appnote.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Here is a couple of approaches you can use for freq measurement ,

   

attached.

   

 

   

Regards, Dana.

0 Likes
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

The other approach, attached.

   

 

   

Regards, Dana.

0 Likes
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Sorry, not paying attention to the fact you are working with PSOC 1.

   

 

   

Here, attached, is a PSOC 1 solution.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

Hi,

   

I am using this code for CY8C28623-24LTXI chip and using CY8CKIT-001 kit. But when I program the kit, I am not able to see any display. Can you please help me with it.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

This might be useful to you -

   

 

   

   

 

   

Regards, Dana.

0 Likes