LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I use a digital signal to trigger a linear encoder to start and stop sampling?

I have a 6601 PCI card and am recieving a digital signal from the z-index on a rotary encoder and a count edges signal from a linear encoder.  I want to use the digital signal to trigger the linear encoder to start and stop sampling from the linear encoder.  I want to use the DAQmx read counter mutliple samples with a specified number of samples per channel and the DAQmx timing (sample clock) function to specify the sampling rate.  I am having trouble how to use the DAQmx trigger function to start and stop the DAQmx read function.  If you have any suggestions please let me know.
 
Thanks,
Dave
0 Kudos
Message 1 of 23
(4,744 Views)
Hi Dave,

In order to figure out the best way to accomplish your goal, I am going to need some more information on exactly what you are trying to do.  From your post, it sounds like what you are trying to do is to start counting on one z-index pulse,  poll what count you are on at a given frequency, and then stop counting on another z pulse.  If this is the case, it sounds like you are trying to do buffered event counting with a start and stop trigger.  The triggering for this is quite complex, but the buffering is relatively easy.

If you are actually trying to use the z-index signal to gate your counter (count when high, dont count when low), this is much easier.  If you just care about your start value and stop value (to get the number of pulses between z-index pulses), this is also relatively easy.

You say you are using a linear encoder.  Your device does have a special type of task for linear quadrature encoder position measurements.  This does have z-index capablities and may work for what you are trying to do.

From what I can tell there are several device considerations you need to know about:
  • The 6601 does not have a timing engine on it.  Because of this, you will have to generate your sample clock for your buffered measurement a different way.  One way to do this would be to use a pulse generation output from another one of your counters and use that as your sample clock (which you could then use a start trigger to start).
  • You cannot do a typical start trigger with a counter.  This implies that we are actually starting something (sampling for example).  Counters do not do this, they instead are "armed".  Because of this, you can use an Arm Start Trigger instead.
  • You cannot have a "stop trigger" per se.  This implies that you do not know how far into the past you need samples for, and figuring out the buffering for this is extremely complicated.  You can use a Reference Trigger, which allows for pretrigger samples to be read. The link is for a M Series device, and I have not tried it with a counter board such as yours, but the theory would be the same for buffered counting.
Any information about what exactly you are trying to do will narrow down the possibilities and make it easier to direct you to the best tactic to accomplish your application.
Neal M.
Applications Engineering       National Instruments        www.ni.com/support
0 Kudos
Message 2 of 23
(4,725 Views)
Neal,
Thanks for getting back to me, but I have decided to take a different approach than using a trigger.  If I decide to try the triggers again I will let you know.
 
Thanks for your time!
Dave
0 Kudos
Message 3 of 23
(4,709 Views)

I have a similar issue but I am trying to use a digital signal (Z-index pulse) to read the current position of a currently running Quad Encoder Task.

 

I am using a PCIe-6320 DAQ card.

 

What I am trying to do is "map" the marker pulses on a linear scale.  I have the DAQmx Task set up to read the counter pulses but instead of using the Z-index to reset the count, I would like to get the current position of each pulse.  I have tried to do this using software but the resolution is too low so I need to be able to accomplish this with hardware.

 

Any ideas?

 

See also "Using Z-Index on Linear Encoder to determine Absolute Position" for more details.

0 Kudos
Message 4 of 23
(4,312 Views)

CW_Edge

 

I would begin by looking at some of the links above. I would also take a look at these examples: 

 

http://zone.ni.com/devzone/cda/epd/p/id/1721

http://zone.ni.com/devzone/cda/epd/p/id/194

 

There is also a good document on Z index reloading: http://digital.ni.com/public.nsf/allkb/C9D8039FBEF6DCAA86256B8C0060FA3A

🙂

Sam S
Applications Engineer
National Instruments
0 Kudos
Message 5 of 23
(4,299 Views)

Sam,

 

Please don't take this personally, but did you actually read my post?  The examples and discussion you gave me are dealing with the most basic Encoder set up and are using the built in Z-Index functionality of the step to simply RESET the counter.

 

THAT IS NOT WHAT I AM TRYING TO DO!  I have an 18" long LINEAR scale that has 45 marker pulses along the length and I am trying to get an accurate "map" of the positions of each marker pulse - i.e. get the current position of the Encoder task each time there is a marker pulse.  I was able to do it using the software, however, the resolution is too slow so I am trying to see if I can do it on the hardware side.

 

Is there an example of how to measure the number of counts between Z-Index using the hardware sample rate?  Does this require buffering?  Can I use a digital input looking for rising edge to trigger a read on a currently running task?  These are the questions I need help on.

