Controlling DC motor overshoot
hello everyone,
i working on project need relatively accurate , consistent positioning dc motor. motor sent command of position go to, , power cut motor @ target position, motor has overshoot , goes past target.
i found arduino pid library , attempted use fix overshoot, , seems helping some, i'm not sure if i'm using properly. below sample of code of how i'm using it:
here line declared pid controller:
the current position , target changing based on commands send arduino. intention pid controller @ current position, , target , adjust speed of motor approaches target minimize overshoot.
i'm open solution, if has better idea other pid controller fix overshoot issue please let me know. of help.
i working on project need relatively accurate , consistent positioning dc motor. motor sent command of position go to, , power cut motor @ target position, motor has overshoot , goes past target.
i found arduino pid library , attempted use fix overshoot, , seems helping some, i'm not sure if i'm using properly. below sample of code of how i'm using it:
code: [select]
void leftfifteen() {
//checks see if window way or stopped in middle
midupcheck();
targetl = 167; //this desired position
if (!stopcheck(serialdata1)) {
if(enccountl > targetl) { //if current position > target position
leftwindow.setcontrollerdirection(reverse);
leftwindow.compute();
serial.println(f("decreasing angle of left window 15"));
downleft(speedl); //tell motor move @ specifc speed , direction
while (enccountl > targetl) { //runs while motor isn't @ correct position
//checks requested stop
if(stopcheck(serialdata1)) {
break;
}
}
digitalwrite(in2,low);
}
//same above if target lower current
else if(enccountl < targetl) {
leftwindow.setcontrollerdirection(direct);
leftwindow.compute();
serial.println(f("increasing angle of left window 15"));
upleft(speedl);
serial.println(speedl);
while (enccountl < targetl) {
//checks requested stop
if(stopcheck(serialdata1)) {
break;
}
}
digitalwrite(in1,low);
}
}
}
here line declared pid controller:
code: [select]
pid leftwindow(&enccountl,&speedl,&targetl,2.0,5.0,1.0,direct);
//enccountl = current position
//speedl = speed of motor (pwm)
//targetl = target position
the current position , target changing based on commands send arduino. intention pid controller @ current position, , target , adjust speed of motor approaches target minimize overshoot.
i'm open solution, if has better idea other pid controller fix overshoot issue please let me know. of help.
you need tune pid loop - read it, there's lot of resources out there on topic.
Arduino Forum > Using Arduino > Motors, Mechanics, and Power (Moderator: fabioc84) > Controlling DC motor overshoot
arduino
Comments
Post a Comment