







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








CO.
CO.
CO.
void main() { int y , i ; float r = 0.0; float e_curr; // current error float check_time; float t_sample = .03; // sample time float u_control; float e_prev = 0.0; float i_prev = 0.0; // PID Values float kp=0.6; float td=0.00; float ti=100000.0; float mvalue; int knob_value;
CO.
// reduces sensitivity of knob and set to standard speeds while(!stop_button()) { if(knob()<= 25) knob_value=15; if(knob()>25 && knob()<=50) knob_value=18; if(knob()> 50 && knob()<=75) knob_value=20; if(knob()>75 && knob()<=100) knob_value=23; if(knob()>100 && knob()<=125) knob_value=25; if(knob()> 125 && knob()<=175) knob_value=27; if(knob()>175 && knob()<=225) knob_value=30; if(knob()>225 && knob()<=255) knob_value=32; printf("%d\n",knob_value); msleep(200L); }
CO.
Stop Button Pressed?
Object
Check_time= seconds – t_sample * (float)(i) Set u_control^ Set y (error) Set e_curr Motor(1,u_control) Update errors^ and integrals Set integral i ++ -.01< Time <0.01?
CO.
while(!stop_button()) { check_time = seconds()- t_sample(float)(i); if (check_time < 0.01 && check_time > -0.01) { while(analog(5)>8) { float i_curr= i_prev + 0.5 * (e_curr + e_prev)t_sample; u_control = kpe_curr + kptd(e_curr - e_prev)/t_sample + (kp /ti)i_curr; y= analog(4)-analog(2); e_curr=r-(float)(y); //set motor speed to u_control motor(1,(int)(u_control)); e_prev=e_curr; i_prev=i_curr; i++; } ao(); tone(1000.0,0.3);tone(999.0,0.3);tone(850.0,0.3); tone(750.0,0.3);tone(642.0,0.3);tone(510.0,0.3);tone(510.0,0.3); printf("\nClear!"); } } ao(); printf("\nBye!"); beep();beep(); }
CO.
Varing Kp -100-150 -
0 50 250200150100 0 1000 2000 3000 4000 Time (msec.) Tracking Error (y) kp=1.0kp=0.8kp=0.6kp=0. Use Kp=0.
CO.
0 80 60 40 20 180160140120100 0 200 400 600 800 1000 Time (msec.) Tracking Error (y) ti=500ti=1000ti=10,000ti=100, Use ti=
CO.