Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

RPM using a quadrature encoder

Solved!
Go to solution

I am using a quadrature encoder (CPR = 1024) to measure the rpm of a motor. For data acquisition, I use NI USB-6210. I am using one of the example VIs on LabVIEW to acquire signals from the encoder and have confirmed the physical location of the z-index. What I need help with is the way I am calculating the motor RPM. I use 'change in encoder angle per unit change in time' to give me the speed of the motor. This works fine except when the z-index resets the encoder angle to zero. How do I avoid this issue?

 

Thanks,

lza

Download All
0 Kudos
Message 1 of 14
(440 Views)

If all that you need is rpm using a quadrature encoder, use the DAQmx CI Velocity Angular

santo_13_0-1721422884968.png

santo_13_1-1721422942433.png

It will readback the value in rpm, it would ignore the Z-index.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 2 of 14
(428 Views)

Thank you for your suggestion, Santhosh. But I need both the RPM and the z-index enabled. What changes can I make in the existing program to continuously get the correct values of RPM?

 

-lza

0 Kudos
Message 3 of 14
(384 Views)

I misunderstood the comment initially, but I got it now. For reference, this page explains it well: https://forums.ni.com/t5/Example-Code/Measure-Angular-Position-and-Velocity-with-a-Single-Counter-an....

 

Thanks,

lza

0 Kudos
Message 4 of 14
(381 Views)

@laz_2331 wrote:

Thank you for your suggestion, Santhosh. But I need both the RPM and the z-index enabled. What changes can I make in the existing program to continuously get the correct values of RPM?

 

-lza


I am not expert at counters, I would wait for Kevin to share his wisdom.

In the meantime, if possible, I will connect the encoder to two counters, and set up the first counter for angular position and the other for angular velocity. This way, you get RPM and position simultaneously, but use twice the resources.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 5 of 14
(377 Views)

The link that I shared in my earlier post explains acquiring the angular location (z-index enabled) and simultaneously calculating RPM using one counter. In my initial attempt, shown in the VI attached with the first post, I was able to do the same. However, the problem remains: whenever the z-index resets the angle from, say, 359 to 0, the change in angle (delta theta) is -359deg which creates an erroneous dip in the RPM value. I am planning to control the RPM using a PID controller. This dip/spike would create troubles there. 

0 Kudos
Message 6 of 14
(336 Views)

I am now using NI 9361 Counter Input Module with cDAQ 9178. For this module, the correct terminals for Ctr 0 are: A-PFI0, B-PFI4, Z-PFI-7, and those for Ctr 1 are: A-PFI1, B-PFI5.

 

I wrote two separate VIs, one for angle measurement (CI-angular-encoder) and the other one for rpm (CI-angular-velocity). When I run them separately, they work fine, but once I run the two tasks inside the same VI, I get an error: "Error -50103 occurred at DAQmx Start Task.vi:7220003. The specified resource is reserved. The operation could not be completed as specified."

 

What do I need to do differently?

0 Kudos
Message 7 of 14
(327 Views)

@laz_2331 wrote:

I am now using NI 9361 Counter Input Module with cDAQ 9178. For this module, the correct terminals for Ctr 0 are: A-PFI0, B-PFI4, Z-PFI-7, and those for Ctr 1 are: A-PFI1, B-PFI5.

 

I wrote two separate VIs, one for angle measurement (CI-angular-encoder) and the other one for rpm (CI-angular-velocity). When I run them separately, they work fine, but once I run the two tasks inside the same VI, I get an error: "Error -50103 occurred at DAQmx Start Task.vi:7220003. The specified resource is reserved. The operation could not be completed as specified."

 

What do I need to do differently?


"Resource is reserved" means you don't have enough counters to setup two CI-angular tasks.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 8 of 14
(324 Views)

The spec sheet says that this module can be used for the velocity and position of the quadrature encoder. https://www.ni.com/docs/en-US/bundle/ni-9361-specs/page/specs.html

 

 

0 Kudos
Message 9 of 14
(318 Views)

@laz_2331 wrote:

The spec sheet says that this module can be used for the velocity and position of the quadrature encoder. https://www.ni.com/docs/en-US/bundle/ni-9361-specs/page/specs.html

 

 


Absolute, you can, but it did not state that you can have two instances of them.

 

Let us consider this analogy: you have a car at home, and both you and your partner can drive the car, but not both at the same time because there is only one car, and resources are constrained. 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 10 of 14
(309 Views)