Absolute Angle Encoder

10K12822

Intro: Absolute Angle Encoder

This instructable explains how to make an absolute angle encoder using an Arduino UNO R3, a reference capacitor, and a variable capacitor.

The readings are absolute in that the current angle is displayed when the encoder is powered up.

Accuracy is better than 1 degree over the entire range.

The estimated cost of materials is less than $20.00.

Images


  • The cover photo shows the capacitance meter attached to an Arduino UNO R3. The reference capacitor is the small brown blob.
  • Photo 2 shows the encoder underside.
  • The video shows the encoder in operation.

STEP 1: Circuit Diagram

 The circuit diagram is shown in photo 1.

The variable capacitance is represented by C.

Both sections of the variable capacitor are wired in parallel.

The internal trimmer capacitors have both been set to minimum.

STEP 2: Theory

 The circuit is a variation of the simple capacitance meter described in my instructable https://www.instructables.com/Simple-Capaitance-Meter/

The reference capacitance has been reduced from 10nF (nanofarads) to 220pF (picofarads) to improve the resolution.

A small variable capacitor is used for capacitance C.

In this project we are not interested in the capacitance values. Instead the variations in ADC count are recorded into an array at 10 degree intervals.

Photo 1 shows how the ADC count varies when the capacitor shaft is rotated.

The absolute angle is determined using the array and interpolation as shown in the following code.


// ----- Interpolation table
/* ADC Count at 10 degree intervals */
const int Lookup[] = {865, 843, 813, 782, 751, 723, 697, 676, 652, 632, 614, 596, 580, 563, 547, 534, 523, 509, 495};




// ----- Interpolate
for (int i = 18; i > 0 ; i--) {
if (Lookup[i - 1] > Adc) {
Serial.print( ((float)(Lookup[i - 1] - Adc)) / ((float)(Lookup[i - 1] - Lookup[i])) * 10.0 + (i - 1) * 10.0);
break;
}
}


The final resolution is within 1 degree.

STEP 3: Software

 Method:

  • Download the attached file “absolute_capacitance_angle_meter.ino”
  • Copy the contents into a new Arduino sketch. (Use a text editor such as Notepad++ ... not a word processor.)
  • Save the sketch as "absolute_capacitance_angle_meter" (without the quotes).
  • Compile and upload the sketch to your Arduino.


STEP 4: Calibration

 Method:

  • Attach a protractor to the upper arm using double-sided tape.
  • Upload and run the code
  • Open your Serial Monitor at 115200 bauds.
  • The left hand column in photo 1 shows the ADC (analog-to-digital-converter) count.
  • Rotate the capacitor from 0 through180 degrees and record the ADC count every 10 degrees [1]
  • Over-write the values (left-to-right) in the Lookup[] array found in the header.
  • Recompile and upload the code to your Arduino
  • Done


Note

[1]

Estimate the last count if your capacitor does not rotate a full 180 degrees.  

STEP 5: STL Files

 Photo 1 shows the PLA arm on which the variable capacitor is attached. The STL file for this arm is:

  • capacitive_encoder_arm1.stl


Photo 2 show the PLA arm that is attached to the capacitor shaft. The STL file for this arm is:

  • capacitive_encoder_arm2.stl


 All mounting bolts are M2.5 x 5mm


The arms were printed on a Voxilab Aquila 3D printer using 1.75mm PLA, a 0.4mm nozzle, and a layer height of 0.2mm

STEP 6: Summary

This instructable explains how to make an absolute angle encoder using an Arduino UNO R3, a reference capacitor and a variable capacitor.

The readings are absolute in that the current angle is displayed when the encoder is powered up.

Accuracy is better than 1 degree over the entire range.

The estimated cost of materials is less than $20.00.

  Click here   to view my other instructables.

19 Comments

