LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous Analog Input and Output with USB-6009: timing output

Hi,
 
I have a USB-6009 and want to set it up to continuously log Analog Input data and also to output a continuous Analog Output signal (such as a sine wave or ramp which I give through a spreadsheet with 1000 data points). Please see attached the VI that I have worked out so far for this purpose.
 
1. When I run the above VI, my analog output signal (that I am logging with time) appears to not have a constant time interval between two points. For example, running the VI with a Software Loop Time of 20ms, at times the time interval between two AO points is 0.015s and at others it's 0.032s. I need this time interval to be constant. How can I do this?
2. When I stop running the VI the USB-6009 is still giving me a voltage (at the value it was at when I stopped the programme). Is this voltage going to be at the rate it was last running at, i.e. say if it was giving me 4V at 150S/s when I stopped the programme will it continue to give me 4V at 150S/s?
 
Any suggestions on improving my VI are much appreciated as well.
 
Thank you in advance,
Chanchala
0 Kudos
Message 1 of 4
(4,198 Views)

Because the inexpensive 6009 has software timed analog output, you are subject to all of the vagaries of a non-deterministic OS. You simply don't have enough control over what windows is doing and how it will periodically interupt your software. You can experiment with changing the priority of the VI (VI Properties>Execution) and you can also try the timed loop. In the long run, if you want precise timing for you analog output, you should upgrade to a better DAQ board.

When you stop the VI, the analog output is the last value you set with the DAQmx Write. There is no rate associated with this, it's just keeping the last value. When the loop finishes, you could do another DAQmx write to set the output voltage. Put this before the DAQmx Clear Task.

You can also probably gain a bit of performance by using one of the low level file write functions. I think Write LabVIEW Measurement File opens and closes the file each time it is called. You could also write to a queue and have the file write in a separate loop. Your wiring style could be much improved but that really doesn't affect performance. You should not hide the while loop's termination or iteration terminals behind the case statement. Line up all of the DAQmx functions so that the task and error wires are straight and don't cross. To avoid the coercian between data types, the Unsteady Flows control and the Iteration Number indicator should not be DBLs. They should both be an I32 data type

Message 2 of 4
(4,192 Views)

Hi,

Thank you very much for your suggestions. I tried changing the priority and the first time it ran with a more constant time interval between Analog Output values, but when I re-ran (having changed nothing at all and ensuring the high priority was still on and no other applications running on my PC) it reverted back to the bad timing. No idea why.

What do you mean by 'low level file write functions'? Also how do I write to a queue and have the write function in a separate loop. I tried this and it did not work. An example would be much appreciated.

thanks again,

Chanchala

 

0 Kudos
Message 3 of 4
(4,179 Views)

There are always other applications running. Open windows task manager and look at the Processes tab. Unless you go to a real-time OS and RT LabVIEW, you will always experience some amount of jitter. You'll have to decide how much is acceptable.

Low level file write functions are functions like Open/Create/Replace File, Write to Text File, Close File. The Open is called before the while loop starts and the Close File is called when the while loop finishes. The Write to Text File (or Write to Binary File) is inside the while loop and you save the overhead of opening and closing the file with each iteration of the loop. the binary option ios faster than writing to a text file. You also have the TDMS option. This is also faster than text.

There are some shipping examples and design templates that you can look at. Select File>New... and then expand the VI>From Template>Frameworks>Design Patterns. You'll see the Producer/Consumer and Master/Slave templates. Search the examples for such keywords as queue and files.

Message 4 of 4
(4,174 Views)