11-03-2016 07:17 AM
Hello,
how can i analyse a pwm signal?
i want to show the duty cycle of the signal below.
thx
Mike
Solved! Go to Solution.
11-03-2016 10:43 AM
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
11-04-2016 03:01 AM
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
11-04-2016 05:37 AM
Thanks for your reply. 🙂
Sorry but i´m just a rookie at diadem.
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?
11-04-2016 07:13 AM - edited 11-04-2016 07:15 AM
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):
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:
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
11-04-2016 09:41 AM
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]/Pe
Depends on your data and if there is a falling or rising event first.
Regards
Christian
11-08-2016 08:37 AM
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.
11-09-2016 07:24 AM
Hier sind mal meine berechnungen des Signals.
11-10-2016 03:00 AM - edited 11-10-2016 03:02 AM
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
11-10-2016 05:27 AM
Vielen Dank Christian,
dein Skript hilft mir sehr.
Ps.: Leider ist der errechnete duty cycle nicht über die komplette Signallänge von ca 25s darstellbar. Gibt es dazu auch eine Abhilfe?