Introduction: Shaft Encoder Using Polarized Light

About: 55+ years in electronics, computers, and teaching ... now retired.

This instructable explains how to make a shaft encoder from three pieces of linear polarized film, two LEDs, two ambient light sensors, and an Arduino UNO R3.

Construction is simple … once you have printed the 3D parts, cut the polarized film to shape, and super-glue the components in place.

Angular resolution is determined by the number of bits in your ADC (analog-to-digital-converter).

Step 2 of this instructable explains how absolute encoding is possible.

Features include.

  • Non-contact
  • High resolution
  • Not affected by magnetic fields
  • Simple construction

The estimated cost of each encoder, excluding the Arduino test jig, is less than $20.00

This project is “proof-of-concept” and is published in the hope that it may be of use to someone.



Images


  • Photo 1 shows a closeup of shaft encoder. In this shot both photo transistors are receiving light.
  • Photo 2 shows another closeup of the shaft encoder. In this shot only one photo transistor is receiving light.
  • The video shows the shaft encoder in operation

Supplies

The following parts were obtained from https://aliexpress.com/

  • 1 only Arduino UNO R3 with USB cable
  • 1 only NEMA17 17HS3430 stepping motor
  • 1 only NEMA17 mounting bracket
  • 1 only Big Easy Driver
  • 2 only sheets of linear polarized film

The following parts were obtained locally

  • 2 only 5mm diameter TEPT5600 ambient light sensors
  • 2 only 5mm diameter “clear glass” green LEDs
  • 1 only LM394N quad comparator.
  • 1 only breadboard
  • 2 only 330 ohm resistors
  • 4 only 1K ohm resistors
  • 2 only 2.2K ohm resistors
  • 4 only M4 nuts
  • 4 only M4 x 10mm bolts
  • Hookup wire
  • Black PLA … 1.75mm diameter
  • Clear plastic food container … used to stiffen the film
  • Super Glue
  • The estimated cost of each encoder, excluding the Arduino test jig, is less than $20.00.

Step 1: Circuit

The circuit diagram for the “Polarized Light Encoder” is shown in photo 1.

The encoder itself is shown in gray highlight … everything else is for testing.

The peak output from the TEPT5600 ambiant light sensors is small. The LM324 non-inverting op-amps provide isolation and amplify the signals to the Arduino ADCs [1]

The unused sections of the LM324 are wired as voltage followers with the inputs connected to ground. This prevents unwanted (random) current fluctuations should an unused input change state.


Note

[1]

I found best linearity occurred when the TEPT5600 load resistors were small.

The gain of each non-inverting amplifier is 1+(2.2+1)/1 = 4.2

Step 2: Theory

Photo 1 shows several overlapping sheets of linear polarized film. The amount of transmitted light is determined by the angle at which each sheet overlaps the sheet underneath. My encoder makes use of this effect.

Photo 2 shows how sine and cosine waves are produced when a sheet of polarized film is rotated above two pieces of polarized film that are at angle of 45 degree to each other.

Note that there are two complete sine waves per shaft revolution.

The shaft angle can be calculated using this formula:

Shaft-angle = atan2(sin/cos)/2 + N*180 ………………….…….. (1)

Where N = number of completed sine waves out.

Photo 3 shows the sine and cosine waves obtained when the motor shaft is rotated 180 degree. The green sawtooth represents 0..180 degrees.

Photo 4 shows the sine and cosine waveforms obtained when the shaft is rotated a full 360 degrees. As predicted there are two complete sine waves per shaft rotation. The orange sawtooth represents 0..360 degrees.

It is interesting to note that, by combining the two sawtooths into one using equation (1), any error due to contamination (smudges/finger-prints) on the filters is halved. [1]


Absolute Encoding

Assuming that we have saved the calibration values, this encoder always knows its precise position within each half-revolution.

To convert it into an absolute encoder we need to know in which half-revolution it is at power-up.

This could be achieved by coating one half of the outer edge of the encoding disc with black paint and adding a third ambient light sensor without a polarizing film in front.


Note

[1]

Perfect sine waves require absolute cleanliness.

