03-01-2019 06:22 AM
Hi,
I use a function name "Sine Wave PtByPt" to generate a sine with a offset see below :
Can you help me to find the zero point (here 2V) every period ? Thank for your helps.
03-01-2019 07:12 AM
For help with your LabVIEW code, you need to post your code (best done by attaching the VI that you used to generate the waveform). But here's some math that might help you figure this out:
Bob Schor
03-01-2019 07:20 AM
Hi,
Thanks for your answer, you can find my code in this attach
03-01-2019 07:35 AM
As long as you at lest one full cycle of data the "zero" you are looking for is simply the average.
"Mean PtBypt.vi"
Ben
03-01-2019 07:48 AM
Hi Ben,
I'm not sure to understand your explanations, I know the average is in this case 2 (equal the offset of my signal) but I don't need this value but I need to detect the 0 (if you want every period of this signal) after I want to send this point 0 to a acquisition card.
03-01-2019 07:53 AM
I should have asked what you mean by "find the zero point". I assumed that since you knew the offset was 2, you wanted the time that this occurred. If you want, instead, to compute the offset, then Ben's answer (take the mean) will work as long as you have an integral number of cycles.
I notice from your code that you are generating a sinusoid with phase = 0. The period of your waveform is 1/frequency. I don't know what "sampling frequency" you are using, but it appears you take 1000 samples per waveform period, so the zeros come at samples 0, 500, 1000, 1500, ..., i.e. n * 500 for n = 0, 1, 2, ...
Bob Schor
03-01-2019 08:07 AM
I am afraid you are not being clear in what you want.
If you do not want to know what the value is are you trying to figure when?
Give a context because I am more lost now than when I started reading this thread.
Ben
04-17-2019 05:11 AM
Hi Ben,
Sorry I was busy but now I have a VI to detect a 0 from my signal but sometimes I don't have the same period (see in this attached). Have you got an idea to resolve this problem ? Thanks
PS : in this example I'm working with Frequency=cte, Amplitude =cte, Offset=cte. It's just to observe.
04-17-2019 07:50 AM
It looks like you're successfully detecting your positive slope "zero-crossings" (or more accurately, threshold-crossings where your code sets a threshold of +2.0). What you're writing to file is the first data point *after* crossing the threshold. The time you associate with that data point is a query to system time at the moment your algorithm evaluates the data point. It really isn't a good way to do things, though the problem probably won't show itself in this simple example code.
Ideally, you'll be heading toward a DAQ task using a hw clock that gives you deterministic timestamps for each sample. Barring that, you should associate time with the sample as early as possible in the dataflow.
So then, once you have a *good* timestamp for each data point, you should actually make use of the feedback node. When a crossing is detected, the feedback node gives you the data value just before the crossing. With both the before and after values, you can interpolate to figure out the (estimated) timestamp when the crossing occurred. When you identify the times *this* way, you'll get more consistent period measurements.
-Kevin P