LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need a trigger based on particular angular position of encoder

I am completely new to labview and concurrently doing tutorials to understand the layout better. For now I have a quad encoder that I have configured using a simple DAQMX which gives me the position in degrees based on the position. Now I want to send a trigger to an external camera when the encoder is at 30 degrees. How do I go about this?

0 Kudos
Message 1 of 7
(3,635 Views)

I notice you are using the Dreaded DAQ Assistant (as I call it, a.k.a. the DDA).  When using a DAQ Device, I always advise students to plug your device in your PC and run MAX, the Measurement and Automation eXplorer, and to "play" with it.  When doing Data Acquisition, you almost always want to sample at a fixed rate, something that NI DAQ devices handle very well.  For an rotary encoder, I might suggest acquiring 100 points at 1 kHz, and doing continuous recording.  If you set MAX up this way and hit "Go" (I'm not sure what the "Go" button is called), you should see a nice chart of shaft position and watch it change as you move the shaft.

 

Does your encoder have a "Z" (or "index") input?  This can be used to "define" 0° by resetting the DAQ device when this pulse is seen, which "calibrates" your Angular Position so it not only goes 360° per revolution, but knows where 0° is (making it much easier to find 30°).  [Of course, your device might have another way to define 0° -- read the manual).

 

So you now want to trigger a camera when the encoder is at 30°.  How fast is the shaft turning?  How "accurately" do you want to be to hit 30°?  This can give you an idea of how fast you need to sample in order to be "close enough".  You didn't tell us what DAQ device you are using, but many that can handle encoders also have digital outputs that you can use to create a pulse (start by writing "False", which is probably the default output, then when you want a pulse, write "True" (giving you a "rising edge") and "some time later", set it back to False.

 

Bob Schor

 

 

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

How are you sending the trigger, with some kind of digital signal or in software? As far as the LabVIEW goes, you can just check if the encoder is at (or reasonably close to) 30 degrees and then have a case structure with whatever code you want to execute when that condition is true.

0 Kudos
Message 3 of 7
(3,618 Views)

Hi Adi,

 

As Bob_Schor and Gregory mentioned, your solution here will depend on the speed of the rotation and the desired accuracy.

 

To elaborate slightly, if the change in position between measurements is smaller than the desired error, you can just check for position ~= 30 degrees, then send a digital output.

 

If on the other hand this is not true, (and you can't improve measurement frequency/accuracy to make it true) you could perhaps try using the 0 position (read Bob's description for the Z channel) and a digital output with regeneration and the sampling triggered by the encoder pulses.

 

To do this, you'd want to generate a sample with the same number of values (in the array) as the number of encoder pulses per rotation. Note that if you have a high resolution encoder, you might not be able to fit these into the buffer, in which case regeneration might not be possible (don't recall). In that case, you'd have to keep writing values, but otherwise this should still work...

Then, set (using DAQmx Timing node) the timing source to a PFI pin that is either connected to or the same as the input from the rotary encoder (take care for quadrature when counting pulses etc).

Trigger your digital output task to start with the Z-pulse.

Offset the True value(s) in your array of values by an appropriate amount to line up with the 30 degrees - so if you have 360 pulses per revolution, you'd want the 30th (element #29?) value in your 360 element array to be true (and perhaps elements 31-{3,4}x as well to increase the output pulse duration, depending on the requirements for your camera trigger).


GCentral
Message 4 of 7
(3,597 Views)

You've been given a few different ideas, can you give us more description now?  

 

What DAQ device do you have?  Do you want to trigger a repeating pulse *every* 30 degrees?   Or a repeating pulse once per rev at the 30 degree position?   Or a single 1-time pulse at that position?

 

Does your encoder axis move continuously in one direction?  Or does it stop and start?  Or does it move bi-directionally?

 

How close to *exact* do you need to be about this 30 degrees?  (Think long run here.  Simple approaches can get you "kinda close", but will be dead ends that can't get you any closer.  Approaches that are exact and repeatable will probably be more complex but will have certain distinct advantages that could matter for your testing and data collection.

 

Depending on your answers to questions like these, we can probably help steer you toward a suitable solution.  

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 5 of 7
(3,580 Views)

Wow thank you for the help here. So to clarify and provide more description regarding this, I have attached an image here as well.

 

I am using an incremental rotary encoder with a Z index. The DAQ I am using is a USB 6229. The shaft rotation will be between 10 to 60 r[m. In terms of accuracy of reaching '30 degrees', I just want it to be repeatable, since I will be averaging the data over multiple cycles.

 

I will try sending the signal to a software called 'davis' which is a software used for particle image velocimetry (aka fluid dynamics). But even before that, I'd like to setup my case where everything works and when the shaft reaches 30, i get a boolean answer.

 

In terms of the questions Kevin asked, I want a pulse at a particular position 'once' in the cycle in a particular direction. The image below shows that the shaft goes from initial position to final position (lets say 90 degrees for now). When it covers 30 degrees ( i do want to implement taking data at every 10 degree increment in the future), I want a a trigger. The shaft does not complete an entire rotation since once it reaches 90 degrees, it will return back to 0 (during this reverse cycle, I do not want the trigger).

 

It terms of how close, I just said 30 degrees as an example. If the measurement is repeatable enough within 1-2 degrees that should work for me to begin it. Although I would only be able to tell this once I process my results. I hope that answers most of the questions you guys had. In the meantime, I will try to work on a VI and see what I can achieve. As a newbie, it does take me implement changes and learn the tutorials at the same time.

Thank you

0 Kudos
Message 6 of 7
(3,570 Views)

If you want it to be repeatable so you can overlay data from multiple cycles, you *need* to look for a solution that involves hardware-timed sampling.  A variant of what cbutcher outlined in msg #4 should be a good approach.  A nice benefit is that it is easily adapted to generate trigger pulses wherever you want them.

 

So now some more questions.  😁   Do you have control over the motion of the encoder axis (in terms of start, stop, speed, distance)?  Things get easier if you do.  If not control, do you at least have knowledge of the rotation distance?  Can you arrange the physical setup to make sure that you *always* pass through the encoder's z-index position *before* you need to generate any trigger pulses?  Things might not be feasible if you can't.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 7 of 7
(3,561 Views)