LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Z-Index on Linear Encoder to determine Absolute Position

I am trying to use the Z-Indexing function on the DAQmx Counter along with the reference marks on a linear encoder to be able to determine Absolute Position.

 

I have a PCIe-6320 DAQ card which has 4 Quatrature Counters each hooked to a linear encoder through the SB-68 Breakout box.

 

One of the encoders I am using is the SENC150 which has 2 reference marks every 20mm (but not exactly 10mm).  The spacing of the reference marks are "random" so that once you characterize the spacing on a given encoder, once you find any two marks, you should be able to tell where you are on the encoder.

 

I am able to get relative position with the Z-Index disabled and if I enable it with the phase setting A High B High, it does reset to the Z Index Value every approx 10 mm so I am confident it is wired correctly.

 

My question is can I use the Z-Index pulses to determine absolute position without having to use an additional counter task since I have used them all? 

 

Perhaps more generally, if not this, what is the purpose of the Z-index function on linear encoders?  Is this just a carry over from angular?  I have found quite a few examples and threads concerning the Z-Index in reference to angular encoders, but very few if any having to do with Linear position encoders.

 

Any suggestions?

0 Kudos
Message 1 of 16
(6,613 Views)

I couldn't find any information on the Position-Trac feature, but the z-pulse on a linear encoder would be used the same way as a z-pulse on a rotary encoder.  It provides accurate referencing.  A typical homing procedure would be finding the edge of a switch, then find the z-pulse.  The switch is used for rough referencing, and the z-pulse is used for final referencing.

0 Kudos
Message 2 of 16
(6,585 Views)

OK.  That makes sense, but how do you monitor the Z-Index pulse using the Counter task?  Do you manipulate the Z-Index Enable and the Z-index value properties?  I haven't been able to change the Z-Index properties of the DAQmx Counter task without stopping the task and starting it up again so how do you do that while the encoder is moving without missing counts?

 

Is there an example of this so I can see how this would be handled in Labview?

0 Kudos
Message 3 of 16
(6,576 Views)
0 Kudos
Message 4 of 16
(6,555 Views)

Highland, I really appreciate your taking your time to try to help me, I really do, but at the same time, please don't waste my time.  The example you gave me is the most basic linear encoder example possible.  I have some experience with the DAQmx in general.  My application has 4 quadrature linear encoders running simultaniously with processing on each along with 3 ea. analog signals from strain gages. 

 

You had suggested using the Z-Index in conjunction with a switch (I am assuming physical switch like a limit switch) to determine a "home" position.  I am interested in this concept, but have not been able to determine how to accomplish this in LabView without losing counts.  As far as I can tell, I have to stop the task to change the Z-Index parameters and I don't know how to do that while the encoder is moving without missing counts.

 

It is the Z-Index/homing actions that I am looking for an example of.  If you can help me with that, that would be great.

 

Thanks again.

0 Kudos
Message 5 of 16
(6,532 Views)

There are two ways to change configuration setting on a DAQmx task. First would be in the DAQmx create channel.vi which would require you to stop and clear the task to change the z index settings. This is not what you would want as stopping the task would cause you to lose data.  The second method would be to use a property node to change these values later on during the task. I ran a test where I would change the values of the Z index enable, phase, and value property nodes and reread the property node directly afterwards to see if the changes were actually made to the task. I was not able to change the Z index phase, and value property node dynamically from within a running daqmx task. It looks like the best option is to stop the task, change the values, and restart. This however may cause you to lose data as you were expecting when used within the counter task. I am looking into this more to get a 100% confirmation of this issue.

 

What application / purpose would you need to change the values of the z index properties dynamically?

Frank,
National Instruments
Software Group Manager
0 Kudos
Message 6 of 16
(6,490 Views)

I don't think there's a built-in way to do what you want, although you might get lucky and find someone has written it already.  Unfortunately I don't have sample code for you, but here's my suggestion.  Instead of using the Z channel to reset the counter, route it to the counter sample clock.  Set up a DAQ task to do buffered position measurement, then start the motor.  You'll get a position measurement every time you cross a reference mark.  Create a table that matches distance between marks to absolute position.  Once you've crossed two reference marks, subtract the counter values and look up that value in your table; you now have your absolute position (if you can't stop immediately after reaching a reference mark, you'll need to get the position after stopping and figure that in as well).  Once you've determined your position you can stop and reconfigure the DAQ task, if necessary, without losing position.

0 Kudos
Message 7 of 16
(6,474 Views)
OK. I think I'm following you. This sounds like what I was wanting to do. When you say "route it to the counter sample clock" are you speaking of Labview code routing, physical wiring or both? I think I found an example using the Angular encoder that does what you are talking about Meas Angular Position-Buffered-Cont-Ext Clk.vi It seems like I should be able to select the PFI that the Z-Index is already connected to as the Sample Clock Souce, is that correct?
0 Kudos
Message 8 of 16
(6,436 Views)

Your choice whether to connect the Z line to the default sample clock pin, or set the Z-index pin as the sample clock source in software - I'm pretty sure you'll get the same result either way.  You might want to look at the similar "Finite" version of the same example since you only need two measurements.

0 Kudos
Message 9 of 16
(6,430 Views)

OK.  I tried using the Sample Clock as discussed above and came across an issue.

The task by itself works fine, however, since I already have a DAQmx task collecting and processing the data from the counter channel, if I add the buffering task to my existing program, I get an error about conflicting resources - It doesn't seem that I can run two tasks from the same channel at the same time.  Is that correct?  It kind of makes sense I guess.  Can I use the Sample Clock from the Z-Index trigger to pull the current position from the existing task?  I know it wouldn't be as clean but would that work?

0 Kudos
Message 10 of 16
(6,405 Views)