LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pulse width calculation

Hello !

 

In order to learn about sine wave pwm and LabView, i've done a little code which i attach for reference.

 

I am comparing a sine wave with a triangular wave.

 

There are a few things i don't understand :

 

1. Why does the PWM graph have a X scale of 0 to 1000 ?

 

2. How to calculate how long a pulse lasts (i.e the duty cycle).

 

Can you give me please answer this questions ?

 

I've searched the forums but i can't find a clear answer.

 

Some hints or ideas/threads that deal with this issue are greatly appreciated.

 

P.S. Using LabView 8.5.1.

 

Thank you !

 

 

 

 

0 Kudos
Message 1 of 5
(3,729 Views)

Is there anyone that can help me ?

 

Thank you !

0 Kudos
Message 2 of 5
(3,717 Views)

Please be patient.  You only posted the original question half an hour ago.  Most of us on the Forums are volunteers who have other jobs.

 

The PWM graph x-axis scales to 1000 because you gave it no timing information and waveform has 1000 points.

 

The PWM generation can be simplified as shown below.  This does not generate the array of timestamps but gives exactly the same PWM waveform.

 

PWM Modified.png

 

The Pulse Measurements VIs should be able to find the duty cycle for you or you could calculate it fairly easily from the boolean array.

 

Lynn

Message 3 of 5
(3,711 Views)

Thank you 4 your reply !

 

I've been working for several days on this before i've decided to post this question.

 

I've seen that there are some functions that can calculate the pulse width but how can it be calculated from the boolean array ?

 

I want to fully understand what is going on, and that is why i'm asking these questions.

 

Thank you 4 your time and patience.

0 Kudos
Message 4 of 5
(3,704 Views)

From the boolean array: Loop through the array. Note the index of the first F to T transition (t0).  Note the index of the next T to F transition (t1). Note the index of the next F to T transition (t2).  Then the period is dt*(t2-t0) and the duty cycle is (t1-t0)/(t2-t0), where dt is the time interval between samples.  Repeat for the next pulse by setting the new value of t0 to the previous value of t2.

 

If you are a beginner with LV, this will be a good learning exercise.  Hint: Use shift registers.

 

Lynn

Message 5 of 5
(3,698 Views)