Example Code

NI myRIO measurement of frequency of a digital signal - with Video.

Code and Documents

Attachment

This simple program uses the FPGA on a myRio to detect the edges of a square-wave and sets a times to measure the period (number of samples between the positive going edges of the waveform). It is accurate from a few Hz up to 80kHz. A video goes with this.

https://www.youtube.com/watch?v=Fz4GIb455YY&feature=youtu.be

fpga.PNG

Top is the FPGA code and below is the host code that runs on the real-time processor.

host.PNG

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
amit_IITP
Member
Member
on

Hello. I have tried this code and also watched your youtube video. I am trying to get the spped from my quadrature encoder. I have converted the frequency code to velocity measurement code as seen in your video. I am getting the reading but it is fluctuating very rapidly in y axis. My motor is running at 1000 rpm and I am getting other rpms along with 1000 rpm in waveform window.  The video of speed measurement is below.

Please help me.

Thankyou

amit_IITP
Member
Member
on

Hello. I have tried this code and also watched your youtube video. I am trying to get the spped from my quadrature encoder. I have converted the frequency code to velocity measurement code as seen in your video. I am getting the reading but it is fluctuating very rapidly in y axis. My motor is running at 1000 rpm and I am getting other rpms along with 1000 rpm in waveform window.  The video of speed measurement is below.

Thankyou

tomnz
Member
Member
on

You could try increasing the sampling frequency. That is probably the problem.

amit_IITP
Member
Member
on

Thank you Tomnz. I will try it.

Contributors