LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to modify a DAQmx task programatically without stopping it?

I'm currently generating a signal with the NI 4461 card enclosed in a PXI chassis. I would like to modify dynamically some characteristics such as frequency, amplitude and so on, without stopping my task. By doing so with an event structure, an error (referred as -50103) occurs.

 

Thanks for your answers.

0 Kudos
Message 1 of 8
(3,306 Views)
Please post your code as an attachment. Seeing your code will make it a lot easier for us to understand the cause of your error.
Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 2 of 8
(3,291 Views)

Thank you for your answer,

 

please find the attached file containing a modified version of my VI. In order to keep my program from generating errors, I have added a "Stop task" VI. But of course this is not the normal behaviour I would like to implement as you have understood from my preceding message. I hope you will find more insights concerning the problem I'm confronted to.

0 Kudos
Message 3 of 8
(3,279 Views)

Sorry, but there are several issues with your VI.

 

First and imho most important point is:

Do not mix event based programming with "classic" state machines in the way you did. This will lead to code which is difficult to maintain. 

 

Second point:

Why do you split the creation of the task (which contains timing) and setting of trigger and additional timing info? This makes no sense.

 

Third point:(This is propably the most important for you)

You have to know that there are properties which can be changed while the task is running, but most are not. So you have to define:

- What properties are needed in order to change the output to the desired new setting?

- Which of those properties are changable during runtime?

 

Please note that i don't see any parameters you want to change.....so please let us know.

 

Norbert 

 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 8
(3,276 Views)

I don't speak French, so I don't understand the label and enum strings in your code, but I've taken a quick look at your vi.

The Timeout case of your event structure has a Default on the state machine terminal. This perhaps means that 100ms after your task starts, you change to the Paramétrage de la waveform state, which means the DAQmx Clear Task subvi does not ever get called.

Message Edited by Thoric on 11-18-2009 02:51 PM
Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 5 of 8
(3,275 Views)
I wrote "stop task.vi" but I meant of course "clear task.vi". Anyway, the reason why I added this subvi is because my program generated the error code -50103 which means that the ressources had already been reserved for another task. As implemented now, my this VI does'nt generate errors anymore but I cannot modify dynamically the generation parameters neither.
0 Kudos
Message 6 of 8
(3,260 Views)

The parameters I would like to change dynamically are frequency, amplitude of the waveform and the number of samples (named "nb éch." on the front panel) from which the VI calculates the sampling rate.

 

Concerning the points you pointed out, do you think it may be useful to use a state machine with a queue for example?

0 Kudos
Message 7 of 8
(3,255 Views)

I am wondering why you want to change the namber of samples per waveform during runtime. Why is that?

 

Changig the frequency is easy if you use an external clock. Simply increase the external clock to increase the signal's frequency. If the DAQ device you are using has an onboard counter available, you can use this as external clock source. You can change the frequency of counter outputtasks "on the fly" (during runtime).

 

If you want to change the amplitude or shape of the signal, this is a bit more tricky. This requires non-regenerating buffered output, examples for this are available. The catch is, that you have to make sure to "refill" the buffer right on time. If you mess that up, you will receive an error.

 

hope this helps,

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 8 of 8
(3,206 Views)