Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop Encoder from resetting to Initial Angle

Solved!
Go to solution

Hi,

 

I currently have an enoder connected to a counter input on my DAQ card.  For my process, I need the ability to start/stop the task that read the encoder.  My problem is that everytime I restart my task, the encoder gets reset to zero (My Initial Angle).  Is there anyway to avoid this?

 

Thanks,

Paul

0 Kudos
Message 1 of 5
(4,026 Views)

Unfortunately, I don't currently have access to hardware to test out my thoughts, so here are a few questions to help clarify:

 

1. What is the reason you need the task to be stopped?  

2. Do you only need to stop and restart or do you need to clear and reconfigure?

3. What data acq board are you using for the encoder?

4. Does the task have an associated sample clock or is it a simple software-timed read-on-demand type of task?  If the former, you can stop (or disable) the clock signal without stopping the task itself, and the counter will continue tracking position without sampling it.  

5. Can you describe the overall app a bit more? Let's suppose the reading was 30.0000 degrees when you stop the task (or perhaps merely stop sampling).  While you are not taking readings, the encoder moves by +10.0000 degrees.  Now it's time to start the task again (or start sampling again).  Should the initial reading show 40.0000 or 30.0000 degrees?  In other words, do you want the data acq counter hardware to track position even when your app isn't reading it?  Or should it ignore movements during those times?  Why?

 

-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 2 of 5
(4,019 Views)

Kevin,

 

Thanks for the reply. Let me explain my application for you.  I really need to be able to do two things.  I need to be able to acquire encoder data at various rates (500 Hz - 7KHz) at certain times, but when I am not acquiring data I need to be able to still read from the encoder periodically (5 times a second).  I am also doing the same thing for with Analog Inputs, acquiring at a certain rate at certain times, but stopping the task and reading one sample on demand in between.

 

My initial idea was to use the AI Sample Clock for the fast rates and then stop the task and read it as a single sample demand for the periodic readings.  The real problem my single sample is always zero because the encoder is resetting.

 

3.  PXI-6284

5. If I stop the task at 30.000 degrees and it moves 10.000 degrees the task should restart at 40.000 degrees.

 

Based on your input it seems like my only option is to make this work with only one task, and do not stop it unless I want to clear the encoder.

 

Thanks for your input and sorry if the all sounds a little confusing. If you have any other suggestions I would love to hear them.

 

Thanks,

Paul

0 Kudos
Message 3 of 5
(3,998 Views)
Solution
Accepted by topic author pgstein

Your answer to #5 makes it clear that you must NOT stop the task when you want to drop down to a slow sampling rate.  I've got 2 basic approaches to suggest:

 

1. HW-based approach: You're using one counter for your encoder measurement.  Is your other counter available to generate your sampling clock?  If so, you can simply change that counter output frequency on the fly to change your sampling rate as needed.  A possible downside is that the actual data acq buffer won't provide any clues as to which rate was used for which samples.  Whether or not this is an issue depends on your app.

   There's actually a more complicated possible method based on using a dummy AO task (if you don't have a real hw-timed AO task) as a sample clock because AO rates can also be updated on the fly.  Then you could use your 2nd counter to measure the clock so you'd have a record of all the timestamps.  You'd need to be careful to keep your starts and reads in sync, but it's surely doable.

 

2. SW-based approach.  Always sample at the same rate and always pull data from the buffer fast enough to keep up.  But during the "slow sample modes" times, extract only the portion you care to keep.   Overall, this approach is probably simplest, but the former one is too nifty not to mention.

 

You were already on basically the right track with your thought to share the AI sample clock.  What you might not have realized is that you CAN stop the AI Task (making the sample clock cease) WITHOUT stopping the CTR task.  Then you could restart the AI at a different rate.  During the time the AI task is stopped, there are no sample clock pulses to cause CTR encoder values to be buffered.  However, the actual count register will still be incrementing/decrementing appropriately to track position.  When you restart AI at a slow rate, you'll just get back to sampling/buffering those position values. 

 

-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 4 of 5
(3,993 Views)

Kevin,

 

I did end up just keeping my encoder task constantly running, while stopping my AI task to change the rate. Works like a charm.

 

Thanks for your help,

Paul

0 Kudos
Message 5 of 5
(3,916 Views)