Hello @assaf,
Yes, an encoder can be added to a stepper motor. However, it’s not a common configuration. Most of the time, the stepper motor runs open loop. The system assumes the stepper faithfully completes each step.
As for a DC motor and encoder, here are a few articles to get you started:
-
Design a Robust Quadrature Encoder ISR based program for Arduino Motor Control
-
Brushed DC Motor Control Using an MDD3A H-bridge Featuring FreeRTOS and the Arduino C33
Notice that timing is a critical requirement for reading the sensor. Responsive ISRs are required of the motor position will be lost.
DC motor control is worthy of study as there is so much material to learn.
Best wishes,
APDahlen