Read 12 bit PWM encoder data

Hi! For one of my projects I use few absolute rotary encoders. I built first prototype with chinese 8 bit analog encoders and arduino. This device send angle data to 3d application. It works good, but I want improve quality and decrease size. For this reason I want switch to MA3 | US Digital it's small and have nice resolution, but I'm not sure that it works with arduino because 12 bit pwm. maybe someone know how to read this 12 bit data with arduino or maybe with additional shield or use another controller?

Using the Arduino's pulsein(); function you should be able to read it. You didn't state how fast you were going to spin the encoder, and it sort of depends on that. The pulsein function can resolve as fast as 10 microseconds, so your speed would be 1/(4096 * 10e-6) limited or about 24 revs/second. That works out to 1464 RPM.

You should research this carefully. The Arduino pulsein() function is not very accurate and can be affected by interrupts, so you may want to use the input capture feature of Timer1. See this discussion among others: pwm - How precise is the timing of pulseIn()? - Arduino Stack Exchange

Furthermore the 12 bit PWM output has a cycle frequency of about 250 Hz, so it clearly cannot be used on shafts that are rotating rapidly.

jremington:
Furthermore the 12 bit PWM output has a cycle frequency of about 250 Hz, so it clearly cannot be used on shafts that are rotating rapidly.

Hmm. Fs=244Hz gives a Nykvist limit of 122Hz or 7320rpm. Thats pretty fast i think. I believe the mechanical limitations lie much below that even if there is a version with ball bearing.
But using the input capture would be the best way to read it.

The problem is this sensor have minimum pulse width 1 microsecond.

The problem is this sensor have minimum pulse width 1 microsecond.

The 12 bit sensor has a resolution of .088 degree per microsecond with 4098 microseconds pulse length per 360 degrees. Are you concerned that you can not measure motion of less than .088 degree if you see the minimum pulse width of 1 microsecond? What is the positional resolution you require for your application?

As others state you can use the 16 mhz timer1 to measure this pulse width and resolving the pulse length to less than a microsecond should be achievable with a prescale of 1. There are many tutorials on using timer1.

The resolution of pulsein just happens to be at the limit of your 12 bit device. So the resolution is ok. Your accuracy will be somewhat less. Is that OK? if you require more accuracy, use timer1 as others have said.

Sergin, how did you ultimately read the PWM? I have the exact same encoder that I would like to interface. I'm curious what direction you went in.