DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

pulse width modulation

Solved!
Go to solution

Hello,

 

how can i analyse a pwm signal?

i want to show the duty cycle of the signal below.

thx

Mike

0 Kudos
Message 1 of 12
(5,758 Views)

Here's one possible solution:

1. Use Event Search in Analysis module and detect rising and falling slope events for a specific threshold that is appropriate for your pwm signal.

2. Calculate the difference in time between detected events

3. Calculate duty cycle using the time differences

 

Regards Christian

Christian
CLA, CTA, CLED
0 Kudos
Message 2 of 12
(5,735 Views)

Hi Mike,

 

sadly I can't see the Picture you attached, feel free to attach it as file to a reply.

 

Still I guess you got a PWM sampled by some hardware, so basically a 1d-Array/Waveform. I think there are many approaches on how to do that, but I think you should first make the signal "perfect", so define a treshold, and set all values bigger to e.g. 1, and all values lower to 0. With this "perfect" signal, you can easily use the "Pulse Measurements.vi" to detect the duty-cycle. You should use a Waveform-Datatype with the Pulse Measurements.vi, but if you just need the Duty Cycle a DBL-Array should work as well.

Feel free to reply, if you have any else questions, or problems using the VI.

 

Best,
Jan Göbel

Staff Applications Engineer

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

Thanks for your reply. 🙂

Sorry but i´m just a rookie at diadem.Smiley Indifferent

With the Event Search i can detect the falling an rising slope. But how can i read the time to calculate the differece betwenn "on" and "of"?

And how can i write a script to calcuate the ongoing signal to each seperate time?

0 Kudos
Message 4 of 12
(5,710 Views)

Hey,

 

Here's a more detailled description:

1. Load attached TDM demo file with "Time" and "PWM" channels

2. Use channel event search with following settings (run calculation two times with rising and falling slope settings):

EventSearch1.PNG

3. I reanmed the resulting channels to "Rising" and "Falling"

4. Use "Process NoValues" function in Analysis to remove NoValues from "Rising" and "Falling" channels

5. Use "Calculate Differences" function in Analysis to calculate the PWM period from "Rising" or "Falling" channel. In my example I named the resulting channel "Period".

6. Use calculator to calculate duty cycle:

Ch("duty cycle") = 1 - abs(Ch("[1]/Rising")-Ch("[1]/Falling"))/Ch("[1]/Period")

 

Here you can see the result of the event search but with 1 and 0 values instead of time and novalue like in the above picture:

Events.PNG

Basically you have to remove the zeros between the spikes and replace the spikes with time values which is done with the event search function like explained above.

 

Please note that the event search dialog can look different before DIAdem 2015 SP1 (less options in dialog).

Use  recording mode to create a script that does the work for you.

 

Hope this helps

Christian

Christian
CLA, CTA, CLED
Message 5 of 12
(5,702 Views)

If the first blue spike in my last screenshot would not be there you could also make calculation easier:

Ch("duty cycle") = (Ch("[1]/Falling")-Ch("[1]/Rising"))/Ch("[1]/Period")

 

Depends on your data and if there is a falling or rising event first.

 

Regards

Christian

Christian
CLA, CTA, CLED
0 Kudos
Message 6 of 12
(5,694 Views)

Hallo Christian,

danke für deine schnellen Antworten.

Leider funktioniert dein Vorschlag nicht, da ich die falling Flanke vom Zeitpunkt t2 von der rising Flanke zum Zeitpunkt t1 subtrahiere.

Gibt es keine Möglichkeit die deltas der Flanken anders zu berechen?

 

Im Anhang habe ich das PWM  als Excel Datei, welches ich in Diadem importiere, angefügt.

Ich wäre dir wirklich dankbar wenn du es dir vill. anschauen könntest.

mfg Michael K.

 

0 Kudos
Message 7 of 12
(5,632 Views)

Hier sind mal meine berechnungen des Signals.

0 Kudos
Message 8 of 12
(5,617 Views)
Solution
Accepted by topic author michi_kpunkt

Hallo Michi,

 

bei mir funktioniert es mit der genannten Vorgehensweise auch mit deinem Datensatz.

Dieses Script tut das gleiche (evtl. Kanalnamen anpassen):

ChnEventList1 = ChnEventDetectionSlope( , "[1]/U_NWV_I\ES650\AD\Thermo:1", 5, "increasing", 1)
Call ChnEventCreateFilteredTrueChn("/Rising", ChnEventList1, "[1]/time", NOVALUE)
ChnEventList2 = ChnEventDetectionSlope( , "[1]/U_NWV_I\ES650\AD\Thermo:1", 5, "decreasing", 1)
Call ChnEventCreateFilteredTrueChn("/Falling", ChnEventList2, "[1]/time", NOVALUE)
Call ChnNovHandle("[1]/Rising","[1]/U_NWV_I\ES650\AD\Thermo:1","Delete","XY",1,1,0) Call ChnNovHandle("[1]/Falling","[1]/U_NWV_I\ES650\AD\Thermo:1","Delete","XY",1,1,0)
Call ChnDeltaCalc("[1]/Rising","/Period") Call Calculate("Ch(""duty cycle"") = 1 - abs(Ch(""[1]/Rising"")-Ch(""[1]/Falling""))/Ch(""[1]/Period"")",NULL,NULL,"")

Je nachdem ob du zuerst eine steigende oder fallende Flanke hast, musst du die eine oder die andere Formel nehmen (siehe vorherige Posts), damit eine positive Zeitdifferenz herauskommt.

 

Gruß Christian

Christian
CLA, CTA, CLED
0 Kudos
Message 9 of 12
(5,597 Views)

Vielen Dank Christian,

 

dein Skript hilft mir sehr.Smiley Happy

 

Ps.: Leider ist der errechnete duty cycle nicht über die komplette Signallänge von ca 25s darstellbar. Gibt es dazu auch eine Abhilfe?

0 Kudos
Message 10 of 12
(5,583 Views)