01-17-2015 01:13 PM
Hi,
I want to calculate a peroid on Sine Positive Half Cycle.
Please share your ideas to me, Refer the graph for your reference.
Thanks
Thiyagi
01-17-2015 02:05 PM
Tick Count when the value goes from negative to positive and again when it goes from positive to negative then the difference between the two will be your period. I suppose if you have a noisy signal you will need some logic similar to a Schmitt trigger so you don't get periods much smaller than expected.
Post your VI of what you have so far and we can help you out.
01-18-2015 09:07 AM - edited 01-18-2015 09:07 AM
Basically, step thru the signal and use a ">0" comparison on each sample.
When the signal changes from F to T, record your sample number (N1).
When the signal changes from T to F, record your sample number (N2).
Subtract N2 - N1 and that is how many samples the signal was above zero.
Multiply that by your sample period and that's the TIME it was above zero.
There are faster ways to do it, if you are reading the data from a file or something. But the above method will apply to any data.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
01-18-2015 10:58 AM
Coastal's idea is much better. Reading my post again I'm not sure what I was going for, it would work for reading signals on FPGA in real time but that is about it.
Again though, be careful of fast switches between T and F. A computer will have no problem telling you that one of your periods was exactly one sample long if there is noise.
01-18-2015 11:02 AM
Matt is right - watch out for the noise. There are ways around it, but the simple solution I posted will be vulnerable.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
01-18-2015 11:30 AM
I guess the hardest part is defining what is signal and what is noise. Once you get that down, you could probably filter out most/all of the noise.
01-20-2015 07:32 AM
Hi CoastalMaineBir
It's possible to give us an example on VI
Thank you in advance for your answer
My best regards
01-20-2015 08:14 AM
He told you step by step how to code it. You'll get much more out of this if you at least attempt to follow his instructions. If that doesn't work, you can always post what you have here and people will help you debug it.
01-20-2015 08:27 AM
In attachment a picture of what I understood and tried. And I'm sure it's not right what I did
If you can help I'll be thankful
01-20-2015 08:35 AM
That being said no where in your code are you getting a tick, or timer value.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord