# sine/cos encoder to digital

I am a newbie and looking for solutions to convert sine/cos encoder signals to digital resolution of 12 bits or 360/4095=.087 degrees/LSB. Shaft rotates maximum to 1rps. I have external adc with arduino and scanning at 1.2 KHz. I tried arc tangent method and I have to get 4095 counts in one second (for 1 rps), ( attached is the csv file). my doubt is that I have to take into account of time resolution of incoming signal, LSB changes at 244 us. So should I scan at 4.096KHz to get angle resolution of .087degrees?

sine_cos.zip (34.6 KB)

Find out how accurate and stable are the values from your external ADC. If nothing moves, how many ADC bits are stable?

How many bits have to be changed for a changed arc tan result? At the begin and middle of each quadrant?

For more detailed assistance specify which encoder, ADC and Arduino you use, links to data sheets...

Why don't you use a digital rotary encoder with super simple code for guaranteed high resolution?

I am using AD7606 and with calibration, I am getting close to 14 bits. Please explain about dealing with time resolution as described in post 1

Check the static resolution first. Higher sampling rate usually results in lower resolution ADC values and/or more jitter.

static resolution is great. I face problem only during revolution

What processing are you doing with the resulting angle values?

You are getting 12 bit sine and cosine values?

Knowing the sign of each I’d know the quadrant and knowing the quadrant, either sine or cosine gives me the angle.

When cosine or sine are zero it’s even quicker.

i’d put a table in flash with 4096 entries, 1 for every sine or cosine value (becomes the index) with the degrees for each in the table.

Lookup takes less than a microsecond. Calculating, given that most duinos don’t have FPU’s (I know of one, Teensy 3.6) the calculation will be slowwww.