Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Analog retriggerable/continuous output from a custom waveform?

Solved!
Go to solution

Hello,   

 I am trying to periodically output an analog signal using the USB-6211 and Labview2009. I've looked at various waveform examples including the retriggerableAO.vi example, but I can't seem to figure out how to send a custom "Waveform" to the buffer (perhaps terminology is the issue). In all the examples(including waveformbuffer) I ran across the only waveform options are sine, square, etc.  I previously posted on this board looking for hardware suggestions (link here) and explained what I am trying to do and got great help. To summarize, I would like to read in a  "waveform" from a text file,  send it to the buffer of the usb-6211 and then keep sending that to an analog out channel . Concurrently, I will be using the start of the analog out task to trigger a digital signal once per cycle as well. 

 

I have gotten as far as creating the waveform, but am stuck at figuring out how to get it into the buffer and setting the frequency, etc.

 

Thanks,

 

Gabe

0 Kudos
Message 1 of 16
(5,360 Views)

Have you looked at the example called 'Gen Mult Volt Updates-Text File Source'? Providing a waveform from a file is no different than the examples that use a standard waveform if you are actually creating a waveform data type. This would require your text file to include sample rate or dt information.

 

Post your text file and the code you have written so far.

0 Kudos
Message 2 of 16
(5,356 Views)

Hi Dennis,

 Thanks for the quick response. I had looked at the 'Gen Mult Volt Updates-Text File Source', but I went back and took another look after your suggestion. I modified my createwaveform.vi to write a waveform file. GenMult   can now read it in, but it only seems to output the waveform once. What I am unsure about is if the example you mention is using the buffer or not during output and what is exactly controlling the timing. (I also have to figure out how to make it loop in a logical fashion). I'm attaching my createwaveform.vi(quite basic) as well as an example waveform. First column is timepoints in ms, second is velocity/voltage output. Ultimately, I would like to be able to change the frequency(or dt) vi the front panel, as well as scaling of the voltage values and I'll have to add in the timing requirements for triggering the digital output.

 

Thanks,


Gabe

Download All
0 Kudos
Message 3 of 16
(5,350 Views)
You can set regeneration mode to false and have the DAQmx Write inside a loop such as show in the Cont Gen Voltag Wfm-Int Clk-Non-Regeneration if the waveform parameters might change with each iteration. Otherwise, you set regeneration mode to true and the output will be generated as long as the task is running. The example with reading a file is purposely set to generate a single waveform and stop. There probably does not exist an exact example of what you are trying to do. You will have to combine concepts from several of the examples. Have you read through Getting Started with DAQmx? You should to get a basic understanding.
0 Kudos
Message 4 of 16
(5,325 Views)
Solution
Accepted by Gacevedo

Hi Gabe,

 

Dennis is correct that it will take some piece-work of modifying existing VIs to fit your need.  As he mentioned, the Con Gen Voltage Wfm-Int Clk-Non Regeneration.vi  example that ships with LabVIEW.  In the example, it can be shown that there is a customized VI used to account for the issues that arise when outputting a waveform of a given frequency at a specified Analog Output sample frequency. 

 

With all of that said, it appears that you want to read from an existing waveform file that you have created and output that waveform to an AO channel.  There are a few things that will be necessary to know before proceeding:

 

-how large is the waveform you are trying to output (5000 samples, 10k, 100k, etc.)?

-what size chunks of the waveform do you want to output (100 samples at a time, etc.)?

-do you want to loop the waveform over and over, or just run through it once?

 

Assuming you have the waveform already and are only going to step through once, here is what I would:

-break large waveform into smaller waveform chunks of a standard size

-import the waveforms into LabVIEW and create an array of waveforms

-bring the waveform into the example that Dennis mentioned before with auto-indexing enabled on the tunnel

-remove the existing waveform function generator from the while loop

-wire in your indexed array of waveform to the data terminal of the DAQmx Analog Output VI

 

It is possible that you will have to play around with the parameters of your waveform and the timing of your VI, but this should be a good starting point.  Please let me know if anything is unclear or if I have misunderstood your initial post.  Have a nice reast of the day.

 

Best,

Adam
Academic Product Manager
National Intruments
0 Kudos
Message 5 of 16
(5,315 Views)

Dennis, Adam,

Thanks for the responses. I have started looking through the NI-DAQmx literature, and it will most definitely help. As to Adam's questions, my waveforms are usually no more than 64 to 128 samples(they are actually velocity waveforms from computation), and I want to keep outputting the waveform until I hit the stop button, or switch to a constant voltage. In case it helps, the waveform is sending voltages to a servo-motor which is running a flow loop (I'm trying to model physiological blood flow). I actually just now played around some more and actually got the output to loop! I forgot about resetting the output to zero when I stop the vi, so I'll have to do that, and also add in the digital out. I'll post my VI when I get it to a functional state, and hopefully there will be some helpful suggestions.

 