0 Kudos
Message 6 of 23
(4,296 Views)

CW_Edge,

 

I apologize for not clearly reading your previous post. The only current way I know how to do that would be using the software (DAQmx) to find the distance between pulses, and then use that to map the current position of the encoder. However it sounds like you were able to do this and were unhappy with the results. I do not know if a way to measure the counts between the Z-index using hardware sample rate for that card. However you could use that digital trigger and buffering to generate a positon but then it becomes a software times update and then you may be running into the same problem that you were previously.

Sam S
Applications Engineer
National Instruments
0 Kudos
Message 7 of 23
(4,290 Views)

I'm still not sure I understand the nature of your operating conditions, constraints, or overall needs.  Here's what I've gathered:

 

- you have 4 linear encoders and are performing buffered measurements on their displacements

- one encoder has multiple "Z-index" marks which are synced to its own A-High B-High quad state

- in addition to buffering displacements, you want to also map out the precise location of these Z-index marks using

hardware

 

Questions:

- once you do the desired mapping, is there a reason to expect it to change dynamically?   In other words,

can you simply have a mapping mode that characterizes your system, followed by a normal operating mode

where you use that info?

 

- to characterize the specific encoder with the marks, why not enable Z-index reload to a 0 value and then

sum up the delta positions between 0's to figure out absolute?  (You'll need to be sure to sample faster than

the rate of quadrature state changes)

 

- is there some physical linkage among these 4 axis of measurement? 

 

- do you need to correlate the other 3 encoders to the Z-index marks of the 1st?  Or does each have its

own set of markings?

 

- what's the bigger picture here?  Once you map out these marked positions, how will you be using them?

 

- there was an earlier suggestion (from nathand) to use the Z-index mark as a sample clock to capture instantaneous

displacement readings from all 4 encoders simultaneously.   This seemed to me like exactly the kind of thing

that ought to help you, so what aspect of that idea didn't work out?

 

-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.
Message 8 of 23
(4,280 Views)

Kevin,

 

Thank you for responding.  The "big picture" of this application is actually to use the marker pulses to be able to establish absolute positioning while the axis in in motion.  The distances between the marker pulses are designed to be unique so once the "map" is established, anytime the encoder passes any two marker pulses (assuming direction is known which it is), the system will know exactly where it is in absolute position.

 

The sampling rate on the DAQ card is plenty fast enough to handle the rate of motion, however, no matter how fast I run a while loop in LabView, it is not fast enough to "catch" the marker pulses accuratly enough.  I need to be able to count down to the single count level which in the case of this particular scale is .0002."

 

During normal running, I don't need such accuracy, my while loop timer is normally set to 10ms, however, for the absolute positioning portion, I need the resolution I can only get from the hardware side.

 

There is no mechanical relationship between the 4 encoders, the only reason I mentioned the 4 encoders is that I have used all the counter channels on the DAQ card so I do not have an extra one which is why I was trying to see if there was a way to trigger a "Read Current Position" of an existing counter task using a Digital Trigger.

 

I realize that there are many other ways to establish a "home" position, but I understood from the scale manufacture that this was the intended purpose of the marker pulses and just assumed there would be a way to do it in LabView.

 

So far, no luck.  Let me know if you have any suggestions and/or questions.  Thanks again for your time.

0 Kudos
Message 9 of 23
(4,269 Views)

Hmmm, well, *maybe*.  Does your 10 msec while loop timing suggest that you are normally taking software timed position measurements?  Or are you buffering the position measurements with a hardware clock but only servicing

the task every 10 msec or so?

 

If you need to hardware buffer all the time, then I think you'll need another daq board to solve this.  You won't be able to use 1 counter with 2 hardware-timed tasks where one of them buffers normally and the other buffers only on marker edges.  

 

Hopefully though your 10 msec while loop could simply take software-timed measurements.  In that case, you could do as nathand suggested and use the marker edges as a sample clock.  But then in your while loop, you could query the DAQmx Channel property node CI.Count (counter input-->general properties-->more-->count) to get a software-timed snapshot of the count value without disturbing the buffered task that gives you hardware-timed precision for your marker positions.  You'd need to do your own scaling from count to distance, but at least you wouldn't need another daq board!

 

With either approach, I'd also note that you might have a little ambiguity if your marker positions line up pretty exactly with A,B edges.  I'd worry that sometimes the count increment might register before buffering and other times the buffering may happen before the count increment registers.  It's a bit of a race condition for the electronics.  There's a workaround you could do using yet 1 more counter set up for retriggerable single pulses.

 

-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 10 of 23
(4,249 Views)