Three-level controller

Now, let's examine a version of this program using the rotation sensor. This program is similar to the previous program except that the angle is set to 400 (the probable rotation of the wheels) and the blocks are set to the rotation sensors instead of the Gyro Sensors. The Gyro program used a two-level controller. A path in the case structure was chosen based on the robot's position relative to a setpoint value. Notice that, in this program, I have a switch within a switch. This allows for a three-level controller. When the robot is actually at the set-point value, no motion takes place.

Three-level controller

In the preceding screenshot, you can see the path the switch takes for the true case of when the Motor Rotation sensor is greater than the value of the angle variable. In the following screenshot, you can see the false case, when the value is not greater than the value of the angle variable. You can see in the screenshot that to make three levels we need the switch within a switch. In the embedded switch, if the value of the rotation sensor is less than the value of the angle variable, the robot turns the other way. For the false case of the embedded switch, the Motor Rotation sensor must be equal to the value of the angle variable. The robot does not move and we use a Loop Interrupt block to end the Loop. For the Loop Interrupt block, we must name the Loop that you want to end.

Three-level controller
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.116.20