Design of Control Strategy Environmental Disturbances Goal Control
Design of Control Strategy Environmental Disturbances Goal Control Strategy System Dynamics Sensors Feedback Output
Linebot • Goal – Follow the path defined by the black line • Strategy – Drive left and right wheels at same speed – If left light sensor drops below threshold turn left. – If right light sensor drops below threshold turn right.
Linebot Implementation //define motor outputs #define LEFT OUT_A #define RIGHT OUT_B #define REYE SENSOR_1 #define LEYE SENSOR_3 #define THRESH int dir=0; task main() { // configure the sensor Set. Sensor. Light (IN_3); Set. Sensor. Light (IN_1); } Start. Task (decision); Start. Task (motion_control); We introduce a global variable: dir. If dir = 0 we will travel straight. A negative value for dir will cause us to turn left and a positive value of dir will cause us to turn right. Two sensors LEYE and REYE are defined; note that reference for configuration is different than for reading port level. Two parallel tasks are started. Task decision will read the sensors and decide if we should go straight, turn left, or turn right. It will set the global variable dir to 0, -1, 1 depending on the readings of the sensors. Task motion_control will have access to the global variable dir and, based on that value, actuate the motors accordingly.
Linebot Implementation task decision() { // write the statements for this task } task motion_control() { // write the statements for this task } Task decision must continuously monitor the sensors (forever). It sets the global variable dir to -1, 0, 1 depending upon the sensor readings. This will depend on the value of the defined constant THRESH. Task motion_control has a fast loop which cycles forever. It accesses the global variable dir and adjusts the motor signals.
The Decision x L LEFT_EYE RIGHT_EYE W High value Threshold value Low value X -W/2 RIGHT_EYE AND LEFT_EYE both above threshold go straight RIGHT_EYE below threshold turn right LEFT_EYE below threshold turn left
- Slides: 5