LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Encoder signal acquisition using USB 9233

Hello All,

 

I need to measure angular position between encoder signal and sensor signal using quadrature encoder. I am using 9233 analog input module for counting encoder edges using attached vi. The attached vi counts the edges of encoder signal. Now I have to acquire one data point from simulate signal vi(considering this as my sensor signal)at each edge of encoder pulse how can I accomplish this.

 

Thank you very much for your assistance.

 

0 Kudos
Message 1 of 7
(2,842 Views)

Hi Shaila,

 

Since encoder signals are digital, I would highly recommend considering a different module that supports digital input. Currently, it appears you have built a makeshift ADC within your VI, which might work, but I wouldn't recommend. If your input was interpreted by your hardware to be digital (since it actually is), you could easily use it to trigger an on demand sampling of your sensor signal without needing to manually check the signal level.

 

That being said, you can accomplish your goal with your current implementation using software triggering. You can find a good example of software triggering for dynamic acquisition in the NI Example Finder under Dynamic Acquisition Software Trigger.vi. Basically, what you want to do is link your LabVIEW code for encoder edge detection to send a software trigger to the task that is reading your sensor signal and have it sample once (this is step 7 in the example VI, except you would substitute your edge detection for the Send Software Trigger Boolean control). I would be happy to write a bit of prototype code if you find this explanation lacking.

 

It should be noted that software triggering does not guarantee good synchronization. If you don't mind the encoder and sensor samples being at different times, the above implementation could work. However, if the sensor must be sampled within the time it takes to sample the encoder and recognize an edge, in software (this could range anywhere from fractions of a millisecond to a few seconds, depending on a lot of variables), this implementation won't work. In order to guarantee synchronization, you would need to use digital hardware triggering which is not available with the 9233 since it is designed for analog input.

 

If you could provide additional information about the hardware available to you and your specific project, we may be able to identify a solution that is both synchronized and adequate for your problem.

 

Duncan W

0 Kudos
Message 2 of 7
(2,772 Views)

It will be useful if you provide me prototype code.

0 Kudos
Message 3 of 7
(2,760 Views)

hi Duncan W,

I need some clarification with my first post.. I simulated my sensor signal with simulate vi.. But consider if I'm feeding same (sensor) signal from my function generator (to A0 input) to the 9233 device with encoder signal as my other input (to A1 input).. whether the same code can be used to accomplish my goal.

 

Thanks for your patience and reply..

0 Kudos
Message 4 of 7
(2,749 Views)

Shaila,

 

It is my understanding that you would like to use an edge from an encoder signal to trigger sampling of a sensor. Using your current implementation, that trigger will need to come from software since you are detecting the edge in software. However, software triggering does not guarantee synchronization. This means that the time at which you sample the sensor signal will not necessarily correspond to the time at which the edge of the encoder signal occurred. The sensor will be sampled at some point in time arbitrarily later than the encoder edge. If this is not a problem, you can use your proposed method to capture the sensor signal. If you need the sensor to be sampled at the same time, or within a short time of the encoder edge, then you will need to use some form of hardware trigger.

 

A few things to think about in designing your solution:

Encoder outputs are digital signals. (You can read them as analog, but it is currently obfuscating and overly complicating your code.)

Using Basic DAQmx Functions

Triggering in LabVIEW

 

To answer your specific question, your code should work with a real signal, provided it works with a simulated signal. However, I am not convinced that your posted code will accomplish your goal. If my understanding of your problem is incorrect, I would be happy to offer additional assistance if provided further details, particularly about any additional hardware available to you and the purpose of your application.

 

Duncan W.

0 Kudos
Message 5 of 7
(2,730 Views)

hi DuncanW,

 

Thanks for your reply.. I gone through the example of vi which you stated in previous post.. I tried modifying for my purpose.. but it didn't work properly.. can u provide me some prototype code.

 

thanks for your assistance.

 

0 Kudos
Message 6 of 7
(2,722 Views)

Shaila,

 

I do not have enough information about your system and application to offer any more assistance at this point in time or write any code that would be of use to you. It is worth noting that the example VI that I linked you to is an example of something I think might be similar to your problem, not a plug-and-play substitute for writing your own code.

 

Here are some questions that you will want to answer as you solve this issue:

What is an analog signal? A digital signal? How does NI software/hardware treat these two differently?

How does an encoder work? Specifically, how do quadrature encoders work?

What hardware do I have? Do I have the right hardware for the signals I would like to acquire?

 

I can help you answer some of these questions, such as whether you have the correct hardware for your application, but most of these are questions you will want to answer on your own so that you can better describe your issue and we can help you find a solution. Additionally, be sure to take a look at the links I have posted previously. Understanding the functionality of DAQmx and triggering will help immensely for what I believe you are trying to do.

 

Here is another link on reading encoders using NI products:

Encoder Measurements: How-To Guide

This guide uses different hardware. If what you are trying to do is read a quadrature encoder using its two output channels, then you need a counter, which the 9233 does not have.

 

Duncan W.

 

 

 

0 Kudos
Message 7 of 7
(2,714 Views)