LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous Samples Data Acquisition from two encoder ( Multi digital input)

Solved!
Go to solution

Hi;

 

There is NI USB-6251 DAQ system in our lab.

I am new at NI devices and LabView.

There are two encoders in my system and I need to get continuous samples. I found an example in help menu for one encoder.

" Counter - Read Encoder (Continuous Clock).vi "

 

It works perfect for one encoder with 100kHz timebase for Sample Clock Source.

But when I copy everything for second encoder, it gives error. I couldn't find a solution for this. Can anyone help me?

 

Best regards.

 

 

 

Possible reason(s):

Specified route cannot be satisfied, because it requires resources that are currently in use by another route.

Property: SampClk.Src
Property: SampClk.ActiveEdge
Source Device: Dev1
Source Terminal: 100kHzTimebase

Required Resources in Use by
Task Name: _unnamedTask<9>
Source Device: Dev1
Source Terminal: 80MHzTimebase
Destination Device: Dev1
Destination Terminal: Ctr1Source

Task Name: _unnamedTask<A>

0 Kudos
Message 1 of 9
(2,257 Views)

In MAX, the device routes for a multifunction board like yours shows only an "indirect route" from the 100 kHz timebase to the counter gates.  (The gates are where sample clock signals would go).   What's not as clear are the implications of an "indirect route".  Typically it means that one of the counters gets used behind the scenes to accomplish the needed routing and is thus not available for other use by you.

 

I'd recommend that you make a "dummy" continuous AO task that generates 0 V out to a channel that isn't physically wired to anything.  Then you can configure your encoder tasks to use the '/Dev1/ao/SampleClock' signal as their sample clock source.   *This* kind of routing doesn't consume either counter, so you'll be able to run 2 encoder tasks at the same time.

 

Note: be sure to start the encoder tasks before starting the AO task so they'll be ready for the first sample clock signal and thus be in sync with one another.

 

 

-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 2 of 9
(2,204 Views)

Thanks for your reply Mr. Kevin Price,

 

I understood but I don't know how to do your suggestion. Because My knowledge on this subject is limited. If you don't mind, can you add it to the program when you're available? Please.

 

Best wishes

Thanks

0 Kudos
Message 3 of 9
(2,199 Views)

Took a quick look at your program and it looks pretty manageable to modify enough to illustrate.  No time now, hopefully at the end of the day.

 

 

-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 4 of 9
(2,187 Views)
Solution
Accepted by topic author lambanerl

I didn't have hardware to test, but this should at least be awfully close to working.  You had both encoders configured to use the same PFI pins for A,B,Z -- I left it that way on purpose for initial debug.  After all, if both counters are looking at the same encoder, it's easier to compare their data to confirm sync.

 

 

-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 9
(2,179 Views)

Mr. Kevin Price,

 

Sorry for late respond, because NI forms says that "As a new user, you can only post twice in the first 24 hours"

 

I am grateful to you for your help. It works perfectly. Now, I modified it according to my system. Because I have 1 linear and 1 rotary encoder. My last problem is logging data.

 

I added two logging block so it saves data seperately but I want to save them in one file. First column must have rotary encoder data and second column must have linear encoder data. How can I do it so ?

 

Thanks for your helps

0 Kudos
Message 6 of 9
(2,156 Views)

It can't be done *directly* -- the logging feature requiers 1 unique file per logging task.  But here are 2 ways to get your data into a single file:

 

1. Use logging feature for each task, then after the tasks are cleared, merge the 2 files into 1 (see especially msg #4).  I would then add conditional code to delete the originals *only if* there were no errors from the merge.  Note that you can also get rid of the example's call to launch the TDMS file viewer.

 

2. Learn and use the native TDMS logging functions.  If you were capturing AI waveforms, I'd probably recommend this method because waveforms carry useful metadata that automatically gets carried into the TDMS file.  Counter data comes as raw arrays without such metadata so you don't get the automatic benefit.

 

I don't really use the automatic logging feature but would guess maybe it *would* automatically include some useful metadata.  If so, option 1 is probably the better way to go (for now).   Option 2 is worth your while to learn from though as it illustrates the producer/consumer pattern to separate file logging from data acq.

 

 

-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 9
(2,147 Views)

Mr. Kevin Price,

 

Thanks for your help and suggestions.

I will be forever grateful to you.

 

 

Best Regards

0 Kudos
Message 8 of 9
(2,137 Views)

Oops, I forgot the link that should have been part of option 2, showing how to use the native TDMS functions.   Here it is.

 

 

-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 9 of 9
(2,129 Views)