Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Two Counter inputs to measure speed of motor

Solved!
Go to solution

Hello, 

 

I am trying to measure the speed of a motor using an optical encoder using a PCIe-6343 device. The encoder has only A,B channels with 2x360 Pulses Per Revolution. I plan to use counters to measure the rising and falling edges of both A and B signals giving me 4x resolution. I went through the example programs for counter input. Most of them require an external clock from the encoder. My encoder has no external clock. Second, they calculate duty cycle etc which is not relevant to me. Can anyone point me to examples/resources in the right direction? 

 

 

0 Kudos
Message 1 of 6
(173 Views)

The A and B outputs typically provide a quadrature signal so the speed AND direction can be determined and should be used as such. I think it would be misguided to expect higher precision by doing a convoluted analysis of the transitions. The rotation speed is determined by the pulse frequency.

 

The encoder resolution determines the resolution in angular precision (i.e. not in rotation speed). 

Message 2 of 6
(137 Views)

Hello altenbach, 

 

Thanks. I see what you mean. So, you are suggesting the use any one of the channels to determine the pulse frequency. How do I go about doing that? Doesn't the pulse frequency rely on 0/5V transitions? Is it better to use an event counter? 

 

 

0 Kudos
Message 3 of 6
(126 Views)
Solution
Accepted by yezdi777

You can use a buffered counter task. An additional counter is required to generate the sample clock.

You can then use the known sample clock rate to calculate the speed.

Freq, Hz = [(position in index N+1) - (position in index N)]/360*sample_rate

-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
Message 4 of 6
(93 Views)

Hi ZYOng, 

 

Thanks for the idea. This makes sense. Just to confirm my understanding, I am not required to physically connect the generated sample clock to my device. You start a dummy counter just to set the sample clock for timing the samples. Right? 

0 Kudos
Message 5 of 6
(73 Views)

@yezdi777 wrote:

Hi ZYOng, 

 

 Just to confirm my understanding, I am not required to physically connect the generated sample clock to my device. You start a dummy counter just to set the sample clock for timing the samples. Right? 


The sample clock will be routed internally. No external connection is required.

-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
Message 6 of 6
(58 Views)