Hey everyone, first post here. I am a misguided, troublemaker physicist with only my irrational sense of over-confidence driving me forward on this project. Long story short, I am stuck on the last two parts of a nerdy Arduino project. Basically, I am looking to output a 'sine wave' (plan on using a lookup table into an analogWrite function and probably a low-pass filter) to a circuit and then use a FFT to find the phase angle. I'm not looking to have code or answers handed to me, but if anyone has advice on hangups I might have or the method I am going about it, that would be spectacular. I'm panning on a frequency range between 50-1,000Hz. Thanks in advance.
Tony, the analogWrite of the Arduino is PWM, i.e a pulse-width modulated digital level, not a real analog output.
This sine wave table Arduino article modulates the intensity of an LED in a sine wave pattern.
Your eye integrates the pulses into an average intensity.
http://www.arduino.cc/playground/Main/PWMallPins
I think all you need is a D/A converter, something not built-in, but easily added.
search for "DAC" for more.
This help?
...(plan on using a lookup table into an analogWrite function and probably a low-pass filter) to a circuit and then use a FFT to find the phase angle.
The default PWM frequency is "about" 500Hz, so you'll need to increase that... (I don't understand the limits of PWM as well as I understand the Nyquist theory and and how it relates to PCM, but I'm sure the PWM frequency has to be higher than than the signal frequency.
...and then use a FFT to find the phase angle.
Your firmware is generating the waveform, so it should already "know" the phase angle!
DVDdoug:
Your firmware is generating the waveform, so it should already "know" the phase angle!
Oh, sorry, phase angle between voltage and current. Although I have to say, in just an hour of ghosting around the forum, I already have found a ton of answers. Looks like my method (or modified version of it) will work, I'll be sure to post on here my findings and methodology when its all done for whoever reads this thread in the future. (But feel free to keep adding tips or advice on things to avoid.) XD
I think the FFT is an external system, not part of the Arduino, correct?
(FFT alg barely fits into an Arduino, and with limited precision)
I also have the same question about phase angle.
Phase angle relates to two entities. ( Phase angle calculation time delay frequency calculate phase lag time shift between voltage difference time of arrival ITD oscilloscope measure two signals formula angle current voltage phi phase shift time difference - sengpielaudio Sengpiel Berlin )
What meaning is there to measuring the phase angle of a constant sine wave?
Are you planning to send this audio through some medium and calculate the phase shift of a recieved signal?
This will do it won't it?
http://interface.khm.de/index.php/lab/experiments/arduino-dds-sinewave-generator/
He changes the PWM duty cycle on the fly to change the "output level". The PWM frequency is smoothed out with a filter.
Tony_C:
use a FFT to find the phase angle
I don't get how that would work (how does moving into the frequency domain help you to find the phase relationship between two signals?) but it sounds as if you know what you're doing so I assume that makes sense to you. It seems to presume some sort of fairly accurate and high frequency current measuring. Do you have a solution in mind to provide that?