LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NI USB 6229: Analog and 2x Quadrature encoders simultaneous acquisition

Hello,
 
I am using a NI USB 6229 and want to measure the following:
- 6 analog input signals
- 2 quadrature encoders
 
I want to make a buffered acquisition and (if possible) have all the 8 signals acquired simultaneous.
 
Which clock do I have to use for the 2 encoders? One colleague has a similar application working, with only one quadrature encoder and with the PCI 6221 board. 
He is using PFI13 as clock for both tasks (analog and counter task).
 
In my case, I would like to make an buffered acquisition for both encoders (acquiring at 100 kHz) and have this two signals simultaneous with the analog inputs . Is it possible?
 
If not, which configuration do I have to choose for having a buffered acquisition of the two counters (without being synchronised with the analog inputs). How much delay would I have, if both acquisitions are not synchronised)
 
I would like to have a fast answer, since I have to find a way to measure this signals very soon.
 
Thank you in advance,
 
Eugenio
0 Kudos
Message 1 of 12
(4,754 Views)
You can do this (most likely)

Create in Max a task with the digital encoders, set the acquisition to continuous.
Create in Max a analog input task with a continuous input of 100 kHz.
In LabVIEW open the help, look for synchronized acquisition. There is some VI 'port with device prefix'.

Use this VI in your own VI to get the 'Sample Clock' of the analog task and use that as the clock for the encoder task.

Be sure to first start the digital task and then the analog task.

Good luck,

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 12
(4,750 Views)
Hi Ton,
Thank you for your answer.
I have forgotten to write that I am writing this application in .NET C#, not in Labview.
 
But you helped me a lot when saying that it is possible to make this, since in C# the same functions are available.
 
But I am concerned about the possibility of measuring two quadrature enconders with the USB 6229: is it possible at all? I have read that it is necessary to use an external clock source, and if (for example) I am using Ctr0 for counting and Ctr1 for the clock, then I can not use Ctr1 for the second quadrature encoder. Is there a way to measure both quadrature encoders using another clock source? If yes, which clock source do I have to use? (because for me it is mandatory to read both quadrature encoders, a way without synchronising them with the analog inputs would be also ok!
 
As I understand in your answer, it would be possible if using the sample clock from the analog task, wouldn't it?
 
Thank you in advance
 
Eugenio Acevedo
0 Kudos
Message 3 of 12
(4,730 Views)
You can use the analog input sample clock as the external clock.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 4 of 12
(4,728 Views)

Hello again,

Since this is something new for me, do you mean to configure the software to use "ai sample clock" as clock source or do you mean to wire the ai sample clock to (I don't know which one) an input of the board?

Thanks

0 Kudos
Message 5 of 12
(4,722 Views)

You mean selecting (in the code where I configure the counter task) "/Dev1/ai/SampleClock/" as clock source, don't you?

 

Thanks

0 Kudos
Message 6 of 12
(4,720 Views)


@acevedo wrote:

You mean selecting (in the code where I configure the counter task) "/Dev1/ai/SampleClock/" as clock source, don't you?



Yes, (if Dev1 is your 6229) then first start your digital task, and later your analog task.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 7 of 12
(4,710 Views)

Hello again,

I tried it (here below the source code in C#)

****************************************************

this.sSITask = new Task("BufferedDigitalInputTask1");

this.sSITask.CIChannels.CreateLinearEncoderChannel("Dev1" +
    "/ctr0", "",CIEncoderDecodingType.X2,true,0,
    CIEncoderZIndexPhase.ALowBLow,1,0,CILinearEncoderUnits.Ticks);
   this.sSITask.CIChannels[0].DataTransferMechanism = CIDataTransferMechanism.UsbBulk;
  

this.sSITask.Timing.ConfigureSampleClock("/"+"Dev1"+
   "/ai" + "/SampleClock",1000,SampleClockActiveEdge.Falling,
   SampleQuantityMode.ContinuousSamples,-1);

this.sSITask.Control(TaskAction.Verify);

//create a reader
this.sSIReader = new DigitalMultiChannelReader(this.sSITask.Stream);
   
//launch tasks
this.sSITask.Start();

****************************************************

and I got the following error message (when running this.SSITask.Start(); .)


The specified data width is not supported or cannot be
transferred on the bus. The operation could not be completed as specified.

Task Name: BufferedDigitalInputTask1

Status Code: -50005

 

As you see, I have configured "-1" for NumberOfSamples. Perhaps this is the cause for the error. Which settings would be right?


 

 



Mensaje editado por acevedo
0 Kudos
Message 8 of 12
(4,690 Views)
I still have this problem. Can anybody help?
 
Thank you in advance,
 
Eugenio
0 Kudos
Message 9 of 12
(4,609 Views)

I only program in LabVIEW, but I *think* the problem may relate to some intermingling of terminology.  Encoder tasks use the onboard counters and in NI terminology, these are NOT "Digital" tasks.

 

this.sSITask = new Task("BufferedDigitalInputTask1");

This line is probably ok since I expect the string is just a convenient human-readable alias to the task.  But it does suggest that the encoder task is being thought of as a "Digital" task.

 

//create a reader
this.sSIReader = new DigitalMultiChannelReader(this.sSITask.Stream);

I kinda suspect this line.  For one thing, you've only configured 1 encoder channel in your task.  In fact that's all you *can* configure in one task -- you'll need 2 separate tasks for your 2 encoders.  So creating a reader that expects multichannel data may be the problem.  The other possibility may be that your board has only an 8-bit digital port available for digital tasks.  You've asked for a multichannel digital reader that probably wants to create a buffer of 8-bit ints.  However your task is for an encoder with scaling units that want to become doubles. 

You probably need to create a reader that expects to handle encoder position data from a counter.

-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 12
(4,602 Views)