DC motor closed-loop control software

By misan

433
37
Free
It's free to download

Information

DC motor closed-loop control software

By misan

 This program uses an Arduino for a closed-loop control of a DC-motor.    Motor motion is detected by a quadrature encoder.   Two inputs named STEP and DIR allow changing the target position.   Serial port prints current position and target position every second.   Serial input can be used to feed a new location for the servo (no CR LF).    Pins used:   Digital inputs 2 & 8 are connected to the two encoder signals (AB).   Digital input 3 is the STEP input.   Analog input 0 is the DIR input.   Digital outputs 5 & 6 control the PWM outputs for the motor (I am using half L298 here).   Please note PID gains kp, ki, kd need to be tuned to each different setup. Motor's specs : http://www.mabuchi-motor.co.jp/en_US/cat_files/rs_385sh.pdfUpdate: I have just added a new version of the firmware that using an additional interrupt on pin change will allow 4x encoder resolution. PWM output frequency has been raised outside of the audible range too (31Khz) but output pins have been changed, so check the comments in the code.Update2:  I have uploaded the capture of an analyzer showing the signals from the encoder, the step and dir pins and the PWM outputs of an ongoing print operation. The saleae software can be downloaded to browse through the capture (use latest beta). https://www.saleae.com/Downloadshttps://www.youtube.com/watch?v=L-_5KsAOVko&list=UU5fzVBdQrnYixQsIhPOYCgwUpdate2:  Update3: I have added a much more elaborate version of the controller code now with EEPROM support and serial port setting of PID values https://github.com/misan/dcservo/blob/master/dcservo.ino
17 objects 59 Followers 13334 Downloads
Joined over 10 years ago Valencia, Spain
Enjoy a 10% sitewide
Discount at checkout
Get a 10% Discount