LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Recording the time it takes for a counter to increment up to 9999 pulses and then resetting the counter and timer to zero and repeating the process

Hello everyone,

 

I am quite new to LabVIEW and still learning how to navigate in it.

I am working on a code in LabVIEW FPGA to measure the speed of an induction machine in RPM.

I am using an incremental encoder attached to the shaft of the machine. The encoder has a resolution of 1000 pulses/revolution.

I am getting three signals from the encoder (A,B and Z) however I only intend to use one signal to obtain the pulses that  I need to calculate the speed in rpm. I am however using all three pulses to obtain the rotor angle position (this section of the code works fine).

 

For the speed measurement, I would like my code in LabVIEW FPGA to do the following:

 

*Increment the counter when a rising edge has been detected on the input signal (A) which comes from the incremental encoder.

* I would like to count 9999 pulses, after which, the counter should be reset to zero and start counting up again on the next rising edge.

*Keep track of the time when the counter starts incrementing on the very first rising edge.
* Reset the timer when the counter has reached 9999 pulses and start the timer again as the counter starts incrementing to collect the next bunch of 9999 pulses .
So basically I would like to know the time it takes to count 9999 pulses, be it in form of milliseconds/ microseconds or ticks.

After obtaining the time and pulses counted in each instant, I would like to calculate the speed in rpm.


I reckon this should somewhat be simple but I just can't seem to get the timing part of the code working. I have however managed to sort out the counter part of the code.

I'm using the PXI-7813R FPGA card and LabVIEW FPGA 2018 version. I have attached the code that I am working on. 

 

Thank you.

Download All
0 Kudos
Message 1 of 3
(1,126 Views)

Hello,

 

judging from the picture of your FPGA code, it looks fine. The main problem: you are probably not fast enough to read out the max. value of "Elapsed time" in your host VI. Transfer only the max value of elapsed time to your host and do this using a FIFO, similar to this sceenshot (cannnot show the the FPGA code, that module is not installed on the laptop I'm currently using:

JensG69_0-1621959701702.png

Regards, Jens

 

 

Kudos are welcome...
0 Kudos
Message 2 of 3
(1,089 Views)

Hello Jen,

 

Thank you for your response.

I have managed to obtain the elapsed time and the number of counts that I need to capture and I do get the corresponding speed. However, at the instant when the counter and timer resets to zero, there are spikes in the speed (basically a pulse that drops to zero and then shoots back up to the desired speed). This is clear that it is a result of the counter and timer resetting to zero. I suppose I need to figure out how I can get rid of those pulses in the speed at the instant when the counter and timer resets. Does someone has an idea of how to go about this? Thank you.

0 Kudos
Message 3 of 3
(1,040 Views)