I have a PID program that sends my linear actuator with potentiometer feedback to roughly the same position within 0.05 inches accuracy as the result of several measurements I've taken.
When it reaches the target position it makes a droning sound that comes from the motor getting small inputs from the PID function.
Here is the graph of the result. https://imgur.io/a/9qZsM2N
- Does this damage the motor?
- What is the best way to get rid of this droning sound?
- Should I have it time out?
- Is my PID incorrectly tuned?
#include <PID_v1.h>
#include "CytronMotorDriver.h"
#include <SimpleKalmanFilter.h>
double Input, Output; // ,Setpoint
double Setpoint = 88;
// Specify the links and initial tuning parameters
double Kp = 48, Ki = .1, Kd = 17.6;
PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, DIRECT);
SimpleKalmanFilter simpleKalmanFilter(2.0f, 2.0f, 0.01f);
CytronMD motor(PWM_DIR, 9, 8);
void setup() {
Serial.begin(9600);
myPID.SetSampleTime(200);
myPID.SetOutputLimits(-255, 255);
myPID.SetMode(AUTOMATIC);
}
void loop() {
Input = simpleKalmanFilter.updateEstimate(analogRead(A0));
myPID.Compute();
Serial.println(Output);
motor.setSpeed(Output);
Serial.print("analog value on Pot:");
Serial.print(analogRead(A0));
Serial.print("input:");
Serial.print(Input);
Serial.print(",");
Serial.print("output:");
Serial.print(Output);
Serial.print('\n');
}