GithubHelp home page GithubHelp logo

askuric / arduino-closed-loop-motor-control Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 4.0 27 KB

Arduino Based Simple Closed Loop Motor Control library

License: MIT License

C++ 98.27% C 1.73%
arduino motor-control closed-loop-control encoder arduino-library

arduino-closed-loop-motor-control's People

Contributors

askuric avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

arduino-closed-loop-motor-control's Issues

In velocity mode index_search failed

Hi @askuric , I set up a simple test environment, I use arduino 2560 and my motor drive DRV8840.
When I set the index pin:

Encoder encoder = Encoder(arduinoInt1, arduinoInt2, 128, A0);

Connect the A0 pin to the index of the encoder, The motor rotates, but it can never be completed.

DEBUG: Serial debugger enabled!  
DEBUG: Initilaise the motor pins.
DEBUG: Set high frequency PWM.   
DEBUG: Enabling motor.
DEBUG: Align the encoder and motor electrical 0 angle.
DEBUG: Search for the encoder index.

I tried not to use the index pin, set it to 0, I successfully entered

DEBUG: Serial debugger enabled!  
DEBUG: Initilaise the motor pins.
DEBUG: Set high frequency PWM.   
DEBUG: Enabling motor.
DEBUG: Align the encoder and motor electrical 0 angle.
DEBUG: Index not available!
Motor ready.
Input the new target velocity:

Through motor_monitor (); I can monitor my motor status very well. But when I input the velocity value between 0-450, the motor will jitter irregularly. After setting the velocity value greater than 500, the motor works well, but the speed will be maintained at around 460 even if I increase the velocity value.

I don't know if this is related to the parameters of PID.

the motor i used 483068

angle control Back and forth

Hi @askuric ,
Today I tested your angle control code. I found it has two issues.

  1. I adjust the motor.P_angle.K value to allow the motor to start running smoothly, But it will always oscillate back and forth between target values. the log:
