Absolute Angle Encoder
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
[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
equipoisebob 1 year ago
yproy 1 year ago
https://ams-osram.com/products/sensors/position-se...
equipoisebob 1 year ago
jantiemen 1 year ago
Have fun!
tinkertechie 1 year ago
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.
equipoisebob 1 year ago
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.
lingib 1 year ago
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.
amaze1 1 year ago
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
TimW93 1 year ago
amaze1 1 year ago
lingib 1 year ago
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
amaze1 1 year ago
lingib 1 year ago
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.
tinkertechie 1 year ago
lingib 1 year ago
mamoon001 1 year ago
lingib 1 year ago
Point noted about the temperature stability ...
Palingenesis 1 year ago
I think this will give better range than the one I made with the Hall-Effect Transistors.
lingib 1 year ago
Your instructable https://www.instructables.com/Tims-Electronic-Dividers-1D/ was inspirational.