askuric / arduino-closed-loop-motor-control Goto Github PK
View Code? Open in Web Editor NEWArduino Based Simple Closed Loop Motor Control library
License: MIT License
Arduino Based Simple Closed Loop Motor Control library
License: MIT License
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
Hi @askuric ,
Today I tested your angle control code. I found it has two issues.
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.
I have tried many parameters of K
Ti
velocity_limit
voltage_limit
, but they have no effect.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.