Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

USB-6009 Simultaneous Software Timed Analog Output/Input

Solved!
Go to solution

Ladies and gents,

 

I have been working on a LabVIEW interface for a potentiostat I designed and built. I am not very experienced with LabVIEW, but do have programming experience with a variety of other languages (I had originally intended to use a FPGA for this, but was requested to write a LabVIEW VI first).

 

The goal:

 

I wish to output a voltage signal (initially composed of ramps) and measure the voltage of an operational amplifier configured as a feedback ammeter (using the feedback resistor value and voltage to calculate current) connected to an electrochemical cell. The feedback resistor is selected using an autoranging function (although I wrote a previous version with manual control) that ouputs TTL values through DAQ Assistants to select the relevant MUX channel. I then try to save the data in a spreadsheet.

 

The problem:

 

I am using a USB-6009 DAQ and I am aware this does not have a hardware clock. From reading around it seemed apparent the best way to output the voltage waveform was using the DAQmx package to define a write function within a software-timed loop. The problem I am having is that I cannot reliably synchronise the output with the input and I also have some errors relating to the DAQ resources being reserved (Error 50103). I think the way to resolve this would be to convert all the DAQ Assistants to DAQmx equivalents and try to bundle their execution- this is where I stumble. I tried to write a simple VI that shared a software-timed loop to read and write but had issues related to the AI min value (Error 200077).

 

General issues:

 

The way I start the write/read process (using a boolean switch) is very weak and does not feel robust. Ideally I would like some form of indicator to notify the user when the write/read process is running and when it has terminated.

 

My error handling is terrible but I cannot find much to read on the basics.

 

I only use one step sequence and I believe I should have more.

 

Once I hit start, the VI requests the file name for the spreadsheet- at first I was worried that the data would not be correctly captured, but I think this is okay as the file is generated then modified. It would be better if the user was prompted for the file name once the data collection was complete.

 

 

 

Any suggestions or assistance would be greatly appreciated. Thank you in advance.

 

Kindest regards,

 

Julius

 

0 Kudos
Message 1 of 9
(5,104 Views)

I think I have solved the timing issue using the following thread:

 

http://forums.ni.com/t5/LabVIEW/analog-inputs-and-digital-outputs-usb-6009/m-p/2389488#M741206

 

I just had to take care in ordering the DAQmx blocks and wiring the error in/outs.

 

Any suggestions regarding my other faults would still be welcomed.

0 Kudos
Message 2 of 9
(5,095 Views)

Scratch that. It works for 1 AO and 1 AI, but as soon as I add a second AI everything fails.

0 Kudos
Message 3 of 9
(5,082 Views)
Fails how? Are you getting a resource reserved error? That has been discussed numerous times and the Fox is always the same - a single task with multiple channels.
0 Kudos
Message 4 of 9
(5,079 Views)

Thank you for the reply Dennis.

 

I do indeed get the resource reserved error (Error 50103). I am just a little confused as two why I can't read two independent analog channels in the single software-timed loop and thus how to resolve the issue. I just tried to place the two analog read blocks in a step sequence (I assume this executes one read before the other, with the total read frequency set by the software timed loop (100Hz to remain below the maximum output frequency of the USB-6009 DAQ (150Hz)) but to no avail.

 

 

To summarise, within a single iteration of the software-timed loop I am aiming to:

write to AO(0)

read AI(0) and AI(1)

 

 

Kindest regards,

 

Julius

 

 

 

0 Kudos
Message 5 of 9
(5,076 Views)
You can't have two two separate hardware timed tasks since there is a single convert clock. This has been explained numerous times as I mentioned. You simply add the additional channel to the single, existing task.

A timed loop is of little use on Windows. The hardware timing of all that you need. Also, a sequence structure is never retired.
0 Kudos
Message 6 of 9
(5,072 Views)

Thank you again Dennis.

 

I don't beleive the USB-6009 DAQ supports hardware timing. I have found that limiting the software-timed loop frequency to 100Hz is satisfactory in Windows- I ran lots of tests and found there is very little deviation between expected and actual duration.

 

I attached an image of a section of some trial code to try and read two analog channels in a single loop. As previously mentioned, the code works when writing from one channel and reading from another, but fails when I try and wite to one channel and read from two channels.

 

Kindest regards,

 

Julius

0 Kudos
Message 7 of 9
(5,069 Views)
Solution
Accepted by topic author J_Hammond
The 6009 supports hardware timed analog input. Even with 1Samp mode, your code could be simplified with a single task and multiple channels (dev1\ai0:1). Then use Nchan 1Samp.
Message 8 of 9
(5,062 Views)

Thank you Dennis, I did not know this.

 

I'll give it a shot.

0 Kudos
Message 9 of 9
(5,058 Views)