LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong value of Duty Cycle in Square Wave generation

Hello,

 

The value of duty cycle observed on oscilloscope isn't the same as specified in VI (please, see 2 screenshots below: 1st - screenshot LabView, 50% duty cycle specified, 2nd - screenshot Tektronix).

Any ideas ?

 

Thanks

 

Pavel

Wrong_DutyCycle.JPG

 

F0001TEK.BMP

0 Kudos
Message 1 of 16
(4,293 Views)

Hi Pavel,

 

first check: check the waveform coming from the SigGen function! I bet it is showing a waveform with exactly 50% duty cycle!

next check: check the way the waveform is output on your AO channel…

(This process is called "DEBUGGING"…)

 

Or the other way: write a simple VI (just SigGen and DAQmx to output the waveform) and check its output using your scope…

Best regards,
GerdW


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

Hi GerdW,

 

Thanks for feedback.

I've tried 1st suggestion - indeed WaveForm seems to be very close to 50% (pleese, see the screenshot below)

check the way the waveform is output on your AO channel…

In VI it's written to device using "DAQmx Analog Write" block, if I properly understood your suggestion.

 

2nd option coming soon.

 

Concerning WaveForm graph I 've supplementary question - is it possible to erase it once "STOP" button is clicked ?

 

Best Regards

 

Pavel

 

Two_Signal_Generation_modules_FrontPanel_with_WaveForm.JPG

0 Kudos
Message 3 of 16
(4,265 Views)
Why do you post images that show nothing of how you are actually creating the analog signal? What can anyone tell from a front panel?
0 Kudos
Message 4 of 16
(4,257 Views)

Hi Dennis,

 

Why do you post images that show nothing of how you are actually creating the analog signal?

I attached the code in my 1st post. Did you see it ?

 

In the meantime I've tried simple solution, proposed by GerdW and oscilloscope display exacly the same waveform, i.e. duty cycle isn't 50% (please see the sceenshot below and attached VI).

 

Best Regards

 

Pavel

 

SquareGeneration_DutyCycle_Issue.JPG

0 Kudos
Message 5 of 16
(4,236 Views)

That looks pretty much like the signal you're measuring, if you repeat it. You may want to control the number of samples you generate to match one period.



CLA
www.dvel.se
0 Kudos
Message 6 of 16
(4,234 Views)

Hi M_Peeker,

 

You have probably a reason thinkng that this issue is  in connection with number of samples.

When I set frequency to 2Hz, the duty cycle is exactly 50%.

 

So for fractional frequencies like 1,5Hz, 2.53 Hz this simple setup doesn't work and should be replaced by something more elaborating ... setup that adapt the number of samples to frequency. Correct ?

 

0 Kudos
Message 7 of 16
(4,224 Views)
Why do you have the DAQmx Write inside a loop? If you set for continuous generation, you would only need to call the wire once.
0 Kudos
Message 8 of 16
(4,212 Views)

Here is solution that works with fractional frequencies.

Probably not the optimal one, but at least the duty cylcle remains 50% during generation.

 

SquareGeneration_DutyCycle_Issue_working_solution.JPG

0 Kudos
Message 9 of 16
(4,209 Views)

Hi Pavel,

 

I don't think this is a good solution!

- Dennis mentioned the problem of calling DAQmxWrite in a loop.

- Creating a waveform of 1000 samples / 1kHz samplerate with a frequency of 1.7Hz gives 1000/1.7=588 samples for one full period. The next "period" in the signal only has 412 samples left, so the duty will fail for the second part of the waveform… Simple math, eh?

Best regards,
GerdW


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