Welcome to GeeKee CeeBee's Page: House of Mechatronics Projects & Lessons.
Contact Email: Ceebee1108@gmail.com
Follow me on Youtube
__________________________________________________________________________________________________________________________________
Anti-Backlash Dual Encoder Motor Position Control
Step by step practical guide to Anti-backlash position tracking control of a DC motor + gearhead with backlash using Arduino Mega.
Dual encoder multi-loop control model for more accurate motor position control.
Write PID code from scratch (w/o using pre-written library) for backlash compensation.
Demonstrate the use of rotary encoders, rotary potentiometer, L298n motor driver, interrupt service routine, multi-loop motor control algorithm.
Disclaimer: The code and other information on this project are provided on "AS IS" basis with no warranty. Please follow best practices and assess
your own potential risks for this project.
Components List
Arduino Mega ( No Uno/Nano: Need 4 ISR pins) (Affiliate Link)
In this video, we will perform position control of a motor with gearhead that has backlash.
We will use a dual encoder approach to reduce mechanical backlash for more accurate position control.
Control Diagram
We will start with just the motor which is our system. With given voltage, Motor will start to rotate, but to measure the angle of the motor shaft we read the backend encoder of the motor.
And figure out the error in our system. To correct this error, we add a PID controller.Now to correct position error caused by the backlash, add 2nd encoder feedback to our system.
Simply add a Proportional controller to compensate for the backlash error.
This is called a dual loop control model. Where inner loop runs 5 times faster than the outer loop.
Wiring Diagram
Below is the wiring diagram for the components used in this project.
Pin 2 and 3 are used for back encoder ISR and pin 18 and 19 are used for front encoder ISR. Analog pin A0 is used for rotary potentiometer input which generates reference signal for this system.
Pin6 is the PWM pin to control the amount of voltage sent
to the motor driver. Pin7 and 8 are used to change motor direction by changing the polarity of the supply voltage with the help of
L298n h-bridge motor driver. Please check power supply rating of you motor and accordingly select a power supply for your project.
Make sure there's a common ground (not earth ground) between the motor driver, arduino and external power supply.