LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simultaneous use of ctr0 and ctr1

Solved!
Go to solution

I am trying to write a program that will drive two lasers with square wave modulation and that reads in data synced with the modulation. It is necessary that I control the lasers using two AO channels and that  (effectively I want to trigger the AI to start when the AO is either rising or falling). I want to start the AO tasks and keep the lasers running (i.e. continuous mode) while only a finite number of samples are collected for the AI measurements. To do this I have tried to use the counters to bring everything together, i.e. I use the counter to trigger both the AO and the AI tasks. This works well if I do this for one of the lasers, but as soon as I try to use both of them I get an error (-89137);

 

AQmx Write (Analog 1D Wfm NChan NSamp).vi:1<append>
<B>Property: </B>Start.DigEdge.Src
<B>Property: </B>Start.DigEdge.Edge
<B>Source Device: </B>Dev1
<B>Source Terminal: </B>Ctr0InternalOutput
)

 

Note that I have one of these triggered off of ctr1 and the other off of ctr0, which I thought should provide independent control, but I think that they are somehow interfering with each other. 

 

I would appreciate any help in getting this to work! I've attached sample code that shows in general what I am trying to do. Note that the first task works but the second task gives the error. If you switch the order the same thing occurs (i.e. 1st task works, second fails). Note that in the sample code here I've left out the part where I would actually then acquire the AI samples (which would just be a while loop that starts the AI collection, collects samples and stops the AI collection). 

 

Thanks for your help!

0 Kudos
Message 1 of 5
(3,744 Views)

Cappa,

 

What device(s) do you have? 

 

I notice that you are using both the counters and refering to a digital line for the control.  Could it be that these two lines are being used in both the counter and as a digital line?  I cannot verify this is the case until I know what device(s) you are using.

 

Are you using RTSI?  If so this article might apply.

 

It doesn't seem like you are actually using the counter to sync everything.  Are you sure you didn't want to use the counter internal output like in the examples located at Find Examples»Hardware Input & Output»DAQmx»Syncronization»Multi-Function-Ctr Pulse Train Generation for AI Sample Clock.vi

Sincerely,
Jason Daming
Applications Engineer
National Instruments
http://www.ni.com/support
0 Kudos
Message 2 of 5
(3,719 Views)

Hello Jason,

 

Thank you for your help. I am using a M-series USB 6259.

 

I am not using RTSI.

 

Thanks for the pointer to the examples.  Looking at them I think that what I am trying to do is something more like is shown in the Multi-Function-Synch AI-AO.vi example, albeit with the AI triggered off the AO instead of the way shown in the example. Or like is shown in the Multi-Function-Synch Dig Read Write With Counter.vi example, but with the digital I/O replaced with analog channels. 

 

I've been working this this further and I believe that my confusion is coming from not understanding why I can't seem to use the 2 counters independently but simultaneously. For example, if I take the Multi-Function-Synch Dig Read Write With Counter.vi example and create two versions of it and try to run them as sub vi's within a simple program (where the DI, DO and ctr's are specified to be different for the two versions) an error results for one of the versions (-89137) at the point where the waveform is written to the DO task. I can only assume that there is something fundamental about using the counters that I don't understand. I've included my very simple sample code.

 

Note that I have tried the same thing with Analog channels and get the same error, but I thought it best to build on the example vi's to make sure I'm not introducing some other error. 

 

The reason that I would like to do something like this is that I would like independent control of the lasers I am using and this (i.e. creating different tasks for each laser) seemed like the logical way to do it to me. But if you have other suggestions I'm all ears!

 

Thank you,

Chris Cappa 

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

Hello again,

 

I've been doing a lot of reading and playing around in labview and I now think that I understand where my problem arises from, although it is not clear to me how to fix it. I've made a very simple vi where I try to create two different AO waveforms simultaneously and have removed all referencing to counters. When I do this I still get an error (-50103) telling me that the specified resource is reserved. Despite my best efforts, I really don't understand why this does not work (sample vi attached). It seems that Labview will not allow me to start two different AO tasks independently on a single DAQ device (M-series 6259). Is this correct? I think that if I could understand why this error is arising I could figure out a solution but there is obviously something fundamental to how labview or the DAQ device operate that I am missing.

 

I know that I can get around this problem by creating a task that contains both AO channels (such as is done in this very nice example vi that I found and have attached: "Cont Gen Wfm Non Regeneration Mult Channel.vi". Is this the best solution or is there a way to start two separate AO waveform tasks as I've attempted (and failed) to do in the "Multiple AO test.vi" sample? 

 

Thanks again for the help!

 

Chris Cappa 

0 Kudos
Message 4 of 5
(3,674 Views)
Solution
Accepted by topic author cappa
If you had done a search for that error code or message, you would have seen numerous related posts and all providing the same answer. You have a single convert clock for analog out and the DAQmx driver will simply not allow you to create more than one task for the resource. As you have already noted, you can use a single task with multiple channels.
0 Kudos
Message 5 of 5
(3,670 Views)