DC motor closed-loop control software

By misan

999
37
Free
It's free to download
Main Image
Preview Image Preview Image Preview Image Preview Image Preview Image Preview Image

Information

DC motor closed-loop control software

By misan

at 2024-05-03
 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

License

Related objects

17 objects 59 Followers
Joined almost 11 years ago Valencia, Spain

YouMagine

a MyMiniFactory company
© 2024 YouMagine. All rights reserved.  2 Berners Road, Islington, London, N1 0PW, United Kingdom