LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Phase difference from 2 signals(HELP!)

Hi lamela,

 

what's your sample rate? Right now you use 80ms delay in your loop giving you 12.5Hz in the loop.

What's the frequency of your signals?

 

How fast does your Arduino measure the values? Which sample rate did you set in the Arduino?

What's the "phase" between the two samples? (The Arduino probably uses a MUX for it's analog inputs I guess.)

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 21 of 29
(2,415 Views)

How do I check the sample rate? Both the frequency are 70hz.

My arduino uses 9600 bits per second? The phase between the two signal keeps changing from 15-20 and sometimes change to negative and some other values.

How can I solve this?

0 Kudos
Message 22 of 29
(2,408 Views)

Hi lamela,

 

How do I check the sample rate?

It seems to me you programmed the Arduino sketch on your own, so you should know, which sample rate you programmed on the Arduino!

 

Both the frequency are 70hz.

So in this loop you try to do "accurate" phase measurement on signals with 70Hz frequency using 12.5Hz loop rate and unknown sample rate?

 

My arduino uses 9600 bits per second?

This is the setting of the serial port. It has no relation to your sample rate.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 23 of 29
(2,392 Views)

Your rate-limiting step is the serial transfer from the Arduino to the computer. The first thing to do is bump that to the maximum that your particular board supports. Then, in the main loop of the Arduino, make sure that any delay time is short compared to 14 ms (the period of a 70 Hz signal). The Arduino's native sampling speed is a bit under 10 kHz, including setting the multiplexer to the right channel, so there's an intrinisc ~100 microsecond delay built into each separate analog read. That's small compared to your signal period, but if you want precise phase numbers, the fact that the two measurements are not truly simultaenous will add a few degrees of spurious phase shift. When setting the delay in your loop (i.e. the sampling period), you should check that the serial link has enough bandwidth over that time period to transfer the two readings. 

 

0 Kudos
Message 24 of 29
(2,343 Views)

Do you mean I have to increase the sample rate so it will sample faster? Do I have to add any delay on the arduino sketch? Regarding the delay in the loop, how do I make sure they are the correct values? Sorry, I'm still quite new to the arduino!

0 Kudos
Message 25 of 29
(2,309 Views)

You said your signals were at 70 Hz. To have any hope of accurately measuring the phase, you'd want to sample each signal at 140 Hz (and preferably faster), so 280 samples/sec minimum. Therefore, your entire loop, both on the Arduino and in LabView, must complete in somewhat less than 4 msec. That includes the actual sampling and the serial transfer of the data between the Arduino and the computer.

0 Kudos
Message 26 of 29
(2,298 Views)

Ok, I'll see how is it when I go back to my school's lab tomorrow. What can I do if it isn't sampling fast enough? Meaning this will solve the changing phase difference? Because I should be getting close to 0 but I'm sometimes getting random numbers like 16-20? 

0 Kudos
Message 27 of 29
(2,208 Views)

Hi lamela,

 

What can I do if it isn't sampling fast enough?

Nothing with your Arduino.

Or get a DAQ device better suited for your measurement task!

 

You should have learned about Shannon-Nyquist-theorem by now after all these comments…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 28 of 29
(2,200 Views)

The Arduino can sample fast enough; it tops out at just under 10 kSamp/sec. Transferring that data in realtime over an RS232 link is problematic though. 

 

How responsive do you need the LabView phase measurement to be? Would it be OK to update once every one or two seconds? If that's workable, I'd suggest sampling both signals on the Arduino into an array in the Arduino's memory. Take maybe 0.5 seconds of data (35 periods) at 500-1000 Samp/sec (250-500 points per signal per second). Then, transfer the arrays in a block to LabView and do the phase calculation on the computer. 

 

 

0 Kudos
Message 29 of 29
(2,140 Views)