From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

error -200288 AO

Solved!
Go to solution

Hello!

 

I'm programming an analogue output to which I write a single voltage value in 'manual mode' or a waveform in 'scanning mode' depending on the user input. The user can switch between them. The whole program is rather big, so I'm just posting some scrrenshots of the vital parts:

 

1. I initialize the channel to output a single value (Img1).

2. When the user changes the output mode from manual to scanning, a waveform is generated (Img2a). When switching from scanning to manual mode this step is left out because no waveform is required. The respective sub-VI changes the timing of the task to sample clock. I'm not sure if this is really necessary to generate the waveform. I could probably just use the desired sample clock rate instead of reading out the actual value. I copied this part from a previous version of the program. It probably had a reason to be there but I cannot ask the person who wrote it.

3. A sub-VI stops the task, resets the timing and writes either the single value (Img3b) or the waveform (Img3a) depending on the chosen mode. Then it starts the task again.

 

My problem: When switching to 'scanning mode' i.e. writing the waveform, I get the error -200288 saying I'm trying to generate samples after the final sample. The help says I must first stop, then change and restart the task again to rearm the software trigger. I believe that is what I did. So I don't understand why I'm getting this error. The funny thing about it is that the error only appears when I switch to 'scanning mode' the second time after I start the VI. The first time writing the waveform seems to work just fine without any errors. I really don't understand why it doesn't work repeatedly. Any advice is appreciated. Thank you in advance.

 

 

0 Kudos
Message 1 of 18
(4,183 Views)

Hi,

 

I am almost sure, you´ve visited the following sites, nevertheless i would recommend having a look on it:

 

 

To provide a more specific help, it would be great if you can provide an cut down example vi.

 

Best regards

Thomas

0 Kudos
Message 2 of 18
(4,131 Views)

Hi Thomas,

 

Thank you for your reply. I indeed found those two posts that you linked, but they didn't really help me. So I made a Test.vi with the parts of my code that produce the error. It behaves like the original but is less configurable. I attached it with the two sub-VIs that are used in there. Maybe you can find the bug. Thank you.

 

Best regards,

 

Shell17

 

 

 

Download All
0 Kudos
Message 3 of 18
(4,099 Views)

In the example code (Test.vi) you showed, you're just doing a single channel, single sample write.  No clock configuration needed.  Remove the DAQmx Timing property node from your AO task configuration.

 

In the other code, you do understand that you can't change the task type on the fly, right?  That is, you can't go from single channel, single sample to single channel, multiple samples in the same task.  Maybe you're not doing that, although your original post says that you are.  You also aren't pre-writing any data to the buffer after stopping your task, so when you call DAQmx Start, there's nothing in the buffer to write.  You need to write something to the buffer, THEN call Start.

 

Does that make sense?

 

0 Kudos
Message 4 of 18
(4,090 Views)

Hello DianeS,

 

Yes, you got it right. Switching from 1Ch1Smpl to 1ChNSmpl was actually what I wanted to do. I was not aware that it is not possible in the same task. I guess I have to remove that part. Do you have any suggestions how it could be done to switch between putting out a waveform and a single value on the fly? Do I have to make two tasks? Can two tasks that write to the same output coexist? I always get an error message when I try that saying the resource is used by some other task. Or do I have to delete and recreate the task every time I want to switch? Thanks for the advice.

 

Best regards,

 

Shell17

0 Kudos
Message 5 of 18
(4,080 Views)

Hi Shell,

 

What I would suggest is that you create one task which always outputs a waveform.  When you want to output a single, constant value, instead build a waveform where all of the data elements are your constant output voltage.  Does that make sense?  Do you know about the "Build waveform" function?

 

Another thing you might not know...if you want to output different data for different loop iterations, you need to set up your task for non-regenerative operation.  (I'm not 100% clear on whether you'll be generating output continuously, or only in chunks.)

 

To specifically answer your questions, though, you cannot have two tasks that access the same resource.  You can delete and re-create the task every time you want to switch, but that's very wasteful and results in a slow memory leak.

 

I think you are best off adapting your single-value write to use a waveform data type.  So if you want to output, say, 2V at 1kHz, build your waveform like this:

 

create wfm with const value.png

 

Use that (modify as appropriate) for your single-value output.  Then use your regular waveform for your waveform output.

 

Hope that helps!

0 Kudos
Message 6 of 18
(4,068 Views)

Hi DianeS,

 

Thank you for your help. I will try making my constant value into a waveform. It may take a while to rewrite the code to test it, but I will let you know if it worked.

 

Best,

 

Shell17

0 Kudos
Message 7 of 18
(4,057 Views)

Sounds good, give a holler if you need more help!

0 Kudos
Message 8 of 18
(4,037 Views)

Hi DianeS,

 

Your tips made my code much simpler, but unfortunately it didn't solve the -200288 problem. The main problem seems to be that you cannont rewrite a waveform to an analogue output as long as you allow continous generation - even after you have stopped the task. I attached a very simple example file to prove that.

 

I found this (http://www.ni.com/example/29872/en/) example from NI which does rewrite a waveform. But it has to provide the new data continously for every buffer which is consuming resources. I don't need that for my application. I expect the user to rarely do changes to the waveform. So I would like to keep the automatic regeneration of data to avoid supplying new waveform data for every buffer. Only when the user changes the input, I want to generate a new (modified) waveform and output it, then keep regenerating the data until the next change. Do you know any way to do that? Thanks in advance.

 

Best regards,

Shell17

 

PS: I just found the following: http://digital.ni.com/public.nsf/allkb/C711E912243C8B7886256D260069B63B

The second paragraph under DAQmx Stop Task VI describes my problem. The only solution they suggest here is to clear the task which means I need to create it anew to output more data. That is not so satisfying.... But it might in fact be the only way. Unless someone has a better idea...?

0 Kudos
Message 9 of 18
(4,022 Views)
Solution
Accepted by topic author Shell17

Indeed...it's timed acquisition.  It's dependent upon the samples being output at a specific rate, which your inner while loop interferes with.  While that inner loop is waiting for someone to press the button, that buffer's filling up.  Since you don't call DAQmx Write soon enough, that buffer is overwritten, and you get an error.  Does that make sense?

 

Look at this.

0 Kudos
Message 10 of 18
(4,007 Views)