Fingerprints or dirt on the polarized disc will affect the shape of the sine waves by reducing the amount of transmitted light.

Step 3: STL Files

 The encoder comprises four separate pieces … two identical brackets, a PLA timing pulley, and an end plug. These parts are shown in photo1.

The brackets (photo 2) position the LEDs and the ambient light sensors at the correct heights. The recessed pockets are for the polarized film.

The STL file for the brackets is “polarized encoder bracket.stl” ……...…........… (1)

The timing pulley (photo 3), and matching end plug (photo 4), clamp a 42mm diameter linear polarized disc to the motor shaft. Details of the disc may be found in the construction section.

The STL file for the timing pulley is “polarized encoder pulley.stl” ……...........… (2)

The STL file for the plug is “polarized encoder plug.stl” …………….……........... (3)

All parts were printed on a Voxilab Aquila 3D printer using black 1.75mm PLA, a 0.4mm nozzle, and a layer height of 0.2mm.

Step 4: Construction

 Step 1

Assembling the disc.

  • Cut a 42mm diameter disc from a sheet of linear polarized film (photo 1).
  • Cut a 5mm diameter hole in the center.
  • Remove the protective film from both side of the disc.
  • Cut a square of clear plastic from a discarded food container … this is to “stiffen” the film.
  • Cut a 5mm diameter hole in the clear plastic as shown in photo 1.
  • Place the film and plastic sheet over the 5mm shaft on the end plug .
  • Apply a drop of super-glue on the 5mm end-plug shaft.
  • Insert the end-plug shaft into the screw end of the timing pulley.
  • Trim the plastic to the shape of the polarised disc once the super-glue has set.
  • Super-glue (as required) the outer edge of the polarized film to the clear plastic disc. [1]


Step 2

Assembling the ambient light sensors

  • Super-glue the two ambient light sensors into one of the brackets. The sensor leads should protrude over the mounting feet with the cathode (flat edge) of each sensor pointing downwards.
  • Edge-glue a square of polarized sheet, cut from the same 6.5mm strip, into each of the recessed pockets of the ambient light sensor bracket. Remove the protective film from both sides of each square before gluing. The corners of one square will need to be trimmed. [1]
  • Join the anode (top) leads from each sensor together.
  • Attach a length of hook-up wire to each of the exposed leads such that there is one common lead and two active.


Step 3

Assembling the LED light source

  • Super-glue the two green “clear-glass” LEDs into the remaining bracket. The sensor leads should protrude over the mounting feet with the cathode (flat edge) of each sensor pointing downwards.
  • Leave the recessed pockets in the bracket empty … do NOT insert any polarised film.
  • Join the flat-edge leads from each sensor together.
  • Attach a length of hook-up wire to each of the exposed leads such that there is one common lead and two active.


Step 4

Positioning the brackets

  • Photo 2 shows the assembled encoder.
  • The film on the polarized disc should face the bracket containing the ambient light sensors.


Notes

[1]

Be aware that super-glue will “travel” due to capillary action … use a toothpick to apply tiny drops to the edges.


Step 5: Software Installation

Method

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


Notes

The shaft encoder needs to rotate twice to acquire enough data before any waveforms will appear on your Serial Monitor.

A digital low pass filter is used to smooth the output waveforms from the photo transistors. Details of the digital filter may be found here Arduino Digital Low Pass Filter 2.0

The method for calculating the total shaft angle is explained here A practical example

Step 6: Summary

This instructable explains how to make a shaft encoder from three pieces of linear polarized film, two LEDs, two ambient light sensors, and an Arduino UNO R3.

Construction is simple … once you have printed the 3D parts, cut the polarized film to shape, and super-glue the components in place.

Angular resolution is determined by the number of bits in your ADC (analog-to-digital-converter).

Step 2 of this instructable explains how absolute encoding is possible.

Features include.

  • Non-contact
  • High resolution
  • Not affected by magnetic fields
  • Simple construction

The estimated cost of each encoder, excluding the Arduino test jig, is less than $20.00

This project is “proof-of-concept” and is published in the hope that it may be of use to someone.

  Click here   to view my other instructables.