LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Calculate the Sine wave Period calculation

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

Thanks
Thiyagarajan.S
WABCO Vehicle Control System
0 Kudos
Message 1 of 12
(4,870 Views)

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.

Matt J | National Instruments | CLA
0 Kudos
Message 2 of 12
(4,850 Views)

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.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 3 of 12
(4,804 Views)

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.

Matt J | National Instruments | CLA
0 Kudos
Message 4 of 12
(4,791 Views)

Matt is right - watch out for the noise. There are ways around it, but the simple solution I posted will be vulnerable.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 5 of 12
(4,788 Views)

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.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 12
(4,777 Views)

Hi  

It's possible to give us an example on VI

 

Thank you in advance for your answer

My best regards

0 Kudos
Message 7 of 12
(4,731 Views)

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.

0 Kudos
Message 8 of 12
(4,717 Views)

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

0 Kudos
Message 9 of 12
(4,712 Views)
  • When posting code post the actual code not a screenshot.  You wouldn't take a screenshot of a text file and post it on a text language forum.  Upload the actual VI, or zip several files and upload the zip.  The exception to this rule is when uploading a VI Snippet.  This is an image with the VI embedded in it, so the source is still intact.

Source

 

That being said no where in your code are you getting a tick, or timer value.

0 Kudos
Message 10 of 12
(4,704 Views)