Title: Mechatronics Design Project
1Mechatronics Design Project Spring 2003
Demonstration May 7, 2003
2Hardware Update
- Previous Car was difficult to Control
- Steering had too much play in wheels
- Decided to get a new system rather than fix
- due to time constraint
3- Drive Motor
- located at rear of car
- Controls speed
New Hardware
- Main Difference
- - spring return
- Steering Motor
- - located at front
- controls tracking of
- car based on track
- sensors
- - Utilizes PID controller
4Sensors
- Already Calibrated
- 2 Front Sensors (follow track)
- 1 inch apart, best distance
1
5Other Adjustments
- Changed track to ¾ inch wide
- - sensors on outside of track
- Change track color to cardboard brown
- - provided less contrast than white background
6Flow Chart Code
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 kp0.6 float td0.00
float ti100000.0 float mvalue int
knob_value
start
Declare Variables
continued
7// reduces sensitivity of knob and set to
standard speeds while(!stop_button())
if(knob()lt 25) knob_value15
if(knob()gt25 knob()lt50) knob_value18
if(knob()gt 50 knob()lt75) knob_value20
if(knob()gt75 knob()lt100)
knob_value23 if(knob()gt100
knob()lt125) knob_value25 if(knob()gt
125 knob()lt175) knob_value27
if(knob()gt175 knob()lt225) knob_value30
if(knob()gt225 knob()lt255) knob_value32
printf("d\n",knob_value)
msleep(200L)
Set speed With knob
Stop Button Pressed?
no
yes
continued
8Start Button Pressed?
printf("press start!") start_press()
reset_system_time() //set motor speed to knob
values motor(3,knob_value)
no
yes
Reset system time
Motor speed knob value
continued
9Stop Button Pressed?
yes
Check_time seconds t_sample (float)(i)
no
-.01lt Time lt0.01 ?
no
yes
Object near Side ?
Set integral
Motor(1,u_control)
i
Set u_control
Update errors and integrals
Set y (error)
yes
Set e_curr
end
10while(!stop_button())
check_time seconds()- t_sample(float)(i)
if (check_time lt 0.01 check_time gt -0.01)
while(analog(5)gt8)
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_currr-(float)(y) //set motor speed to
u_control motor(1,(int)(u_control)
) e_preve_curr
i_previ_curr i
ao() tone(1000.0,0.3)tone(999.0,0.3)t
one(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()
11Tuning PID Controller
- Process
- Introduced step input curve
- lined up car on marks for each measurement
- Car ran at constant speed, 23
curve
marks
12Varing Kp
- Initial Kp set to 1.0
- Varied Kp 1.0 ? 0.3
- Ti 100,000
- Td 0.0
Use Kp0.6
13Varing Ti
- Initial Ti set to
- 100,000
Use ti500
14Varing Td
- Initial Td set to 0
- does not seem
- to decrease response
- time but less over
- Shoot
Use td0.5
15- Demonstration - Questions?