11-27-2017 12:45 PM
I have two input signals that have 4000 cycles per capture. I would like to be able to calculate the duty cycle and phase for each cycle, and then be able to find max, min, and average. I'm wondering if there is a fast way to calculate the duty cycle and phase, as I don't want to wait 20 minutes between runs while it runs through a loop. I'm thinking calculating them all may just always end up taking too long, but wanted to see if anyone has had experience with this before.
Solved! Go to Solution.
11-27-2017 01:28 PM
You may want to post some example data, and some code showing how you are currently doing it. I've used some techniques mentioned here:
https://forums.ni.com/t5/LabVIEW/Detect-PWM-Drop-Out/m-p/3556128#M994987
And here:
https://forums.ni.com/t5/LabVIEW/Two-Threshold-Analog-to-Digital/m-p/2738970#M809660
To perform signal integrity on a PWM ensuring that the PWM value doesn't change much from cycle to cycle (standard deviation). 20 minutes sounds crazy and there must be lots of inefficiencies, or you are sampling at a couple gigahertz.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
11-27-2017 01:37 PM - edited 11-27-2017 01:42 PM
20 mins was an exaggeration, just what it feels like. Right now I have it set to only do the first 1000, just to speed it up some, and it is taking 26 secs from the start of the capture to being done calculating. Ideally I'd like for all 4000 to be captured and calculated in under 10 seconds. Which is why I'm thinking it may just not be feasible. I'm thinking will end up having to do just the first couple hundred.
The current vi is kinda messy right now. We had an old picoscope laying around, and playing with it to see if it will work for what we want before getting a newer one, so I haven't put much effort into keeping it clean as none of it will be used in a final product.
11-27-2017 02:48 PM - edited 11-27-2017 02:50 PM
One easy speed-up is to replace the While loops around the Pulse Measurements with For loops and enable loop iteration parallelism. Beyond that, I wonder if it would help if after each pulse measurement you used the pulse center output to take a subset of your waveform, excluding the first pulse, before running it through Pulse Measurements.vi again. That way it won't have to repeatedly search through the waveform to find the next pulse to measure.This would preclude iteration parallelism, however.
11-27-2017 04:30 PM
Okay try this. It is a VI that calculates the period and duty cycle of every cycle of a waveform, given the high and low threshold. You didn't provide any typical data so I generated some. For my test I generated a square wave with 10,000 cycles of a 100Hz 20% wave, at a sample rate of 10Khz, which generated 1,000,000 samples. It took 12ms to calculate the duty cycle, and period of all 10,000 cycles (well 9,998 cycles since the first and last were partial). I included two demos, one which does the timing test I just describe and another that graphs the analog, thresholds, and boolean thresholded data on a single graph for testing. Improvements could likely still be made.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
12-01-2017 06:57 AM
That worked amazingly well. Threw it into my VI and it calculated all of the data pretty much instantly. Thank you.