LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

passing DAQmx task out through a shift register

 
Labview 8.2
DAQmx 8.3
 
I have a situation where I want to pass the 'task out' from a task that I created with DAQmx Create Channel(CO_Pulse Generation - frequency) through a shift register in a while loop. Inside of the loop there is a case statement where case 1 is to open the channel, case 2 is to change the frequency of the pulse, and case 3 is clear the task. I intend to go through the while loop a few hundred times using case 2 and then close the task using case 3.
 
Case one executes with OK passed through the error wire. The task name is _unnamedTask<1>
 
Case 2 bombs at the DAQmx Write (Counter frequency 1 Chan 1 Sample) with an error -200429 : the task/channel is an empty string.
 
Is this idea possible? How can I keep a valid task object through the iterations of the while loop?
 
The original code is in an example that I downloaded from NI.com: Pulse Width Modulator - daqmxb.llb
 
 
0 Kudos
Message 1 of 5
(4,085 Views)
Unlike the old NIDAQ TaskID, the DAQmx  tasks can't "usually" be passed through a shift register.

But there is a work around.

In the Advanced Task Options palette, you'll find the DAQmx Create Task.vi.  Call this just before your call to the DAQmx Create Channel.vi.
The only input you'll need is the AutoCleanup, which you set False.  Pass the TaskOut to the TaskIn of the Create Channel function.

If auto cleanup is FALSE, LabVIEW does not automatically destroy the task until you exit LabVIEW. You'll have to use DAQmx Clear Task.vi to manually destroy the task.
0 Kudos
Message 2 of 5
(4,067 Views)
How troubling. I currently have a VI that does exactly this, though it seems to work fine. Do you know more about the conditions in which it isn't supposed to work?

I'm using something derived mostly from the "Acq&Graph Voltage-Int Clk-HW Trig Restarts" example VI.
0 Kudos
Message 3 of 5
(4,057 Views)
hi there
 
i'm holding the tasks in shift registers all the time, and i never had a problem. please check the attached vi if they work on your system. post your code, maybe it's just a little wiring error that clears the shift register (double check the outgoing tunnels of the case struct for "use default if not wired" and overlaying tunnels).
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 4 of 5
(4,048 Views)
Chris,
Your Main VI is acting like a wrapper which prevents the task in the sub vi's shift register from being destroyed.
Your sub vi will not work by itself.
But the beauty of creating the sub VI that actually contains the shift register is that you should be able to run it by itself to control whatever device/task you wish to.
By adding the DAQmx Create Task.vi. like I described above, you can do that.

0 Kudos
Message 5 of 5
(4,042 Views)