04-06-2010 04:07 PM
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
Solved! Go to Solution.
04-06-2010 04:22 PM
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.
04-06-2010 05:50 PM
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
04-07-2010 09:57 AM
04-07-2010 12:47 PM
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,
04-07-2010 02:17 PM
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
04-08-2010 10:19 AM
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,
04-11-2010 02:53 AM
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
04-12-2010 11:58 AM - edited 04-12-2010 11:59 AM
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,
04-12-2010 12:28 PM