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.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

generating analog voltage output in increments with simultaneous analog input voltage acquisition

Solved!
Go to solution

Dear all,

 

I am using a new NI PCIe-6363, X Series DAQ-card which is connected to a BNC-2120 connector block with analog outputs and inputs. The operation system is Windows 7 (32-bit) with Labview 2010 (32-bit) - Full Development System.

 

However, I am new to DAQmx and was wondering if somebody could help me with the following:

 

Situation:

I need to control an external instrument using an analog output voltage from the DAQ-card. Using the attached VI (Output_Input_IncrementLoop_1b.vi), I want to generate a constant analog output voltage starting at -2.6 V which is then increased by a certain voltage step (e.g., 0.05V) during each iteration of the while-loop until the maximum value of +2.6 V is reached. This analog voltage output, which is increased in increments, is generated in the case-structure (case 0) located in the while-loop.

 

Furthermore, during EACH iteration of the while-loop (i.e., after the constant output voltage value has been set in case 0) I need to acquire n-number (e.g., 256) successive analog voltage values from an external instrument. This should happen via the analog input voltage channel on the DAQ-card and is shown in the case structure (case 1) located in the while-loop.

 

In a future step the voltage values acquired during EACH iteration of the loop will be averaged. The averaged value will then be displayed. Finally, by displaying the averaged voltage value from each of the loop-iterations, a signal (e.g., spectrum) will be recorded.

 

 

Problems:

 

  1. When running the VI, I am getting the Error-200278 after the final loop iteration (please see attached screenshot). Why and how do I fix this?

 

Please note that as a safety measure to the external instrument I have included min. and max. voltage limits via true/false structures.  This part of the program was previously working fine before I introduced the DAQmx VI’s.

 

  1. I noticed that there is a problem with the accuracy of the analog output voltage values For example, the program feeds -2.45 V into the “DAQmx Write.vi” but at the BNC analog voltage output I am measuring -2.443 V using a voltmeter.  How do I fix this?

 

  1. The acquisition of n-number (e.g., 256) successive analog voltage values during each iteration of the while-loop is not working properly.  What am I doing wrong?

 

 

It would be great if somebody could help me with these issues.

 

Thank you,

 

beam

 

Download All
0 Kudos
Message 1 of 8
(8,075 Views)

Dear all,

 

I have cleaned-up my previous example code (new code see attached "Output_Input_incrementLoop_4.vi").

 

As explained above, I need to acquire n-number (e.g., 10) successive analog input voltage values during EACH loop iteration but ONLY AFTER a specific analog output voltage has been set during each loop iteration to control an external instrument. The acquired n-number of successive analog voltage values are then averaged and displayed on a XY-graph.

 

For trial-purposes, I then connected the analog output via BNC-cable to the analog input.  After program execution the XY-graph should display a straight line of data from -2.6 V to +2.6 V in steps of 0.05 V increments (i.e., XY-graph:   x-axis: analog voltage output, y-axis: mean of analog voltage input amplitude).

 

However, I receive an buffer error -200609 and generating no output signal or acquire an input signal.

 

It would be really helpful if somebody could help me out and tell me what my mistake is.

 

 

Best regards,

 

beam

 

0 Kudos
Message 2 of 8
(8,049 Views)

Hi Beam,

 

You seem to be starting and stopping your DAQmx read VIs within your while loop. For your DAQmx Write, writing before the DAQmx Start Task vi is correct; simply move these two VIs to start before your while loop does. Similarly, move the DAQmx Start Task for your DAQmx Read vi to the left of your while loop. Starting the task before the while loop starts is a more efficient way of running DAQmx tasks. Your timeout error is likely occurring because you have a DAQmx Stop Task vi for your Write task before you read the data, so the Read VI cannot read any data and then times out. Move your Stop Task VIs to the right side of your while loop. Finally, use the DAQmx is Task Done VI to check on the status of the Write VI, instead of the Wait Until Done VI, which you don't need. The examples that ship with LabVIEW do a good job of illustrating many of these concepts with DAQmx. To find them, go to Help>>Find Examples, and then check under Hardware Input and Output>>DAQmx, and look at the continuous Voltage acquisition and generation examples.

 

As for your error 200609, if the above steps do not resolve it, check the following Knowledge Base article on our website: http://ae.natinst.com/public.nsf/webPreview/34B9B5A331DE0E18862571F80072FAEA?OpenDocument.


Best,

Dan N

Applications Engineer

 

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

Hi Dan,

 

Thank you very much for your help.  However, I am still having trouble getting this to work properly.  I have looked through the examples provided by Labview and have no problen getting a simple analog output voltage example or an analog input voltage example to work seperately.  However, I did not find much information about my situation.

 

 

I have deleted the Wait Until Done vi and the DAQmx Stop Task vi which were placed after the DAQmx Write vi.  Instead I included a DAQmx is Task Done vi after the DAQmx Write vi (please see attached example).

 

