08-07-2014 06:52 AM
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
Solved! Go to Solution.
08-07-2014 07:50 AM
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.
08-07-2014 09:41 AM
Scratch that. It works for 1 AO and 1 AI, but as soon as I add a second AI everything fails.
08-07-2014 09:46 AM
08-07-2014 09:54 AM
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
08-07-2014 10:06 AM
08-07-2014 10:12 AM - edited 08-07-2014 10:27 AM
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
08-07-2014 10:32 AM
08-07-2014 10:35 AM
Thank you Dennis, I did not know this.
I'll give it a shot.