This is very interesting. I am interested in measuring the crank angle on a small Stirling engine (typical max 1000 RPM). I doubt the transistor radio type variable capacitor would cope with these continuous rotation for long but would an air spaced single vane capacitor do the job? My goal is to measure the angular velocity and different points in the engines rotation in an attempt to answer the question are these engines working as single acting or double acting engines? What sort of sampling rate could your system achieve?
Thanks for the headsup on that, I will investigate.
I would use something similar to what is used in a ball mouse: a perforated disk and led + photodiode. Let an Arduino count and store the pulses and time stamps. Then analyse the data.
Have fun!

Commercially available crank angle sensors use either optical or Hall effect pulse counters. I believe they rely to an extent on the fact that engines have quite a bit of inertia, and interpolate between pulses. This would allow them to use a longer pulse from the sensing part to indicate the zero position. Even getting one pulse every 5 degrees would allow a synthesised pulse every degree.

The difficulty here is that sampling a capacitor requires measuring the charge and discharge rates. You need something virtually instant. A rotating prism or mirror illuminating an array of photo transistors would be best. Even LDRs have a comparatively slow response.

A home brew approach could be a rotating hollow shaft with a light source in the middle, and a hole. If you can achieve a steady RPM then a pair of moveable sensors could let you accurately measure the time taken to rotate between two particular positions. This would give you very accurate values but would take some time to collect the data for the full cycle.
Thanks for your input. My
goal is to answer the apparently simple question "Are gamma configuration
Stirling engines double or single acting?" A basic theoretical examination
would indicate that the pressure in a simple air-cooled engine cannot fall
below atmospheric pressure since gas is never exhausted from the system during
its working cycle, Yet measurements of the pressure in real engines almost
always show a depression below atmospheric pressure at some point in the cycle.
Clearly there must be air leaks at the piston seal or at the displacer gland. I
want to be able to measure the 'instantaneous' engine speed at points around
the rotation and then plot a polar diagram to identify where the crank is
accelerating and where it is decelerating. If the engine is double acting then
there will be two distinct periods of acceleration in each cycle but if it is
single acting only one period of acceleration will be observed.
Thank you for commenting :)

There is no reason why an air-spaced vane as you have drawn shouldn't work providing there is enough capacitance. Just use a smaller reference capacitor if the capacitance is low.

As yet I haven't checked the maximum sampling rate.
The current sample rate is set by two delays ... delay(100) and delay(500).
Maximum sampling speed will be obtained if you comment-out these delays.
In practise a small discharge delay may be necessary to ensure that the capacitors are fully discharged.
Nice to see the good old variable capacitor still at work! (doing a good job!)
It reminds me of my homebrew radios built "some" years ago with recovered pieces ...
I was able to make a level indicator for non conductive liquids using two concentric metal tubes and measuring the capacitance between them
And THAT (level indicator) is how fuel level sensors for jets work... Last project I did for that was a certain iconic 747!
Great! So on my last flight back from NYC the plane sported the same instrumentation of my (now defunct) moped :)
Thanks for commenting :)
It's hard to get mechanical parts these days ... everything is solid state :(
Love your concentric metal tubes ... reminds me of the good old Phillips trimmers
... that I used for a VHF airband superregenerative radio :) (on 1976, I should still have it somewhere)
Your mention of superregens brings back fond memories :)
I once made one for the 2m ham band using a 955 "acorn" tube but had to stop using it as it reradiated everything I was listening to up and down the band.
When you say “Both sections of the variable capacitor are wired in parallel.” what exactly do you mean? The device seems to only have three terminals. Could you please add a photo showing the actual construction of those connections?
The variable capacitor used in this project has two separate variable capacitors in the one package. The centre pin is common to both capacitors. Connect the two outside pins by means of a wire. This wire can be seen in photo 2.
For the reference capacitor I would use an upgraded version. The capacitor shown can vary wildly with temperature changes. Calibrate after sitting overnight after soldering. At least the receiver circuits I worked on in the past had to sit and cool to the core before stabilizing.
Thanks for commenting :)
Point noted about the temperature stability ...
I love it.
I think this will give better range than the one I made with the Hall-Effect Transistors.