How to control a DC motor with an encoder
Video Statistics and Information
Channel: Curio Res
Views: 276,106
Rating: undefined out of 5
Keywords:
Id: dTGITLnYAY0
Channel Id: undefined
Length: 9min 30sec (570 seconds)
Published: Tue Feb 16 2021
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
Awesome! I've been doing this recently using DC motors with encoders for a more "professional" linear motion system. For others looking into this sort of thing, I have some more tips.
Most importantly is to actually verify you aren't losing counts from your encoder. Higher speed motors can very easily start losing counts early on. I have a 1000 rpm motor, and I start losing counts around 250 rpm, which is why I am replacing the Arduino with an ESP32. Physically, the motor appeared to be fine keeping track of counts setting a PWM of 160, however, it was still losing about 10 counts out of 12800 at that speed. Only when it was down to about 125 in the PWM did it stop skipping.
To be honest, it is most likely best to have a controller dedicated exclusively towards the counts for the encoder and nothing else. The only thing it does is count using the interrupts and send the current counts when requested. Arduinos are just not good enough for DC motor encoders.
Another thing I would recommend too is to access the pins directly to read the state inside the interrupts using port manipulation. PIN is faster than digitalRead. I was able to increase my PWM value before losing counts by about 20.
Very Nicely explained!
Who actually made this, you or /u/make-life?
https://old.reddit.com/r/ControlTheory/comments/ll9i5x/a_simple_video_i_created_to_explain_pid_control/
Clear development of concepts. Good use of visuals. Excellent code breakdown. all-around fantastic presentation. Well done!