02-13-2014 08:33 AM - edited 02-13-2014 08:34 AM
I was asked to develop some code that would take a signal in on an analog, then convert it to a digital, then perform frequency, duty cycle, and signal integrity testing on it. The built in NI functions for performing these tasks were insufficient because we needed to be able to detect a single drop out of a cycle. With a real world signal I realize there maybe noise and a having a single threshold to convert from a analog to a digital may show transitions that aren't there and so I planned on developing some kind of debounce code.
Instead someone mentioned using two thresholds, one for the low and one for the high, and to only consider the signal transitioning if it goes above the high, after going below the low.
Attached is my attempt at that method. This VI simulates a sine wave with a bunch of noise then does a single theshold to show how imperfect it can be. Then using that same signal it does a two level theshold which works much better but has a slight shift in the time domain, and the beginning will contain unknown values because neither transition has occured with the first sample.
Any pointers or suggestions to improve my implementation is appreciated. Thanks.
EDIT: This does use an OpenG function from the Array palette.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
Solved! Go to Solution.
02-13-2014 09:44 AM - edited 02-13-2014 09:45 AM
Why so many loops when you just need one?
02-13-2014 09:48 AM - edited 02-13-2014 09:50 AM
@crossrulz wrote:
Why so many loops when you just need one?
Well partially because I also need to know at which indices the transitions occur at. But still adding the extra XOR code to your modification is still probably much faster I'll update and give it a try.
EDIT: And actually the digitized version is not needed in my application at all, and will likely have a boolean control to generate it, with the default being false. Transition times is really all I care about at the moment but wanted to visualize them which is why I added it.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
02-13-2014 09:50 AM
If you need the indecies, then use a conditional autoindexing tunnel with the i. When there is a transition, you add to the array.
02-13-2014 10:00 AM
I did some deletions to your code and converted to 2012 for you. Also added the indeices coming out.
02-13-2014 10:04 AM
@crossrulz wrote:
I did some deletions to your code and converted to 2012 for you. Also added the indeices coming out.
Thanks. Quick test shows that with 50,000 samples your code is roughly 10 times faster then mine.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord