04-03-2012 12:51 PM
Hello everyone,
I'm acquiring (with USB-6212) a square wave, "100Hz" with variable duty cycle - which can be 20%, 50% or 80% - for matters of decodification; the acquisition frequency is set to 4k. Actually, I said the frequency is 100Hz, because I get a rising edge every 10ms, but the length of the high level is defined by the communication protocol and that is what I called duty cycle (even though this does not match the exact definition of this property)
Since I need to decode the information contained by the wave, it's necessary for me to be able to tell what the duty cycle is. I've acomplished this so far by taking the derivative of the signal, then calculating peaks and valleys index in the waveform and finally subtracting them, as shown below.
It works ok almost the whole opeartion, however, the acquisition is not 100% exact. Sometimes I get the signal in the picture A, that is ideal for what I intended.
Other times, the signal is like B and the derivative amplitude does not cross my threshold, even though there is a rising edge there. I could lower my threshold to 2, for instance, but then I'd get vulnerable to the signal in picture C, which would accuse 2 peaks, instead of just one.
Anyone have an idea on how to work around this or any other method more reliable than taking the derivative of the signal?
Solved! Go to Solution.
04-03-2012 01:50 PM
It looks like your signal is fairly clean (low noise). I would just set the threshold to 2.5 and use the Greater Than comparison. The percentage of True in the resulting boolean array is the duty cycle.
Lynn
04-04-2012 09:54 AM
Hello there, thank you for your reply.
I reckon that the picture may be misleading, given that only one cycle is shown. However, my acquisited signal is composed by one hundred of cycles, thus I need to calculate 100 different duty cycles.
This way, the sum of high levels would give the average duty cycle and not the duty cycle of each and every "square".
You may suggest that I get just one cycle at a time (10ms acquisition), but that would hit my performance spec, given that I would have to calculate more often. Summing up, I'm trying to find a method that works with big loads of data, more than 2k points at least
04-04-2012 03:05 PM - edited 04-04-2012 03:09 PM
Hmmmm Duty Cycle on a cycle by cycle basis.
Time to break out the Waveform measurements pallate
Try :
Or if the signal is a bit noisy- add some histeresis by changing out the Ref Units
04-04-2012 03:08 PM
Well, we can only answer question based on the information supplied! The LabVIEW Mind Reading Toolkit is still in development.
Your application is one where parallel loops may be valuable. In the acquisition loop you read data from the data acquistion device at a rate which optimizes the DAQ perfomance (the >= 2k points you mentioned). The data is transferred to an analysis loop via a queue. In the anaylsis loop you can put the data into a shift register. When more data is available from the Acquisition loop, dequeue it and append it to the data in the shift register. The Duty Cycle section will find two consecutive rising edges and the falling edge between them ( the 10 ms segment). It calculates the duty cycle for that segment. Then it uses the second of the rising edges as the first rising edge for the next segment. Repeat until duty cycles have been determined for all segments.
There are a lot of details which can be imprortant in a process like this. Many of them are dependent on other things you have not specified. What will be done with the duty cycle values? Is the raw data to be displayed? Saved to file? Discarded after the duty cycle is measured? How long will the process continue? How much data can accumulate?
Lynn
04-04-2012 03:09 PM
Or, do it Jeff's way.
Lynn
04-04-2012 07:41 PM
@johnsold wrote:
Or, do it Jeff's way.
Lynn
Well- I do have a magic 8-ball....
04-04-2012 07:51 PM
04-04-2012 08:09 PM - edited 04-04-2012 08:14 PM
@Hornless.Rhino wrote:
@Jeff Bohrer wrote:
@johnsold wrote:
Or, do it Jeff's way.
Lynn
Well- I do have a magic 8-ball....
Can you put it into a sub-vi for the rest of us?
Sure
04-10-2012 08:29 AM
Thanks for the quick reply, that was really helpful.
Awesome "mind reading" skills