LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous change output signal

Hello everyone,

 

I generate a signals using the daqmx-toolbox (AO-Voltage, Timing, Analog1DWfm_NChan_NSamp, Start). The signal is generated beforehand using the 'Waveform' datatype. 

 

Now I want to change the signal as smooth as possible but I can only produce this two situations.

 

Situation 1:

Stopping the task - writing the new signal - Starting the task changewave.png 

g.jpg

 

The timeout generates problems on the device I am testing.

 

Situation 2:

Directly write in the existing and running task

 

ater.jpgchangewave_orig.png

 

This is even worse, since the signal is not produced correctly. When I only change the amplitude the signal is generated correctly. Only when the frequency is changed the phase seems to cut out.

 

 

Is there a standard/ good solution to change an output signal without such switching artifacts?

0 Kudos
Message 1 of 14
(4,463 Views)

Hi sh,

 


@s.h._tech wrote:

Situation 2:

Directly write in the existing and running task

This is even worse, since the signal is not produced correctly. When I only change the amplitude the signal is generated correctly. Only when the frequency is changed the phase seems to cut out.

 

Is there a standard/ good solution to change an output signal without such switching artifacts?


Those "artifacts" only occur because you are outputting a fractional amount of periods of your sine wave (for situation 2). To avoid them you need to output full periods of the waveforms!

 

(Stopping and restarting the task will always create "artifacts" in the output signal, and should be avoided.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 14
(4,453 Views)

The 'changed' signal is an array of Waveforms (1 full period of the changed signal). The signal is only committed when I press a button.

 

It has to do something with the changed frequency, and therefore the samples generated, since this does not happen when I change the amplitudes.

0 Kudos
Message 3 of 14
(4,444 Views)

Hi sh,

 

how are you setting up the DAQmx task, and how do you generate those waveforms?

It's hard to help from some small images showing only small portions of code…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 14
(4,434 Views)

startwave.png

 

I started from the 'Continous_Voltage_Generation' example.

 

The waveforms are generated using the 'Basic_Function_Generator.vi'

0 Kudos
Message 5 of 14
(4,428 Views)

Without a whole lot more detail about your system, your DAQ device, the purpose of the app, other requirements & constraints, I can only give general & generic advice.

 

IF you are always looking to generate sine waves with 0 DC offset, then by far the most straightforward thing to do is what GerdW said in msg #2.  Make sure you always write full periods of your sine wave.  (Or generally, make sure they always end at the sample just before the next rising zero-crossing.)   

 

If you need a much more general approach, I'd go with something like the following:

 

1. Take time to think about and create a spec for the max allowed rate-of-change for your AO signal.  What rate of change will you consider "unsmooth?"    Note that the max rate of change for a sine wave A*sin(2*pi*f*t) will be 2*pi*f*A.  Your max allowed rate of change better be higher than *that* for your max anticipated sine wave freq and amplitude.

 

2. With this spec, you can use or make rate-limiter code.  Whenever you generate a new waveform, it'll need to pass through your rate-limiter code before being written to the task with DAQmx Write.  This will force all transitions to meet your "smoothness" criteria for rate of change.

    Note that the rate-limiter code will need to maintain memory (unitialized shift register or feedback node) of where the previous waveform left off so it can do its job of blending over to the new waveform according to your definition of "smooth".

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 6 of 14
(4,386 Views)

My whole project entangled and I will need some time to create single Vi with the problem.

 

The approach with the zero crossing only would work with one signal. With multiple signals and a phase angle there would not be a common zero crossing. My signals also have a offset but that should not affect any change. The signal is also generated continously. How can I keep track of the position of the signal

 

For now I can test with a 4 channel function generator triggered via my RS232-card. 

 

I will try to rebuild a simple Vi which demonstrates my problem. Usually I find some examples in the help, but I was unable to find a basic function generator for analog signals.

0 Kudos
Message 7 of 14
(4,347 Views)

I created a Vi which demonstrates my problem. All Daqmx-Vi's are used exactly as I have implemented them in my project. When changing the frequency (even with multiple periods in the buffer) the signal is not generated correctly.

 

sinenew.jpg

 

Changing the amplitude generates the signal correctly. My guess is that the samples generated and the timing is the same as the signal currently in the buffer.

0 Kudos
Message 8 of 14
(4,342 Views)

Hi sh,

 

what's wrong with the signal shown in this image? It looks "continuously" without any steps/gaps…

 


@s.h._tech wrote:

Changing the amplitude generates the signal correctly. My guess is that the samples generated and the timing is the same as the signal currently in the buffer.


Again: how do you define the DAQmx task?

Do you try to change the samplerate when the task is running, when you guess "the timing is the same as the signal in the buffer"?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 14
(4,336 Views)

There are two different Sine waves in the signal (one with 100Hz and a few Periods with 200Hz). There should only be one frequency.

 

The Task is created via the 'AO-Voltage.vi'

 

signalgenerating.png

0 Kudos
Message 10 of 14
(4,333 Views)