I tried to move the DAQmx Write vi and its DAQmx Start Task vi together out of the while-loop as suggested but this does not work as I have to do the following (as previously explained):

 

loop iteration  (1): set a constant analog output voltage (e.g., -2.6 V) and then AFTER this acquire n-mumber (e.g., 10) of voltage samples.

 

loop iteration (2): increase the constant analog output voltage to e.g., -2.6 V + (1* voltage step) and then AFTER this acquire the next n-number (e.g., 10) of voltage samples.

 

loop iteration (3): increase the constant analog output voltage to e.g., -2.6 V +(2* voltage step) and then AFTER this acquire .............

 

I then moved the DAQmx Start vi which was located after the DAQmx Write vi outaside the while-loop. This soved the buffer error -200609.  I do not understand how I would move the the other DAQmx Start vi which belonges to the DAQmx Read vi outside the while-loop as this Read has ALWAYS to occur AFTER the output voltage was set (as explained above).

 

Still it does not work properly - what am I doing wrong?

 

 

Best regards,

 

beam

 

0 Kudos
Message 4 of 8
(8,030 Views)
Solution
Accepted by topic author beam

Hi Beam,

 

Putting your write operation in the while loop is correct since you need to update your write value with every iteration, so that should work fine. As for the DAQmx read, you can put the start operation to the left of the while loop and only have the read operation in the while loop, because the DAQmx Start Task VI does not actually initiate the read, it only places the DAQmx task into the Running state. The task will not actually read data until the DAQmx Read VI is called, and you only have to call the DAQmx Start Task once, even if you call the DAQmx Read task multiple times. The DAQmx help explains the DAQmx Task State Model, as does the following link under "State Machine:" http://zone.ni.com/devzone/cda/tut/p/id/3021 . Therefore, in your particular application, I would call the DAQmx Start Task on the left of the while loop, call the DAQmx Read VI as many times as you need to, and then call the DAQmx Clear Task VI on the right side of the while loop. You do not need to use the Stop Task in the while loop. I have attached a screenshot of how best to wire all of these tasks. 

 

If the above steps do not work properly, then post back and say how specifically your VI is not working, and we can continue to troubleshoot. 

 

Best,

Dan N

Applications Engineer

Message 5 of 8
(8,015 Views)

Dear Dan,

 

Thank you so much for your help!  I am beginning to understand how the DAQmx concept works. I have made the corrections in the program (see attached) but when executed the Read vi and Task Done vi showed the Error -200278 "Attempted to read a sample beyond the final sample acquired".

 

I then switched the analog input channel sample clock from finite acquisition to continous acquisition (i.e., the NI article "Error -200278 at DAQmx Read" suggests this solution if the Read vi is inside a while loop).

 

This solved the 200278 error but in return created Error -200279 at the Read vi following Task done? vi -"Attempted to read samples that are no longer available. The requested sample was previously available, but has since been overwritten".

 

I then found the NI article "Why Do I Get Error -200279 from my DAQmx Read VI or Property Node?" and included a DAQmx property node before the Read vi to check the status of available samples per channel.

 

I discoovered that in finite acquisition mode all requested samples are available but the Read vi returns Error -200278. However, at continuous acquisition mode, 0 samples of the requested samples are available and the Read vi returns Error - 200279.

 

How can I fix this?  I read in the documents that this could be a buffer-problem created by the execution-speed of loops or when trying to create a file and save date?

 

Best regards,

 

Beam

 

0 Kudos
Message 6 of 8
(8,005 Views)

Dear Dan,

 

In addition to my previous email (i.e., about the Errors -200278 and -200279 and the available samples), I have tried the following after reading through many posts dealing with DAQmx buffer issues:

 

1. Switched the AI sample clock back to "Finite Samples".

 

2. Increased the while-loop speed via the "scan interval" control at the front panel and also increased the number of samples to 256.

 

3. Included 2 additional DAQmx Read property nodes into the program (i.e., the first after the AI sample clock to overwrite unread samples; the second before the AI Read vi to set the "Relative To" and "Offset" properties.

 

4. Wired a -1 constant to the AI Read vi.

 

 

With these actions I do not see the Error -200278 and -200279 anymore.  However, when connecting the AO Write cannel to the AI Read channel (via a BNC cable at the connector block), I am getting a constant AI voltage value of 2.28 V.  This cannot be true as the AI voltage values should be increasing in the same way as the AO voltage values!

 

I checked the AO voltage values with a voltmeter and they are working fine.  So the problem is still with the AI.

 

What am I doing wrong?  Is there maybe another problem with the buffer or how to read the data out of the buffer?

 

 

Best regards,

 

Beam

 

0 Kudos
Message 7 of 8
(7,995 Views)

Dear Dan,

 

I found the problem - wrong setting of switch at the AI BNC connector block (i.e., was switched to thermo-couple).

 

So your suggestion from 10-14-2011 is working fine!

 

 

Thank you very much for your help.

 

 

Best regards,

 

Beam

 

0 Kudos
Message 8 of 8
(7,977 Views)