- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi frnds
i am using two counters for measuring freuency, one counter for 1 sec generation, another counter for counting pulses,
after every one sec interrupt generate.
now the problem is after 1 sec it does not give exact value
eg. if i take 10--->10,for 100-->98,for1000--->992,for 10000--->99960
why it come like this,plz help?
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A number of issues involved -
1) Don't use ISR from timer to read counter, it is not a synchronous process.
2) Set timer for 2 sec, 50% duty cycle, and route compare output to the counter
enable. When gate is low, for 1 sec, read counter, then update counter
to its max value. When gate is high, for 1 sec, counter will be counting. Repeat
this cycle in code. You can use Timer compare out and route it to a pin, and set
pin to ISR on - edge (of the compare output), to indicate when to read and reload
counter.
3) There are row in routes, timer and counter routes, that have synch settings.
I have found if I want max count frequency to turn these off. But I suggest ex-
periment with these settings.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Note, when you read counter you have to subtract it from max count val,
to get counts, or Freq, example if a 16 bit counter subtract it from 65535,
eg. 2n - 1.
Additionally, if you care about absolute accuracy, use an external clock
for PSOC with target accuracy you want to achieve. That controls gate
time accuracy, hence precision. PSOC clock is accurate to only 2.5%.
Some ap notes that may be useful, attached.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i take vc1=12;vc2=13;vc3=153; so frequency come =1006;
so, one counter period =1006,another counter period =65535;
any changes occur in aboveselecting parameters
plz attach eg.code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i dont understand an2283
plz post another example
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thank you very much dana
i want to count 1sec pulses, so tell me period value and vc1,vc2,vc3 for test frequ16
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If the frequency you are measuring is 100 Hz or less you want to consider reciprocal
counting technique. If you are referring to counting pulses for 1 sec, in other words
a one second gate time, then the project settings for VC1/2/3 already take care of that.
You can use the project for measuring < 100 Hz, and measurement times will be
very long. For example if you needed to measure .001 Hertz, then min measuring gate
time would be 1000 seconds. Bigger consideration is accuracy. Thats why reciprocal
method more appropriate for very low freq signals.
So what is the freq range you are trying to measure, what measurement resolution do
you want, and what accuracy ? 3 crucial design questions to answer.
Lastly VC1/2/3 are project dependent. If the reason for these clocks is for gate only, then the
product of all the divisors must meet N = Fcpu / Fgate = VC1 x VC2 x VC3 x Gate timer divisor.
So if Fcpu = 24 Mhz, Gate = .5 Hz (1 sec gate), then N = 24000000 / .5 = 48000000. But if you
have other project needs you may choose to set VC1/2/3 to other values, and adjust total N
with Gate timer divisor.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ok tell me about reciprocal type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content