Laboratory 7: CONTROL SYSTEMS FUNDAMENTALS OBJECTIVES - Familiarize the students in the area of automatization and control. - Familiarize the student with programming of toy robots. EQUIPMENT AND REQUERIED ELEMENTS - Legos Robotics Kit - Constructopedia - Computer ROBOTS A Robot is a machine controlled by a computer programmed to be moved, to manipulate objects and to carry out different tasks at the same time it interacts with its environment. Robots are capable of carrying out repetitive tasks quicker, less costly and more precisely than human beings. Depending to the application, different types of robots exist, as for example, industrial robots, didactic robots, toy robots, etc. In this practice we will make use of toy robots that imitate or even accomplish with some similar functions of didactic or experimental robots used for teaching and learning about robotics. The robots we will control consists of the following parts: Processing Unit - RCX, Motors, Sensors, Pieces (bricks, wheels, connectors, etc.) To assemble the robots we have Constructopedia, a computer guide with various robot models that can be built with the accessories of LEGOS. Description of the RCX unit The RCX is a programmable unit of the LEGO used to control the motors and sensors of the robot (Figure 1). Its interior is composed by a microprocessing unit that executes the instructions stored in the internal memory of the unit and that contains all the steps that the robot should execute. The components of the RCX are: - Microprocessing unit and internal memory. These two elements compose the central processing unit which controls the RCX. - Output ports A, B and C; these are used to connect the motors or any another auxiliary element that offers movement to the robot. - Input ports 1, 2 and 3; these are used to connect the sensors of light and touch or any another element used to guide the robot. - Control buttons; these are used to control the RCX unit. Contains the functions to turn on/off the unit, view of the state of the ports, selection of the program and execution of programs. 56
- Display; graphical interface that permits the user interact with the RCX unit. - Infrared transmitter; used to communicate the unit with the computer. - Speaker. Management of the RCX unit Figure 1 The RCX unit is controlled through the use of four buttons, these are: On-Off : turns on/off the unit. Run : Executes or stops the selected program. Prgm : Selects one of five programs stored in the unit which is chosen to operate. View : Collects information of the ports of the sensors or of the motors. Programming of the RCX unit The RCX unit can store up to five programs simultaneously. The execution of each one of these programs is done independently through the buttons Prgm and Run. To execute a stored program in one of the five slots of the RCX: - First select the slot which contains the program; to do this press various times the function Prgm. - Then execute the selected program by pressing on the function Run. To program the RCX we must use the computer software Robotics Invention System 2.0. This software has a graphical interphase that facilitates the construction of programs in a simple and quick way without the use of codes or instructions. Robotics Invention System 2.0 employs the flow diagram format to implement the programs, and the instructions are established in a form of graphic objects which symbolize the functions or operations required for the robot to do. 57
The RCX unit is programmed from the computer through the infrared interphase, as shown in Figure 2. To save a program in the RCX we must indicate from the computer the slot where we want to save it. This operation is done by entering in the menu Settings > Download to Slot. Roverbot Construction Figure 2 Constructopedia has a description of the diverse robots that can be built according to the application or convenience of the user. For this purpose we will only use one of them, the Roverbot, documented in pages 10 34 of the manual. This robot is easy to construct and has the characteristic of being fast and sturdy to move obstacles. Construct the Roverbot according to the instructions indicated in pages 12-17. Construct also the different types of sensors: The Single Bumper, The Double Bumper and The Light Sensor, which appear in pages 26, 30 and 34 respectively. In Figure 3 we can see the different configurations which can take the Roverbot. The Single Bumper 58
The Double Bumper The Light Sensor Basics Programs Control of the motors Figure 3 We intend to control the movement and velocity of the motors with the RCX unit. - Use the Roverbot without sensors. - To enter the program, localize in your computer desktop the Robotics Invention System 2.0 icon (the next commands Hill be done by left clicking the correct word). A menu will appear onscreen, select run, then choose explot and select enter. In the next window select program, then pick a robot, then Roverbot and finally program this robot. - After completing the previous steps a graphical interphase will appear of for the programming of the Robots. - In the graphical interphase of robot programming verify that the motors are properly connected. To do this, right click over the object Untitled, as shown in Figure 4. - In the new window that is opened, listed are the options to control the movements of the motors connected to ports A, B and C. Make use of these options to verify that the motors rotate in the adequate directions. - From the list of options Big Blocks, choose the instruction Forward and place it immediately under the beginning of the program Untitled, as shown in program 1 of Figure 5. - Download the program in the RCX unit by clicking in DOWNLOAD. 59
- Execute the program stored in the RCX unit by clicking in RUN. - Explain what the robot did. - To configure the time the motor is on, right-click over the instruction Forward. Place, for example 5 sec. - Load and execute again the program with the change in place. - To try other instructions that control the movement of the motors, experiment with programs listed 2, 3 and 4 in Figure 5. To eliminate the blocks (to be able to place a new instruction), select the block with a left-click and then place it in the trashcan that appears in the lower-left corner and left-click again. - Explain what occurs in the programs. Programa 2: Programa 3: Programa 4: Left Click Figure 4 60
Program 1 Program 2 Program 3 Program 4 Figure 5 - The speed of the motors is controlled with the amount of power consumed. We can choose other velocities by adding the block Set Power found in the Small Blocks as shown in Figure 6. - Load and execute again the program with the change in effect. - Explain what occurs in the program. Insert here Figure 6 Sensors Now we will verify the operation of the sensors. 61
Touch Sensor The sensor of touch will be used to cause the Roverbot to back away when it finds an obstacle. - Open a new project and use the Roverbot with the configuration Single Bumper. - Choose, between the options of Sensors, the Touch Sensor instruction. Place it in port 1 and keep the option of detecting events with press, as shown in Figure 7. - Construct the program according to the illustrated in Figure 8. - Load and execute again the program in the RXC unit. - Explain what occurs in the program. Light Sensor The light sensor will be used to cause the Roverbot to back away when it finds a dark line. - Open a new project and use the Roverbot with the light sensor. - Choose, between the options of Sensors, the Light Sensor instruction. Place it in port 2 and keep the option of detecting events which are dark, as shown in Figure 9. - Construct the program according to the illustrated in Figure 10. - Load and execute again the program in the RXC unit. - Explain what occurs in the program. Figure 7 62
Figure 8 Program to elude an obstacle The robot will be programmed to elude objects that appear in its course. In the program we will put in practice other instructions that will give more flexibility to the movement of the robot (see Figure 10). As it can be appreciated, we have included the instructions Repeat (this it is used when we want the movement to be continuous and not depend on time) and Beep (it emits a beep when it finds an obstacle). - Use the configuration of the Roverbot with the sensor Double Bumper. - Program the robot according to the illustrated in Figure 11. - Load and execute again the program in the RXC unit. - Explain what occurs in the program. Figure 9 63
Figure 10 Figure 11 Problem Elaborate a program so that the Rovertbot can follow a trajectory or a black line. Note: Use the instructions Repeat, Turn left, Turn right, and the instruction Yes or No. 64