Maker Pro
Maker Pro

Counting number of pulses

J

JSreeniv

Jan 1, 1970
0
Hi all,

Here is my understanding of counting number of pulses of my project:

Please be patient in my description may looks lengthy..

In this mode(process of number of pulses), we can measure the number
of pulses coming on the input line ‘Pulse_din_0’ within some time set
by the processor. There is one counter ‘CNT_P4P_PC0’ to which
processor will load the time period value, during which number of
pulses have to be counted.

Suppose we want to calculate the number of pulses coming on the input
line ‘Pulse_din_0’ in the duration of 1 second, then processor has to
load the value of ‘0x186A0’ (for the ‘10usec’ time base i.e., actual
time divided by time base will give the count value to be loaded into
counter) to the ‘CNT_P4P_PC0’ counter. Then this counter starts
decrementing at the rate set by the processor and at the same time
PC_0 starts incrementing it count value by 1 on receiving the pulse on
input line each time. This process will be continued till loaded
counter ‘CNT_P4P_PC0’ reaches the value of zero. At the end, if we
read the count value of PC_0 counter, we can get the number of the
pulses arrived on the input line during set time period.

Could anyone give or form an equation of counting number of pulses
(confusing what is Actual time here...) with an example

Please ...response..

J.Sreeniv
Design Engg-FPGA,
MOOG,Inc
 
Hi all,

Here is my understanding of counting number of pulses of my project:

Please be patient in my description may looks lengthy..

In this mode(process of number of pulses), we can measure the number
of pulses coming on the input line ‘Pulse_din_0’ within some time set
by the processor. There is one counter ‘CNT_P4P_PC0’ to which
processor will load the time period value, during which number of
pulses have to be counted.

Suppose we want to calculate the number of pulses coming on the input
line ‘Pulse_din_0’ in the duration of 1 second, then processor has to
load the value of ‘0x186A0’ (for the ‘10usec’ time base i.e., actual
time divided by time base will give the count value to be loaded into
counter) to the ‘CNT_P4P_PC0’ counter. Then this counter starts
decrementing at the rate set by the processor and at the same time
PC_0 starts incrementing it count value by 1 on receiving the pulse on
input line each time. This process will be continued till loaded
counter ‘CNT_P4P_PC0’ reaches the value of zero. At the end, if we
read the count value of PC_0 counter, we can get the number of the
pulses arrived on the input line during set time period.

Could anyone give or form an equation of counting number of pulses
(confusing what is Actual time here...) with an example

Please ...response..

J.Sreeniv
Design Engg-FPGA,
MOOG,Inc

Good Lord. What are you actually trying to do? I've read this a couple
of times over a couple of days and it makes no sense to me - and
apparently anyone else judging by the responses you're getting.
How fast is the pulse rate? How many pulses per count period? Explain
this better.

 
J

John Smith

Jan 1, 1970
0
JSreeniv said:
Hi all,

Here is my understanding of counting number of pulses of my project:

Please be patient in my description may looks lengthy..

In this mode(process of number of pulses), we can measure the number
of pulses coming on the input line ‘Pulse_din_0’ within some time set
by the processor. There is one counter ‘CNT_P4P_PC0’ to which
processor will load the time period value, during which number of
pulses have to be counted.

Suppose we want to calculate the number of pulses coming on the input
line ‘Pulse_din_0’ in the duration of 1 second, then processor has to
load the value of ‘0x186A0’ (for the ‘10usec’ time base i.e., actual
time divided by time base will give the count value to be loaded into
counter) to the ‘CNT_P4P_PC0’ counter. Then this counter starts
decrementing at the rate set by the processor and at the same time
PC_0 starts incrementing it count value by 1 on receiving the pulse on
input line each time. This process will be continued till loaded
counter ‘CNT_P4P_PC0’ reaches the value of zero. At the end, if we
read the count value of PC_0 counter, we can get the number of the
pulses arrived on the input line during set time period.

Could anyone give or form an equation of counting number of pulses
(confusing what is Actual time here...) with an example

Please ...response..

J.Sreeniv
Design Engg-FPGA,
MOOG,Inc

Ok, you've got your two counters:
CNT_P4P_PC0
from your description it has a 10 usec time base
so you load it with ‘0x186A0’ (which is 100000 decimal)
It starts counting down to 0.
When it reaches 0, it will have counted for 1 second.
I assume it will give you an interrupt at this point.

PC_0
From your description, I assume this is connected
to Pulse_din_0 pin. Your external pulses appear here
This counter counts up by 1 with each pulse.
When CNT_P4P_PC0 reaches 0, then 1 second has elapsed
and you should simply read the value of PC_0.
The PC_0 counter will contain the number of pulses
in 1 second. (pulses per second: pps)

Since frequency = pps = Hz then the frequency of the pulse train
can be directly read from your PC_0 counter value.

Reset PC_0 to 0 and reload CNT_P4P_PC0 and do it again, if you want an
average value over a few counts.

There is no equation that I can see, as you can read the frequency of
the pulse train directly from the PC_0 counter.

The problems arrive when you want to count very fast frequency pulse
trains, and then a 1 second gate (CNT_P4P_PC0 = 0x186A0) is too long and
your PC_0 counter will overflow (depends on how many bits in PC_0)

In that case, you will want to reduce the counting window (the gate),
counter CNT_P4P_PC0, to a narrow window of 1ms, for example.

For a 1ms gate: 1ms / 1us = 1000 = 0x3e8 so load CNT_P4P_PC0 with 0x3e8
Reset PC-0 to 0 and start the counter CNT_P4P_PC0. Now, when CNT_P4P_PC0
counts down to 0, you must read PC_0. This value in PC_0 is the number
of pulses in 1ms. Multiply this number by 1000 to get the actual
frequency in Hz (or read it directly, as it will be in KHz).

John.
 
Top