Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple again. How to enable/disable zindex reset at runtime.

Hello.
I am wondering what is the simplest way of enabling and disabling hte ZIndex reset function on the 6602 at runtime. Do I need to stop the task and then recreate it with the required zindex? Or can I just poke in the zindex state required without resetting everything else up and restarting the task?
Thanks.
Will
Message 1 of 7
(5,113 Views)

Hi Will

The Z Index  cannot be enabled or disabled while a task is running. You would have to stop the task, disable (or enable) the Z index, then restart the task.

Regards

Beejal

Beejal S
NI UK & Ireland
0 Kudos
Message 2 of 7
(5,094 Views)
Is there a way around this.  I need to disable the z-indez while the task is running. If I stop it and re-start it the counts will be reinitialized when re-started.
0 Kudos
Message 3 of 7
(4,872 Views)

Hi Matt,

Unfortuantely this is not possoble because of the way in which the DAQmx driver access the various resources. Once the Task starts, the resources are locked, and any modifications such as disabling the Z index will only return an error.

My apologies.

Best wishes
Rob L

NI Applications Engineer

UK & Ireland


It only takes a click to rate this message 😉
0 Kudos
Message 4 of 7
(4,863 Views)
There may be an awkward workaround or two. 
 
1. The simpler software-based workaround. 
- Key requirement: must perform workaround while encoder is stationary.  If it's never stationary, this method is no good for you.
- Description: read the encoder value just before stopping the task.  Reconfig the Z-index enabled property as needed.  *ALSO* set the counter's initial value to the value you read just before stopping the task.  Then start the task.
- Note: in the past when I toyed with setting the initial value with various units settings and X1, X4, etc settings,  I found the behavior to be a bit unexpected.  This was many versions of DAQmx ago, and I haven't played around lately, nor do I remember exactly what seemed odd.  Just a word to the wise that you may want to double-check the effect of those settings when you set your initial value.
 
2.  A hardware-based workaround.
- Key requirement: an available counter on your 6602 board
- Description: let's suppose your available counter is Ctr7.  Wire the encoder's Z-index signal to Ctr7's "Gate" input.  Configure Ctr7 to do retriggerable single pulse generation with a short pulse period.  Wire Ctr7's output to your encoder counter's Z-index signal pin.  Configure your encoder counter to use Z-indexing always.  Your software can start and stop the Ctr7 task at will to effectively either enable or disable Z-indexing.
- Note: this can work even if the encoder is in constant motion.  However, the instant of switching between enabled and disabled is still subject to software timing as your code calls DAQmx Start and Stop.
 
-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
(4,854 Views)
I'll add another (conditional) option to Kevin's (both of which are good): If you're trying to disable the Z index during runtime so that you get the correct reference position along with the number of rotations (I'm not sure of a good term for this, absolute position?) you can enable the Z index, and then add another counter to edge count the Z index. Then your "absolute" position is =  read position + count * 360 (assuming degrees). It's a SW solution that would take an additional counter and would give you bad results if your encoder reversed directions (the edge count would only count up regardless of the direction you were going) but it might give you the functionality you need.

If none of these work - why are you trying to disable the Z-Index at runtime? We can probably figure something out...

cheers,
Andrew S


0 Kudos
Message 6 of 7
(4,846 Views)

Thanks for the feedback. All these solution could be viable. However instead of using an additional counter input I rather implement a hardware solution. That is, always have the Z-index enabled and through hardware enable and disable the Z-Signal using an AND gate and a digital out.

 

I am trying to enable and disable the z-index has part of a homing algorithm. Perhaps there is another way to do it.

 

Here is the problem.   Because the encoder value is being used in a feedback system, I can not have it jump to zero when the index is crossed.  Instead, I would like to latch the encoder value when crossing the index.  Then, I can stop the controller and change the encoder value and the command in a controlled way. (but I have not found a way to do this)

 

If I can't latch the encoder value, then I could have another counter zero on an index and the other not zero (the later will be used for control).  After the index is crossed, I could switch back to the other encoder for control (but I need to disable the index).

 

Let me know if you have a better solution that would not require any external hardware and that would require only one counter (or not more than 2).

0 Kudos
Message 7 of 7
(4,812 Views)