Thanks,


Gabe

0 Kudos
Message 6 of 16
(5,308 Views)

Good morning Gabe,

 

I am glad to her that everything is up and working for you.  Please do follow up in the future if you need any advice on the VI when you get further along in the application.  If you are planning on outputting the primary loop over-and-over and then switching to  constant voltage or a zero voltage, you might try out a State Machine VI architecture or an event structure that allows you to change to a different state after you click a button or a condition is met.  There are many ways to go about what you are planning on achieving, but here are a few documents you could review if interested in either architecture:

 

Applications Design Patterns: State Machine

http://zone.ni.com/devzone/cda/tut/p/id/3024

 

Community Example: State Machine for DAQ: AI and AO

http://decibel.ni.com/content/docs/DOC-10176

 

LabVIEW 2009 Help: Event Structure:

http://zone.ni.com/reference/en-XX/help/371361F-01/glang/event_structure/

 

 

Best,

Adam
Academic Product Manager
National Intruments
0 Kudos
Message 7 of 16
(5,283 Views)

 

  Thanks for the links. I started looking over state machines, but I am going to have to spend more time looking over that material. I'll need it to make the VI more functional(adding a constant voltage option), but for the short term, I need some input on synching(and adding an offset) my analog out with a digital pulse(+5V to use as a trigger for some equipment). I looked over various examples, reviewed the suggestions in this thread and ended up trying to combine the Cont Gen Voltag Wfm-Int Clk-Non-Regeneration VI with the Gen Dig Pulse Train Continous.vi  

I don't have oscilloscope access until Monday(currently at home) so I can't test the output, but I have a feeling that even if my vi did work it's pretty inefficient. 

I would also like to be able to have the waveform chart update/scroll, and if possible indicate on the waveform where the digital pulse occurs relative to the waveform.(I'm reattaching the figure of what I'm trying to do from my first thread)

 

 

Any feedback on the VI would be greatly appreciated.

 

Thanks,

Gabe

 

Download All
0 Kudos
Message 8 of 16
(5,246 Views)

Hi Gacevedo,

 

Based on your initial post, assuming it is the post from this thread, you wanted to be able to output a custom analog waveform from file.  It now appears that you would like to output a digital signal at the same time.  Can you explain the digital signal you are trying to output, and to what you are outputting the signal.  Do you need to change the digital signal from a control on your front panel, or will it just be a constant frequency digital pulse train?

 

As for your code, it could be cleaned up a bit.  Your pulse train task appears to be wired into a digital output task as well.  This will most likely not work as desired, and there could be a better way to approach the situation.  There are examples online for synchronizing two task, but it will first be necessary to know what type of signal you would like to output (Frequency, voltage level, pulse train or software timed pulse, etc.).

 

Best,

Message Edited by cyclone2k9 on 04-12-2010 11:59 AM
Adam
Academic Product Manager
National Intruments
0 Kudos
Message 9 of 16
(5,224 Views)
Hi Adam,
Thanks for the response. I just realized that I didn't go into details about the task in this thread(in my mind it's all so intertwined). I wasn't sure whether to continue on this thread or start a new one.
However to answer your question, Yes, I am trying to simultaneously output a digital pulse that will act as a trigger signal for some imaging equipment.

The analog output sends a velocity waveform to a motor driving an experimental flow loop(simulated physiological blood flow). The trigger/(digital out) goes to an MRI machine and triggers it once for each cycle of the analog out. The analog waveform is read in from a file. The trigger/digital out needs to be a short step of +5V and synchronized to the analog waveform because I require several cycles to acquire a complete data set.

The only requirements for the digital signal are
1) +5V, then back to zero(once per cycle)
2)that it repeats at the same frequency as the analog waveform,
3) I need to be able to shift the position of the digital "pulse" relative to the analog waveform(i.e. offset by 1, 2, 4, 100ms, etc) from the front panel .

When I was doing this with the USB-6009 I was outputting two analog waveforms. One was the actual velocity "waveform" and the other was the "trigger" with a bunch of zeros and a step in the middle. I could offset the two by changing the index number on one of the "Read file" commands. I was limited by the software timing, so I moved up to the 6211, and I thought that a digital pulse would be easier to implement.

My confusion with the counters/digital out task is due to my not fully understanding how the counters work. I read over the manual and examples, but I'm not sure if I could use the counter task by itself as a physical output. Most of the examples I found synched an analog input task with a digital out(to start recording data in the software for example)

Hope this makes some more sense, let me know if you need more info.

Thanks,

Gabe
Message 10 of 16
(5,218 Views)