From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generate Waveform

Hello,

 

I would like to generate a voltage waveform with multiple phases (see figure below) where the paramaters (amp, duration, etc) of each phase is independently controlled.

 

A, B, ... E are single phase.

waveform.gif

 

The goal is to have the ability to generate a waveform similar to this, while changing the parameters of any phase I want while the program is running.  The waveform is delivered to a printced circuit board via a DAQ.  To validate that the waveform I generate in LabVIEW is correct, I measure it using an oscilloscope.  With my current program (attached), I cannot get the waveform I generate in LabVIEW to match what I scope. Spcifically, the time scale is not correct.  Any help would be appreciated, and please let me know if any more info is needed.

 

Thanks,

Brandon

0 Kudos
Message 1 of 11
(3,648 Views)

Hello Henley,

 

First off, welcome to LabVIEW Community!

 

Now, I have noticed that in your first DAQ Assistant VI that takes in the waveform (Source) you generate, the Timing Settings-> Generation Mode (under Configuration tab) are set to N Samples. You might want to change that to Continious Samples to continiously generate data, which you can then see on the scope. Also, make sure you check "Use Waveform Timing" in the Timing Settings.

What kind of results have you observed on the scope so far? Does the signal have the correct shape? What is the difference between the time scale you generate and the one you observe on the scope?

It seems that the waveform generation part of your code works fine, and the problem lies in the way the data is being written (time-wise) to the analog output of the DAQ card. Btw, what DAQ card are you using?

Finally, another way to write an waveform to one of the analog outputs of the DAQ card is to use NI-DAQmx Write VI (Analog 1D Wfm).

DAQ Assistant is a quick way to generate/acquire data, however it lacks some of the customization options.

Everything you can do with DAQ Assistant can also be acompished with basic DAQ functions on the Measurement I/O -> NI-DAQmx pallete. 

 

Here is an article that will you get started on using those functions: Learn 10 Functions in NI-DAQmx and Handle 80 Percent of Your Data Acquisition Applications

 

 

 

Mikhail
RF Toolkits, Product Support Engineer
National Instruments
0 Kudos
Message 2 of 11
(3,620 Views)

Thank you Mikhail,

 

Okay, I will go back to Continuous and use waveform timing.  What should I set the input DAQ Assistant to?

 

The main observations are these:

 

-Each input phase is exactly 1/10th the size the output (so if I make the duration of a phase in the Source 1 sec, the oscilloscope reads 0.1 secs for that phase).  I found that I can sort of fix this if I make the number of written samples and sampling rate for both DAQs = 10000, and set the sampling rate in the front panel to 10000 as well.  I'm not sure how to make sense of this, though, just worked...  If I up the sampling rate in order to produce higher frequency waveforms, I get an error telling me to reduce the sampling rate or the DAQs buffer.  I couldn't figure out how to reduce the buffer. 

 

-The waveform does not hold its shape with time.  It will be a square wave, then look like noise/nothing, then become a square wave again.

 

-The waveform also loses resolution at about 0.1 ms/phase.  The edges of a square wave dull out.  My circuit can handle about 1k Hz... This is not crucial, though.  

 

-Amplitude is fine

 

-The shape and time scale of the waveform I read on the scope matches that displayed in the input waveforms (one input [Solution] is the load across an electrode; the other [Current] is the calculated current through that load [curent = measured voltage/1k]).  This lead me to believe that the waveform I see in the Source graph is not being ouputted to the circuit; a 10-Hz faster waveform is...?

 

-I am going back to my lab later today, but off top, I think the four digits of the DAQ is 6221. It's pretty old; the BNC connecter is also pretty old. 

 

Oh, another thing I want to achieve is equal time scale for all three graphs.  Right now, if I make each phase of the output 1s, giving me a 5s pulse, the input graphs only go to 1s.  If I manually extend the time axis of the input graphs to 5s, there is no data from 4 to 5s.  Same idea if I make each phase 0.1s (no data past 0.1 s in the input graphs), etc.  My circuit produces negligable phase lag, so this should be doable.   

 

 

Thanks again for you help,

Brandon

 

 

0 Kudos
Message 3 of 11
(3,606 Views)

Hi Brandon,

You can also set the input DAQ Assistant to Continious Samples for now.
Now, to configure the buffer size you have to beyond DAQ Assistant and use some of more customizable DAQmx functions.
Have a look at the following example:
Continuously Generate Voltage using Internal Sample Clock


Finally, to fix your time scaling problem you have to adjust the  "Samples To Read" and "Rate" parameters in DAQ Assistant.
In simple terms, if "Samples To Read" = "Rate" then you will see only 1 second of data on your graph. If "Samples To Read" = "Rate" x 5 you will see 5 seconds of data.

Mikhail
RF Toolkits, Product Support Engineer
National Instruments
0 Kudos
Message 4 of 11
(3,581 Views)

Thanks,

 

I made some changes to customize the DAQs.  Right now, I can produce a pulse with each phase at 1s and 0.1s.  But when I got down to 100 micro secods (where I need to be), I get all different kinds of errors, that, if I fix, produces different error, and back and forth.  For instance, it will tell me reduce the buffer size, then to increase it, then to increase the sampling, rate, then to decrease it.  It's really confusing right now.  If you could take a look to see what I might be doing wrong, I'd appreciate it.

 

Brandon

0 Kudos
Message 5 of 11
(3,559 Views)

Sorry, this version might be a little confusing.  I included switches that will allow me to use a certain number of phases in the pulse.  In the input daq, I am trying to display data in the two graphs that is just over the time phrame of the choses phases .  Let me know if that makes sense.

 

Brandon

0 Kudos
Message 6 of 11
(3,558 Views)

Hi Brandon,

 

It seems that when you go down to microsecond level, the default buffer that is allocated when you do DAQ Create Channel is too small.

One way to fix this is to increase the buffer size from 100 (your current size) to 1000.

Here is a good article that explains in more details how the buffer size is allocated in DAQmx:

How Is the DAQmx Buffer Size Allocated for a Finite or Continuous Acquisition?

 

Also, I could not run your VI since it is missing the following dependancy: Basic Function Generation with Duration.vi

Mikhail
RF Toolkits, Product Support Engineer
National Instruments
0 Kudos
Message 7 of 11
(3,534 Views)

Sorry, I did not include the VI I made. 

0 Kudos
Message 8 of 11
(3,519 Views)

In the case where I have the pulse width at 100 microseconds, when I set the buffer size for the output daq to 2000, I am told to reduce the buffer.  When I reduce it by 1 to 1999, I am told to increase the buffer.  Ultimately, there has not been a scenario where I have successfully achieved microsecond range pulses.

0 Kudos
Message 9 of 11
(3,518 Views)

I updated the VI.  I am able to produce pulse with 100us/phase now.  The two issues I am facing still is that:

 

1) I get Error -200560.  

 

Possible reason(s):

Wait Until Done did not indicate that the task was done within the specified timeout.

Increase the timeout, check the program, and make sure connections for external timing and triggering are in place.

 

2) The input graphs are still not over the correct time scale even when I have the correct number of samples to read

 

3) Sometimes, I get an error saying that the buffer sizes are not correct, and sometimes I don't. 

 

 

Download All
0 Kudos
Message 10 of 11
(3,502 Views)