LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Linear encoder

Solved!
Go to solution

Hi All

 

I want to record the position(rotation) signal. If there are 1024 pulse per revolution, I want the position signal to increase linearly(1023,1024,1025......). Shall I use Linear encoder or Angular encoder (From DAQmx creat virtual channel).

 

I am using NI-9411.

 

Thank you!

0 Kudos
Message 1 of 33
(6,527 Views)

Hi lvymerciqq,

 

 

For Devices without Counters:
Your module, the NI-9411 doesn't have any on board counters, so unfortunately you cannot use counter functions such as the Linear/Angular encoder DAQmx channel VIs. If you're using a Compact RIO, you can make use of Counters for the device via the use of Scan Mode (You can see this in the NI Example Finder). However, if you're using a Compact DAQ then there are no Counters to make use of so we'd have to implement our own methods in order to clock the signals. For now, I'd think that this application would be limited by being software driven (i.e. making the OS check that a rising edge has occured) however I'm going to do some research and see whether or not there are other possibilities that can be explored; however it won't consist of such a simple solution as just dropping down a single polymorphic VI.

 

 

For Devices with Counters:

You can configure a Counter task to count the number of rising edges recieved from the encoder; therefore this number will increment on every increased rotation of the encoder. You'll have to be careful with respect to this number rolling over, however. This is when you reach the maximum count of your counter task and then it resets back to 0; this changes from device to device as different counters have different resolutions.


Alex Thomas, University of Manchester School of EEE LabVIEW Ambassador (CLAD)

0 Kudos
Message 2 of 33
(6,506 Views)

Thank you Alex.

 

I am using Ni cDAQ-9174 chasis and NI9411. And there are 4 counters(Form the chasis?)Could you please recommend some doc to learn more about the counter and encoder?

Another thing, I am using 2 method to get the position. One is the linear encoder and the other one the count the rising edge. what's the resolution of those two counters? 32bits? I can't simulation counter with MAX. Could you please recommend a way to do the counter simulation?

 

Thanks and Have a nice day

3.png

4.png

0 Kudos
Message 3 of 33
(6,494 Views)

Hi again lvymerciqq,

 

Sorry about my earlier post, I didn't think about the possibility of your Compact DAQ possessing on board Counters.

This Developer Zone Article explains the functionality of Quadrature Encoders in a lot of detail and also provides some example code for a general measurement task; it also provides some example code and a brief explanation on why the counter is useful tool in this instance.

 

The resolution of the four Counters on the cDAQ-9174 is 32 bits. This means that your counters can each count to a maximum of (2^32-1) = 42949672965. Any increment past this state will cause the counter to roll over which you'll need to be wary of in your programming.

 

You can simulate Counters through the Measurement and Automation Explorer by going to MAX » SimulatedDeviceID » Test Panels » Counters. You can select a Edge Source to clock the counter and then press play to simulate the Counter operation. For a device to successfully simulate Counter data, you must ensure that the selected simulation device can support Counter functionality.

 

 


Alex Thomas, University of Manchester School of EEE LabVIEW Ambassador (CLAD)

0 Kudos
Message 4 of 33
(6,485 Views)

Thank you Alex.

 

I tried that. counter is always 0. Correct me please.

5.png

0 Kudos
Message 5 of 33
(6,474 Views)

In the above screenshot, you have selected the 9411 module to read counter input; this device does not possess on board counters. Try selecting the 9174 module and repeating the same process.

 

Regards,


Alex Thomas, University of Manchester School of EEE LabVIEW Ambassador (CLAD)

0 Kudos
Message 6 of 33
(6,461 Views)

Thank you Alex,

 

But when I run the code in the real hardware setting. I do get something from counter(same physical channel name).

 

Does it mean I make a mistake choosing the physical channel?

 

Have a nice day!

0 Kudos
Message 7 of 33
(6,458 Views)

Hi lvymerciqq-

 

No, it is valid to select the ctr0-ctrN channels from either your chassis or from the module name itself.  Internally they both use the chassis counters, but the advantage of addressing them by the module name (i.e. cDAQ1Mod1/ctr0) is that, in most cases, the routing from the digital I/O pins on the module to the counters on the backplane can be automatically made.  If you choose to address the counters by their chassis context (i.e. cDAQ1/_ctr0), then you may need to perform that signal routing manually (that is, programmatically, via DAQmx Channel Property nodes in LabVIEW).

Tom W
National Instruments
0 Kudos
Message 8 of 33
(6,449 Views)

Thank you Tom,

 

Then it goes back to my old question, why the counter does work when I simulate it? The 5th message in this post.

 

Have a nice day!

0 Kudos
Message 9 of 33
(6,446 Views)

Hi again lvymerciqq,

 

Each individual slot of your device comes with an in built Counter for your modules to reference; this is the reason that your DAQmx task can retrieve Counter data.

 

With respect to the simulated device, you cannot reference a timebase scheme as the Counter input due to your device type to trigger the Counter. Instead, your Counter references the PFIx terminals; which aren't acquiring any input as they are also simulated. This is because this is how your Counter physically routes to the module inputs in the device; there is no timebase configuration. If you simulate a device which does allow for referencing to an internal timebase clock such as a PCI card for example, you will see the Counter increment. So, unfortunately the problem here is that the simulated device Counter is functioning, unfortunately we're just not applying a signal to the terminals it is reading! 


Alex Thomas, University of Manchester School of EEE LabVIEW Ambassador (CLAD)

0 Kudos
Message 10 of 33
(6,442 Views)