# Sine wave output conversion

Hi all, I am working with an amr based angle detection sensor(KMZ60). The sensor continuously gives cosine and sine wave output on varying magnetic field. On feeding this output to UNO's analog pin, I get values ranging from 0-1024. How should i interpret this data ? The sensor takes 3.3v as Vref and the a to d values vary as the magnetic field varies. How am i suppose to find the phase and amplitude from this data ? Can you suggest me any other method, if there are any ? Thanks.

Personally, I wouldn't attempt to do the maths on an arduino. Instead, I'd do the maths on an excel spreadsheet and then copy and paste the results into your sketch to use as a simple lookup table.

After carefully calibrating the sensor for gain and offset errors, and subtraction of offset, angle (in radians) = atan2(y,x).

From sensors's DataSheet:

The single-ended outputs are capable to drive inputs e.g. of an external Analog-to-Digital Converter (ADC) referenced to VCC. For an optimal use of the ADC input range the cosine and sine output voltages are tracking ratiometric with the supply voltage.

So, you just feed two outputs directly into arduino analog pins. I didn't get:

The sensor takes 3.3v as Vref and the a to d values vary as the magnetic field varies.

There is no ref. pin, my understanding outputs biased around 1/2 V. You need to run an FFT, that 'd produce magnitude and phase, plus approximate frequency

You need to run an FFT, that 'd produce magnitude and phase, plus approximate frequency

That won't do anything useful, if the angle of the magnetic field is constant.

After carefully calibrating the sensor for gain and offset errors, and subtraction of offset

It's not possible to re-calibrate sensor in all weather condition. At least you 'd need HPF some kind, to keep magnitude error under control. The tricky part is design good HPF for wide freq. band, and here fft comes, outperforming FIR in ~100x times.

Can you post your setup/schematics? How did you hook up the signals?

Magician: From sensors's DataSheet: So, you just feed two outputs directly into arduino analog pins. I didn't get:There is no ref. pin, my understanding outputs biased around 1/2 V. You need to run an FFT, that 'd produce magnitude and phase, plus approximate frequency

FFT is a complete red herring. `atan2 (y, x)` as has been mentioned.

Or more completely:

``````  angle = atan2 ((y-y_offset)/y_amp, (x-x_offset)/x_amp) ;
``````