-0.10   10000.00        9999.98
-0.14   10000.00        9999.98
-0.18   10000.00        9999.98
-0.21   10000.00        9999.98
-0.25   10000.00        9999.98
-0.28   10000.00        9999.98
-0.25   10000.00        9999.97
-0.21   10000.00        9999.97
-0.17   10000.00        9999.97
-0.14   10000.00        9999.97
-0.10   10000.00        9999.97
-0.07   10000.00        9999.96
-0.03   10000.00        9999.96
0.00    10000.00        9999.96
0.04    10000.00        9999.96
0.07    10000.00        9999.96
0.11    10000.00        9999.96
0.14    10000.00        9999.96
0.18    10000.00        9999.96
0.22    10000.00        9999.96
0.25    10000.00        9999.96
0.29    10000.00        9999.96
0.32    10000.00        9999.96
0.28    10000.00        9999.97
0.25    10000.00        9999.97
0.21    10000.00        9999.98
0.18    10000.00        9999.98
0.14    10000.00        10000.00
0.11    10000.00        10000.00
0.07    10000.00        10000.01
0.03    10000.00        10000.01
-0.00   10000.00        10000.01
-0.04   10000.00        10000.01
-0.08   10000.00        10000.01
-0.11   10000.00        10000.01
-0.15   10000.00        10000.01
-0.18   10000.00        10000.01
-0.22   10000.00        10000.01
-0.26   10000.00        10000.01
-0.29   10000.00        10000.01
-0.33   10000.00        10000.01
-0.37   10000.00        10000.01
-0.33   10000.00        10000.00
-0.29   10000.00        10000.00
-0.25   10000.00        9999.98
-0.22   10000.00        9999.97
-0.18   10000.00        9999.96
-0.14   10000.00        9999.95
-0.10   10000.00        9999.94
-0.07   10000.00        9999.92
-0.03   10000.00        9999.92
0.00    10000.00        9999.92
-0.03   10000.00        9999.91
0.00    10000.00        9999.91
0.04    10000.00        9999.91
0.07    10000.00        9999.91
0.11    10000.00        9999.91
0.14    10000.00        9999.91
0.18    10000.00        9999.91
0.21    10000.00        9999.91
0.25    10000.00        9999.91
0.28    10000.00        9999.91
0.32    10000.00        9999.91
0.28    10000.00        9999.92
0.25    10000.00        9999.92
0.21    10000.00        9999.94
0.17    10000.00        9999.94
0.14    10000.00        9999.95
0.10    10000.00        9999.95
0.07    10000.00        9999.96
0.03    10000.00        9999.96
-0.00   10000.00        9999.96
-0.04   10000.00        9999.97
-0.07   10000.00        9999.97
-0.11   10000.00        9999.97
-0.15   10000.00        9999.97
-0.18   10000.00        9999.97
-0.15   10000.00        9999.96
-0.11   10000.00        9999.96
-0.08   10000.00        9999.96
-0.04   10000.00        9999.96
-0.01   10000.00        9999.96
0.03    10000.00        9999.96
0.06    10000.00        9999.96
0.10    10000.00        9999.96
0.14    10000.00        9999.96
0.17    10000.00        9999.96
0.21    10000.00        9999.96
0.24    10000.00        9999.96
0.20    10000.00        9999.97
-0.36   10000.00        9999.97
-0.32   10000.00        9999.96
-0.28   10000.00        9999.96
-0.25   10000.00        9999.95
-0.21   10000.00        9999.94
-0.17   10000.00        9999.92
-0.13   10000.00        9999.91
-0.10   10000.00        9999.91
-0.06   10000.00        9999.90
-0.02   10000.00        9999.89
0.01    10000.00        9999.89
-0.03   10000.00        9999.87
0.29    10000.00        9999.87
0.32    10000.00        9999.87
0.29    10000.00        9999.89
0.26    10000.00        9999.89
0.22    10000.00        9999.90
0.19    10000.00        9999.91
0.15    10000.00        9999.91
0.11    10000.00        9999.92
0.08    10000.00        9999.92
0.12    10000.00        9999.94
0.08    10000.00        9999.94
0.05    10000.00        9999.94
0.08    10000.00        9999.95
-0.30   10000.00        9999.95
-0.27   10000.00        9999.94
-0.23   10000.00        9999.94
-0.20   10000.00        9999.94
-0.16   10000.00        9999.92
-0.12   10000.00        9999.92
-0.09   10000.00        9999.92
-0.05   10000.00        9999.91
0.27    10000.00        9999.91
0.23    10000.00        9999.92
0.19    10000.00        9999.92
0.16    10000.00        9999.92
0.12    10000.00        9999.92
0.09    10000.00        9999.92
0.05    10000.00        9999.92
0.02    10000.00        9999.94
-0.02   10000.00        9999.94
-0.05   10000.00        9999.94
-0.09   10000.00        9999.94
-0.12   10000.00        9999.94
-0.16   10000.00        9999.94
-0.19   10000.00        9999.94
-0.23   10000.00        9999.94
-0.20   10000.00        9999.92
-0.16   10000.00        9999.92
-0.12   10000.00        9999.92
-0.09   10000.00        9999.92
-0.05   10000.00        9999.92
-0.02   10000.00        9999.92
0.02    10000.00        9999.92
0.05    10000.00        9999.92
0.09    10000.00        9999.92
0.12    10000.00        9999.92
0.16    10000.00        9999.92
0.19    10000.00        9999.92
0.23    10000.00        9999.92
0.26    10000.00        9999.92
0.30    10000.00        9999.92
0.26    10000.00        9999.94
0.24    10000.00        9999.94
0.21    10000.00        9999.94
0.18    10000.00        9999.95
0.14    10000.00        9999.95
-0.39   10000.00        9999.96
-0.35   10000.00        9999.95
-0.31   10000.00        9999.95
-0.28   10000.00        9999.94
-0.24   10000.00        9999.92
-0.20   10000.00        9999.90
-0.24   10000.00        9999.89
-0.20   10000.00        9999.87
-0.16   10000.00        9999.86
-0.13   10000.00        9999.85
-0.09   10000.00        9999.84
-0.05   10000.00        9999.82
-0.02   10000.00        9999.82
-0.06   10000.00        9999.81
0.33    10000.00        9999.81
0.36    10000.00        9999.81
0.40    10000.00        9999.82
0.43    10000.00        9999.82
0.40    10000.00        9999.84
0.36    10000.00        9999.85
0.32    10000.00        9999.86
0.29    10000.00        9999.89
0.25    10000.00        9999.91
0.21    10000.00        9999.94
0.25    10000.00        9999.95
0.21    10000.00        9999.97
0.18    10000.00        10000.00
0.14    10000.00        10000.02
0.10    10000.00        10000.05
0.06    10000.00        10000.07
0.03    10000.00        10000.08
-0.01   10000.00        10000.11
-0.05   10000.00        10000.12
-0.09   10000.00        10000.14
-0.13   10000.00        10000.14
-0.09   10000.00        10000.16
-0.27   10000.00        10000.17

In the position control loop, it can't reach the target and oscillates back and forth is bad.

  1. When I started running from position 0 to 10000, the motor stopped several times and did not run smoothly to 10000 as expected.

I have tried many parameters of K Ti velocity_limit voltage_limit, but they have no effect.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.