Skip to content

Encoder

iliasam edited this page Jan 24, 2024 · 14 revisions

Encoder consists of two main parts: encoder disc and optical sensor

Encoder disc

I have taken this disc from old ball mouse.
Encoder photo
This disc have 65 slits, one of them is closed (but it is counted too: 64 opened + 1 closed) - it is zero angle reference mark.
See this drawing:
image

Number of slits is defined in "config.h" file: "ENCODER_HOLES_CNT".
Diameter of the disc is 15.5 mm.

Optical sensor

I have taken mine sensor from old printer so I can't give exact name of it. It is conventional opto-interrupter, with one LED and one NPN photo-transistor.
Closed opto-interrupter (no current through opto-transistor) is need to produce high level at the sensor output.
Notice that if you are using disc with a small diameter, you need to use sensor with small diameter of the optical beam - usually such sensors have smaller packages.
It is recommended to make sensor fixing adjustable - to change position of the light beam in relation to disc.
Sensor is connected to the PCB using 3 wires: +3.3V (ENC PWR), GND, Signal (connect it to P6 pad).
See "PCB_3D_view_up.png": https://github.com/iliasam/OpenTOFLidar/blob/develop/PCB/PCB_project_v4/PCB_3D_view_up.png
You can use R34 as a pulp-up for opto-interrupter photo-transistor.

This is how signal from the sensor should look at the oscilloscope when motor is running:
Signal from oscilloscope
Zero mark "pulse" is shown at the center of this image.

Signal from the sensor goes to comparator integrated to the MCU. Comparator reference voltage is 1.2V. See: "encoder_processing.c" and "config.h":
#define ENCODER_COMP_NEG_SRC COMP_InvertingInput_1_2VREFINT

Clone this wiki locally