LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to detect the time difference between zero crossing points of two sine waves on FPGA. What am I getting wrong?

I feel like I got to be really really close here. But for some reason my calculation is varying a lot, and I'm pretty sure it should be mostly constant. Both waveforms are 60Hz, and one waveform is at a constant 90 degree phase. What I'm seeing is the time difference increases for a short amount of time and then get "reset" back to a lower value. Which leads me to think there's something stupid I'm doing in my logic with my timers.

 

Attached VI is LV2020 32bit

 

Video of VI running 

 

True cases

fpga qesto.png

False cases

fpga qesto 2.png

 

0 Kudos
Message 1 of 6
(1,924 Views)

I'd imagine you have noise on your inputs, have you set a hysteresis on your trigger?

Message 2 of 6
(1,857 Views)

@Intaris wrote:

I'd imagine you have noise on your inputs, have you set a hysteresis on your trigger?


I have not, I'm guessing you're talking about the hysteresis in that VI I'm using to detect zero crossing? I'll try that out.

 

I was thinking I was doing something wrong with my timer logic but I guess not? And I didn't think I would be getting much noise, I'm just measuring 120VAC from the wall in my room and then I'm simulating a sine wave with a USB6001 daq device (-500mV to +500mV)

0 Kudos
Message 3 of 6
(1,841 Views)

Without having any actual data as to what's present at your inputs or how your hardware is set up, it's hard to tell what's wrong.

 

Do you have an oscilloscope to check the signals actually present at your inputs?

Message 4 of 6
(1,832 Views)

Right before you replied, I decided to check my inputs with an o-scope to verify lol. Turns out, my USB6001 DAQ device was outputting a sine wave with a frequency of ~40Hz 😁

 

After I fixed that so it was at 60Hz, things are MUCH more stable. It still isn't perfect, but I think that's because it's hard to match my DAQ device's output frequency exactly to my wall's 120VAC frequency. I noticed my wall's voltage frequency can vary, and I was watching the two sine waves slowly merge away from each other. I'm guessing that's why my zero crossing time difference doesn't stay consistent.

0 Kudos
Message 5 of 6
(1,821 Views)

Ok so this is interesting. I just tried this code out at my place of work, where my voltage waveform signals are 480VAC 60Hz and the current waveform signals are the 480VAC line currents coming from rogowski coils. I have an integrator on the rogowski coils so that the current waveforms are put back in the correct phase.

 

The time difference I'm getting is 16mS for L1. Which awfully close to the amount of time it takes for one full sine wave to complete at 60Hz, ~16.6mS. It's almost as if I'm measuring the time from one of the waveform's rising edge to its next rising edge, if that makes sense.

 

Is it my settings in the Analog Period Measurement VI maybe? There's two of these VI's, one for voltage and one for current, and both have the same settings.

asdlknld.png

0 Kudos
Message 6 of 6
(1,816 Views)