Electronic – FPGA Input Signal measurement

counterfpgaspartanxilinx system generator

How to measure input pulse signal's frequency using xilinx toolkit on matlab?

Since I'm bad at coding,I use System generator on matlab.
I'm doing a project, In which I'll be using a Proximity sensor to measure RPM of a motor. The output of the sensor is put across Schmitt trigger, so it becomes a Pulse Signal.

I need to find the frequency of this pulse signal, So I can calculate RPM.

Best Answer

If you want to measure frequency, you need a reference frequency you can compare it to.

The usual way to do this is to set up two counter chains, one of which is clocked by your reference frequency Fref, and the other clocked by your unknown frequency Funk (input signal conditioning is an exercise left for the student). You let the two counters run for the same amount of time T, then read their values.

$$Count_{ref} = F_{ref} \cdot T$$

$$Count_{unk} = F_{unk} \cdot T$$

Combine the two equations by dividing them, and solve for Funk:

$$F_{unk} = \frac{Count_{unk}}{Count_{ref}} F_{ref}$$

That's the general concept, but in practice, the process is often simplified by using the reference counter itself to determine the time period T, which makes Countref a known constant, and Fref is also chosen to be a "nice round" number. This turns the multiplication and division into trivial operations, and the frequency can be read more or less directly from Countunk. For example, if Fref/Countref = 1 Hz, then Countunk = Funk directly.

There are many subtleties associated with optimizing the performance of this process that I won't get into here, but there's one trick that's often used when you want to measure relatively low frequencies (such as RPM) with high resolution without requiring a long time T. Instead of making T depend on Fref, making Countref constant, you make T depend on Funk, making Countunk a constant. Also, make Fref as high as you reasonably can. Now you need to do a division operation to get the answer, but you can get it in a fraction of a second with many digits of precision.