Вы находитесь на странице: 1из 29

3.1.

7 Machine Control: Apple Elevator

By: Maleko Bravo Hanan Kashkoul Alejandro Martinez John Mayen John Ong Malissa Rodriguez #304 #312 #316 #317 #322 #326

Project Lead the Way: Principles of Engineering Period 3 February 21, 2014

3.1.7 Machine Control: Apple Elevator

Table of Contents
Section Page

Design Brief Final Pictures Final Code Hanans Reflection Questions Alejandros Reflection Questions John Mayens Reflection Questions Malissas Reflection Questions Malekos Reflection Questions John Ongs Reflection Questions

1 2-3 4-6 7 - 10 11 - 14 15 - 17 18 - 19 20 - 23 24 - 26

3.1.7 Machine Control: Apple Elevator

Design Brief
Client: Elevator Company Designers: Maleko Bravo, Hanan Kashkoul, Alejandro Martinez, John Mayen, John Ong, Malissa Rodriguez Problem Statement: A company would like to begin producing residential elevators. Your team must design the control system and a prototype of an elevator that can go between four floors in any combination. The prototype must include a set of four switches to represent each floor of the elevator. Each floor the elevator stops at, must have a call button and a set of four lights to indicate where the elevator is currently located. A built-in safety mechanism requires that the elevator normally rest on the ground floor and return to the ground floor after a user determined period of non-use. Design Statement: Design and build an elevator that meets the given constraints and satisfies the companys requirements. Constraints: 1. Must be able to go between four floors in any combination. 2. Must include a set of four switches to represent each floor. 3. Must have a call button. 4. Must have a set of four lights to indicate where the elevator is currently located.

3.1.7 Machine Control: Apple Elevator


Final Pictures
FIgure 1

Figure 2

Figure 3

Description of Pictures
In Figure 1, you have our elevator. In the elevator, there are many different sensors that make the elevator function the way it does. For example, you have four

3.1.7 Machine Control: Apple Elevator


bump switches that control which floor the elevator goes to. If you click the first bump switch, it will make the elevator go to the 1st floor. In the elevator, there are 369 motors that make the platform move up and down. There is an ultrasonic sensor, which is main component. With this sensor, we can tell the code to make the platform move up floors by a specific range that it detects. The elevator is built with gears, sprockets, and a lot of additional VEX equipment. In Figure 2, you can see our platform and our ultrasonic range finder under it. We are using a fairly wide card as a platform so that the ultrasonic range finder can then detect how far it is off the base. We can then use the values from the ultrasonic range finder to control how high up and how low the platform goes. We set values to each floor so that when a bump switch is activated for a certain floor, the chain and sprocket system moves the platform up or down until the ultrasonic range finder gives us that output. In Figure 3, our chain and sprocket system can be seen. In our machine, we have chains and sprockets on both sides of the platform for stability. These chain and sprocket systems are what move the platform up and down from floor to floor. Using a chain and sprocket system is both stable and efficient for moving the platform to different floors.

Final Code

3.1.7 Machine Control: Apple Elevator

3.1.7 Machine Control: Apple Elevator

3.1.7 Machine Control: Apple Elevator

In this code, you have a preset destination of where the four floors are. The ultrasonic sensor sees and knows where those floors are because it has a cone field of vision. This is also why our code sometimes has issues. Because the sensor has a cone field of vision, the sensor picks up the chain, which causes some problems because now the sensor lost its train of thought, and it cannot figure out where the distance of the floor is. In our elevator, we have two towers, each with two 369 motors. We designed the elevator in a way that the one motor will run counterclockwise while the other motor runs clockwise. In our code, we have if statements and what happens is that if the bump switch for the first floor is pressed, and when it is pressed we know that the value is one, one motor will run clockwise and the other motor will run counterclockwise, which will raise the platform to the preset destination, which is the first floor. This is the same process if the platform is at the base level. Consequently, if the elevator is on the base floor and the button for the third floor is pressed, then the platform will rise to the third floor. This applies to all of the bump switches when the platform is on the base floor. However, if the platform is on the fourth floor and the bump switch for the second floor is pressed, then the motor that is going clockwise will go counterclockwise, and the motor that is going counterclockwise will go clockwise; in turn, the platform will go to the preset distance where the second floor is, in order for the platform to go to the second floor. This idea applies with any other floor.

Reflection Questions

3.1.7 Machine Control: Apple Elevator


Hanan Kashkoul 1. Name three analog and three digital sensors. Explain each in detail (how each works, what port they would plug into, what input/output would be, etc) The first analog sensor is a potentiometer. It plugs into the analog port on the cortex. It is capable of measuring the rotation of a shaft between zero and 265 degrees, and cortex returns values between zero through 4095; it returns a range of values (not limited to one and zero) because it is an analog sensor. The next analog sensor is a light sensor. Light sensors use a photocell that allows the robot to respond to light when it detects it. The light sensor, like the potentiometer, plugs into the analog port in the cortex. It returns a range of values, too, since it is an analog sensor. The last analog sensor is the line follower. The line follower also plugs into an analog port and returns a range of values. This sensor is capable of detecting a white line on a black surface or a black line on a white surface and following the line. Next, one digital sensor is the bump switch. It works by pressing on the gray button. When it is pressed, the output value is one. When it is not pressed, the output value is zero. This is because it is a digital sensor, and the only outputs are ones and zeros. The bump switch plugs into a digital port. The second digital sensor is the limit switch. It works by pushing the metal part. Like the button switch, when it is pressed, the output is one, and when it is not pressed the value is zero. It plugs into a digital port on the VEX Cortex. The third digital sensor is the optical shaft encoder, which is capable of measuring the direction and position of rotation of a shaft. It would plug into the digital port. This sensor identifies each point in a movement with a digital signal, and it assigns each point with a digital signal. As the encoder counts, the inner shaft spins. It is capable of 360 counts per revolution, it counts up and down, and it lets you control how far the robot travels by controlling how much the wheels spin. 2. Describe the cortex in detail (the purpose, the ports, the connections, etc) The cortex is one of the main components of a robot. It coordinates the flow of information and power. It has three different types of ports: digital ports, analog ports, and motor ports. There are twelve digital ports, eight analog ports, and ten motor ports. Ports one and ten are 2-wire DC ports. The cortex fits a USB cable or a wireless key for remote control and wireless programming. 3. There are three types of behaviors. List and describe each. Then, give 2 examples of actual code for each of the three behaviors. The three types of behaviors are basic, simple, and complex. Basic behaviors are the size of

3.1.7 Machine Control: Apple Elevator


single statements, like turning on a motor. Simple behaviors are small, and they allow the robot to perform simple, yet important, tasks. This behavior is the most useful behavior because it is small so that it is easy to code and big enough so that the task is significant. The highest level of behavior is complex behavior, and this type of behavior is composed of smaller behaviors. Basic behavior examples: #1. task main() { startMotor(RightMotor, 63); } #2. task main() { stopMotor(RightMotor); } Simple behavior examples:

#1. task main() { startMotor(RightMotor, 63); startMotor(LeftMotor, 63); wait(4); } #2. task main() { startMotor(RightMotor, 63); wait(4); stopMotor(RightMotor); } Complex behavior examples:

3.1.7 Machine Control: Apple Elevator


#1. task main() { startMotor(RightMotor, 63); startMotor(LeftMotor, 63); wait(4); startMotor(RightMotor, -63); startMotor(LeftMotor, 63); wait(1); startMotor(RightMotor, 63); startMotor(LeftMotor, 63); wait(4); } #2. task main() { startMotor(RightMotor, 23); startMotor(LeftMotor, 63); wait(4); startMotor(RightMotor, -33); startMotor(LeftMotor, 63); wait(1); turnLEDon(yellow); wait(4); turnLEDoff(yellow); } 4. Describe and explain while loops in great detail. While loops are structures of code. They allow a section of code to be repeated as long as a certain condition remains true. There are three main sections to a while loop: the word while, the condition, and the commands to be repeated. Every while loop begins with the word while.

3.1.7 Machine Control: Apple Elevator


The condition is the thing that controls how many times or for how long a while loop repeats. When the condition is true, the while loop repeats; however, when it is false, it ends, and the rest of the program or code is put into effect. Each time a loop repeats (before the commands before the curly braces run), the condition is checked once. The commands will repeat as long as the condition is true.

Alejandro Martinez Name 3 analog and 3 digital sensors. Explain each in detail (how each works, what port they would plug in to, what the input/output would be, etc) 1. One analog sensor includes the potentiometer. The potentiometer works by measuring the rotation of a shaft between 0 and 265 degrees. The potentiometer can determine the position and direction. You would plug in the potentiometer into an analog port in the cortex. The input would be a range where you tell the code how many times you want to turn. A digital sensor it the quadrature shaft encoder. It is a digital counting sensor. It has a shaft that is inserted into the

3.1.7 Machine Control: Apple Elevator


shaft encoder that spins as the encoder counts. The Shaft Encoder has 360 counts per a revolution. It can count up or down which means a positive or negative value. With this digital sensor in particular you can control the distance at which a robot moves by telling the robot how many times the wheels spin. You would plug in this sensor into any digital port. A digital sensor is the ultrasonic sensor. How this sensor works is similar to how bats and submarines detect distance. The sensor detects distance like a cone. It doesnt detect distance like a circle that is extruded it detects distance like a cone. The sensor detects distance based on sound waves.You would plug this sensor into any digital port. An analog sensor is the line follower. How this works is that the sensor has an infrared light sensor and an infrared LED. It shines an infrared light at a surface and then the sensor picks up the reflected radiation which determines how much it reflects. The intensity plays a huge factor which is why light surfaces reflect more than dark surfaces. The analog sensor would plug into an analog port. The last analog sensor is the light sensor. The light sensor allows a robot to detect light. The sensor uses a photocell that is a photo resistor which means that the value changes based on the amount of light. You would plug this sensor into any analog port in the cortex. The last digital sensor is the bump switch. When you touch the button your value is 1 and when you are not pressing the button the value is 0. The port you would plug the sensor into would be any digital port. Describe the cortex in detail (the purpose, the ports, the connections, etc) 2. The cortex is called the VEX Cortex Microcontroller. The VEX Cortex has 12 digital ports for all of the digital sensors you use in your robot. The VEX Cortex has 8 analog ports for all of the analog sensors used in the robot. It has 10 motor ports, a VEXnet Connection, and has capabilities beyond the VEX kit we have in our classroom. For example, the VEX Cortex supports an external LCD screen and video. The purpose of the VEX Cortex is to be a command center. It controls the flow of information and power on the robot. It is the brain in the robot. There are three (3) types of behaviors. List and describe each. THEN, give 2 examples of actual code for each of the 3 behaviors. 3. There are three types of behaviors. Basic, simple, and complex. A behavior is anything a robot does. Basic behaviors are the size of single statements. The single statements include statements such as turning on a motor or turning on a servo. An example of a basic behavior is motor{port3} = 63; . Another example of a code is stopMotor(ElevMotor). Another type of behavior is a simple behavior. A simple behaviors are small that allow the robot to perform a simple but important task. These are the most important because they perform useful actions but they are small so that anyone can program the ROBOTC code. An example is motor{port3} = 63; (next line) motor{port2} = 63; (next line) wait1Msec(2000); . Another example of a simple behavior is the figure at right. Here you are telling the robot to stop the servo motors for a

3.1.7 Machine Control: Apple Elevator


millisecond. Our last type of behavior is the complex behavior. These behaviors are the most complicated behavior there is. However, this behavior is composed of simple behaviors and basic behaviors. Here is an example of a complex behavior. (Next page) You can see that in this code we have a variety of simple and basic codes. We have commands that tell the robot to start and stop motors.

3.1.7 Machine Control: Apple Elevator

Here is another example of a complex code. (Next page)

3.1.7 Machine Control: Apple Elevator

You can see that here you have a complex code that is composed of several other basic and simple behaviors. The code has commands that are basic such as turning on the right motor and half speed counter clockwise. These are the 3 types of behaviors. Describe/Explain while loops in great detail. 4. While loops allow a section or part of a code to be repeated as long as a specific condition it true. In a while loop there are three main parts to it. You need the word while, you need the condition, and lastly you need the command or commands that you want to be repeated. The condition in a while loop is in control of how long or how many times the while loop is repeated. For example, if the condition is correct the while loop will repeat but if the condition in invalid or false then the while loop stops and the rest of the code continues. Curly braces are extremely important in a while loop. The command or commands between the curly braces will repeat as long as the condition in correct or true. When handling while loops you have to consider boolean logic. The decisions you tell the code are based on questions. There are only two answers in the code yes or no. A decision breaker when deciding what statement to use is that a while loop is more flexible than an until statement.

John Mayen

3.1.7 Machine Control: Apple Elevator


1. Name 3 analog and 3 digital sensors. Explain each in detail (how each works, what port they would plug in to, what the input/output would be, etc) Three examples of digital sensors would be the bump switch, the limit switch, and the Ultrasonic Range Finder . The bump switch is basically a button that can be pushed. When the button is pushed, the output value will be 1 which will mean true. When the bump switch is not pushed, the output value will be 0 which will mean false since the button is not pushed. The purpose of the bump switch can be to activate other things like motors. You would plug in the bump switch into any of the analogs port. If you would want to turn it on the computer you would input a value of 1; if you would want to turn it off you would input a value of 0. A second example of a digital sensor would be the limit switch. The limit switch is similar to a bump switch but it has a long arm. The limit switch is typically used to make things go or stop when they reach appoint or limit. If the limit switch is not pressed, then the output value will be 0 which means false. If the limit witch is pressed, then the output value will be 1 which means true. This digital sensor would be plugged into a digital sensor input. . If you would want to turn it on the computer you would input a value of 1; if you would want to turn it off you would input a value of 0. A third example of a digital sensor is an Ultrasonic Range Finder. This sensor can detect the distance that something is away from it. It does this by using ultrasonic sound waves. An ultrasonic Range Finder detects the distance that an object is away from it in a cone-like way. It does not detect the distance of an object in a cylinder like way. The sonar can return a value between 0 and 255 inches. If not properly coded, the sonar may return a value of -1 or -2. You would plug in this sensor in any digital port you want in the digital ports section of the cortex. AN input for the sonar would be based on the distance that the object you are measuring is away from the sonar. Apart from digital sensors, there are also analog sensors which can have an output of any number greater depending on the sensor and it not only true or false (1 or 0) like a digital sensor. An example of an analog sensor could be a potentiometer. A potentiometer measures the rotation of a shaft between 0 and ~265 degrees but the cortex returns a value of 0- ~4095. This sensor is analog because the cortex returns a value anywhere between 0 and 4095 depending on what angle the shaft is. You would be able to plug this sensor into any of the analog sensor ports in the analog port sections. The input you could do to this sensor would be based on the degree of the axle. A second example of an analog sensor could be a light sensor. A light sensor can detect how

3.1.7 Machine Control: Apple Elevator


dark or light the room or object is. It does this by using a Cadmium Sulfoselenide photoconductive photocell that changes its resistance value based on the amount of light around it or hitting it. The light sensor can give a value anywhere between 0 and 255 (outputs). The input depends on how much light is in the room or is hitting the light sensor. You could plug in this sensor to any of the analog ports in the analog port sections. A third example of an analog sensor can be a line follower. A line follower is consisted of an infrared light and Led light. This sensor works by illuminating the surface with the infrared light. It then picks up the reflectivity of the surface and will pick up lighter colors than darker colors. The input will be based on the color of the surface since every color has a different reflectivity. The output will be a value in between 1volt and 5 volts. The scale is based on 5 being maximum illumination or reflectivity and 1 being minimum reflectivity or illumination. You would plug this sensor into any analog port you would like in the analog ports section. 2. Describe the cortex in detail (the purpose, the ports, the connections, etc) The cortex is a device where sensors and motors can be plugged in. The purpose of a cortex is to be the brains for the robot. You are able to export your code into the cortex for the robot to follow. The cortex itself has ports that are available for analog sensors, for digital sensors, and for motors. It also has a usb port so that you may plug it into the computer to load the code in and to connect a wireless controller. The cortex has a total of 12 digital ports, 8 analog inputs, and 10 motor ports. For our specific elevator, we connected the sonar to the digital sensors port, the 2 wire motors to the motors ports, and the bump and limit switches to the digital sensors. You are also able to plug in a battery to the cortex to power up the whole robot. To recap, the cortex is basically the brains for the robot where you can load the code om it, connect sensors and motors to is, and plug in the battery to power up the robot. 3. There are three (3) types of behaviors. List and describe each. THEN, give 2 examples of actual code for each of the 3 behaviors. There are 3 types of behaviors in coding on Robot C. The 3 types of behaviors are Basic Behaviors, Simple Behaviors, and Complex Behaviors. The first behavior is a Basic Behavior. A basic behavior is where there is a line of code and it is an extremely simple task that allows the robot to do single statement-like commands. An example of a Basic Behavior would be Turning on Motor Port 2 at full speed which would turn the motor at full speed forever until another line of code would stop it. Another example of a Basic Behavior would be a line of code that would say setServo(servomotor, 0) which would set the servo motor to be at its current angle. The second type of behavior is a Simple Behaviors. Simple Behaviors are still small behaviors that allow the robot to perform a task that is simple but this simple task is significant

3.1.7 Machine Control: Apple Elevator


and complex in its own way. This Simple behavior is the most commonly used because they are small enough for the program to understand, yet they are big enough that useful actions can be described. An example of a Simple Behavior would be a line of code that would say startMotor(RightMotor), 89); wait(5); stopMotor(RightMotor) because you are doing simple tasks that are complex in the result, but simple statements for the program to understand. This code will make the right motor run at a speed of 89 for 5 seconds. Another example of a Simple Behavior would be turnLedOn(green); wait(5); turnLedOff(green) this line of code would turn the LED light on, then turn the LED light off after 5 seconds of turning it on. This is yet another example of a simple behavioral code because the tasks or statements are short, but in its way the code is complex because it turns a light on and off after 5 seconds. The third type of behavior is a complex behavior. A Complex Behavior is a behavior where the code is made up of a bunch of little simple codes, but the simple little behaviors make up a bigger behavior that is complex as a whole. An example of a Complex Behavior in code would be startMotor(leftMotor, 63); startMotor(rightMotor, 63); untilEncoderCounts(480, quad); stopMotor(leftMotor); stopMotor(rightMotor). This would be an example of a Complex Behavior code because it is made up of smaller simple code lines but as a whole they come together to make a complex command for the robot. The command for the robot in this example would be that the motors have to turn until the encoder counts a value of 480, when it reaches 480 the motors will stop. Another example of a complex code would be untilBump(bumpSwitch); startMotor(rightMotor, 67); wait(5); stopMotor(tightMotor);. This is an example of a complex code because it is made of simple commands like stop motor or wait, but as a whole the code is complex. This code will start the right motor when the bump switch is bumped then after 5 seconds the motor will stop. 4.Describe/Explain while loops in great detail. While loops are conditional statements that can be used in a code to repeat the code as long as the statement after while is true. A better way to look at it could be of the structure: While A = True, do B. This example of the basic structure of a while loop is a good example because it is saying that while A or the first statement is true, then the robot will follow through with command B. If A is false, then B will not happen because the code will only work WHILE A is true. A real example of a while loop in Robot C programming could be something along the lines of whileSonarLessThan(20, sonar); startMotor(rightMotor, 35); startMotor(leftMotor, 35); turnLEDon(green). This code is a while loop code because it starts off with a while statement and is followed by what the robot should do if the while statement is true. This while statement says that while the sonar distance from the sonar to the object is less than 20 cm,

3.1.7 Machine Control: Apple Elevator


then the right, left, and LED light will all be turned on and the motors will be spinning at a speed of 35. If the distance between the sonar is greater than 20, then the motors nor the LED light will be turned on.

Malissa Rodriguez Name three analog and three digital sensors. Explain each in detail (how each works, what port they would plug into, what input/output would be, etc) 1.The three digital sensors include the light sensor, potentiometer, and line follower. Three analog sensors include bumper switch, limit switch, and lastly ultrasonic range finder. One digital sensor is the Bumper Switch. The bumper switch has a grey button, that when it is pressed, it makes the robot respond as it was programmed and expected to do. It does this by maintaining a high signal on its sensor port, which means the bumper switch is turned off when not pressed and turns on when pressed. While the bump switch is pressed, the signal changes to low, which tells the robot that the switch has been triggered on, the bumper switch remains turned on until the button is longer being pressed. The inputs and outputs of the bumper switch are 1 to 0. Another digital sensor is a potentiometer measures the rotation of a shaft between 0 and ~265 degrees. If only two terminals are used, one end and the wiper, it acts as a variable resistor or rheostat. A potentiometer measuring instrument is essentially a voltage divider used for measuring electric potential (voltage); the component is an implementation of the same principle. Describe the cortex in detail (the purpose, the ports, the connections, etc 2.The VEX Cortex Microcontroller is basically one of the main parts of the machine and has a huge role in controlling what the machine does. The cortex has twelve digital ports for the digital sensors and has eight analog ports for the analog sensors, and also has ten motor ports. The cortex is basically the center of the code and the actual machine and information. The purpose of the cortex is to deliver the information from the code to the ports, to help transfer information or a demand to the machine, to make it move and work, and also controlling each part of the machine. There are three types of behaviors. List and describe each. Then, give 2 examples of actual code for each of the three behaviors 3.There are three different types of behaviors. A behavior is basically what the robot is doing. The three types of behaviors are simple, basic, and complex. A simple behavior is a basic behavior with some sort of requirement for a sensor value or some other condition to begin. A

3.1.7 Machine Control: Apple Elevator


complex behavior is a series of simple behaviors in which all come together to complete a task. Lastly, a basic behavior is a behavior that tells a robot to simply do something without first requiring a sensor input. Describe and explain while loops in great detail. 4. While loop is a structure within robot, it allows a section of code to be repeated as long as a certain condition remains true. There is three main parts to every while loop: the word while, the condition, and commands to be repeated. Every while loop begins with the keyword while, the condition controls how long or how many times a while loop repeats. Condition is checked once every time loop repeats before commands between curly braces are run. Commands between curly braces will repeat while condition is true Program checks at the beginning of each pass through the loop. If there is no loop then the code will not be repeated.

3.1.7 Machine Control: Apple Elevator

Maleko Bravo 1. There are different kinds of sensors such as digital and analog sensors. For example, three different types of digital sensors are a bumper switch, limit switch, and optical shaft encoder. Another example of three different analog sensors are a light sensor, a line follower, and a potentiometer. In digital sensors, there are only two different values that you can get, either 1 or 0. 1 represents when it is true or on, for example when a bumper switch is being pressed, it gives out a 1 value. In contrast, 0 represents when it is not true or on, for example, when the bumper switch is not being pressed, it is not on. In analog sensors, the outputs range in different numbers compared to just having two outputs. For example, light sensors range from 0 to 4095. When you have a black object in front of a light sensor, you will get a number close to 4095 because it is sensing darkness compared to a huge amount of light. When you put a white object in front of the light sensor, you will get a lower value range closer to 0 because it is sensing more light compared to the black object. First for digital sensors, I will explain a bumper switch. As explained before, digital sensors can only have two different outputs of either 1 or 0. When it is 1, that means that it is giving out a value of a true statement meaning that the bumper switch is being pressed. The other output that a bumper switch can get is a 0. In a 0, that means that it is giving out a value of false or off statements meaning that the bumper switch is not being pressed. This rule is the same for a limit switch. Digital sensors can only have two different outputs of either 1 or 0. When it is 1, that means that it is giving out a value of a true statement meaning that the limit switch is being pressed. The other output that a bumper switch can get is a 0. In a 0, that means that it is giving out a value of false or off statements meaning that the bumper switch is not being pressed. The last example of a digital sensor is optical shaft encoder. An optical shaft encoder can measure both the position and direction of rotation of a VEX shaft. This allows you to calculate the speed of the shaft, as well as the distance it has traveled, which can be very useful measurements for autonomous programming. It works by shining light onto the edge of a disk outfitted with evenly spaced slits around the circumference. As the disk spins, light passes through the slits and is blocked by the opaque spaces between the slits. The encoder then detects how many slits have had light shine through, and in which direction the disk is spinning.An optical shaft encoder is a digital sensor because it counts 360 times to create a revolution. It counts either up or down meaning that it can be a positive (up) or negative value (down). Then, I will explain the analog sensors. I will first start with a light sensor. As I said previously, you get a

3.1.7 Machine Control: Apple Elevator


range of numbers when it is analog compared to just having just two values. Light sensors can range from 0 to 4095. Light sensors enables the robot to detect different wavelengths of light such as dark and light. When you are looking at a darker object, you will get a higher ranged number depending how dark it is. If you have a lighter object, you will get a lower ranged number depending how light it is. Line followers also kind of follow the same traits of a light sensor. A line follower is an infrared light sensors and an infrared LED light. The LED lights up, then the sensor senses the LED that is reflected by the on the surface. Lighter surfaces will reflect more compared to dark surface, meaning that the lighter surfaces are brighter for the sensor. With the amount of light that is being reflected back, it can tell either if it is on a light surface or a dark surface. A line followers value can range from 0 to 225. The lower the number, the brighter the reflection from the surface. The higher the number, the darker the from the surface is. Lastly, is a potentiometer. A potentiometer is a device that can have a adjustable resistance. It measures the rotation of the of the shaft in ranges from 0 to 265. It can determine the position and direction of the shaft. The ranges control the angle of the shaft, meaning that the value you program would be close to the angle that you want the shaft to be. 2. The cortex is basically the brain of the robot. I say that the cortex is practically the brain because it stores the code inside, which controls the robot. It also connects all of the different outputs of the sensors in one place so that we could utilize them. It connects all of the sensor outputs so that it could allow the robot to run on a closed loop. On the cortex, there are only three different areas where you can plug in your output for your sensor, either analog inputs, digital input/outputs, or motor outputs. When trying to plug in the outputs into the cortex, it is self-explanatory. you plug in the analog inputs of the sensors into the area of the cortex with analog inputs, which has 8 slots to put it into. When trying to plug in outputs/ inputs of a digital sensor, you plug it in into the area of the cortex digital input/outputs, which has 12 slots to put into. When trying to plug in outputs of the motors, you plug it into the area of the cortex motor outputs, which has 10 slots to put into. When plugging these in, you have to connect a motor controller to the motor itself and then plug in the output of the motor controller into the cortex. 3. There are three different types of behaviors: basic, simple, and complex. Basic behaviors are the smallest parts of the robot code, meaning that they are the basic blocks that make up the code. Which means that these programs are easily understood from the robot so that it can understand it easier and perform directly. These are single statements on ROBOTC, like turning on a single motor or timing. A simple behavior is a little more

3.1.7 Machine Control: Apple Elevator


complicated than the basic. These are small behaviors that perform a simple, but big task that the robot has to do for a certain amount of time. These programs are very important in the code and robot, but very easy to program, for example moving forward for 3 seconds. Complex behaviors are the most advanced and the hardest out of the three. This behavior is practically the behavior that would be used to navigate through a maze. Complex behaviors are hard to understand, but can be broken down into simpler behaviors. Two examples of a basic behavior is: startMotor{port2} = -127 or startMotor{port3} = 67. Two examples of a simple behavior is: startMotor{port2} = 127; wait1Msec(15); stopMotor{port2}; or startMotor{port3} = 67; wait1Msec(5); stopMotor{port3}; Two examples of complex behaviors is out code that we create for the project and this:

4. Robot programmers commonly use while loops because it allows a certain part of the code to repeat itself until the statement is false. While loops are when the code function is true, it repeats itself until the function turns false. When making this on ROBOTC, you need the while with the statement that you want either being true or false and the semi colons. Semi colons are one of the most important parts of a code because that ends the simple behavior of the code. The while loop controls how long and how many times that the code can be repeated. For example, the code will not repeat if it is invalid, but it will

3.1.7 Machine Control: Apple Elevator


repeat if it is valid. Curly braces are also important because it controls the commands to see if they repeat depending if they are true or not. Everything in the code is questioning either if it is true or false making it repeat or not to repeat, meaning the only options are yes or no.

John Ong 1.) One digital sensor that we use is the bump switch. In our elevator we use it as a call button. What this switch does is it gives us 0 or 1 output values which tells the computer when it is pressed. It plugs into the digital slot on the cortex. When pressed it activates the program that lifts the platform to that switchs corresponding floor. Another digital sensor is the limit switch. This switch works very similar to the bump switch. It gives an output of 0 or 1 or yes or no outputs. These outputs tell the computer whether the switch has been activated or not.

3.1.7 Machine Control: Apple Elevator


Another digital sensor is the optical shaft encoder. The optical shaft encoder works by counting up and down on how many times the axle spins. You can use this to tell the encoder to spin the axle a certain amount of times. An analog sensor is the potentiometer. The potentiometer measures the rotation of the shaft between the output values of 0 and 265 degrees. The internal mechanical stops prevent the potentiometer from turning a full rotation. This would plug into the analog slots of the cortex. This helps determine position and direction. Another analog sensor is the line follower. The line follower sensor consists of an infrared light sensor and an infrared LED. The infrared LED shines infrared light which then is reflected off the surface and detected by the sensor. This helps determine how reflective a surface is. Lighter surfaces will reflect more light than darker colored surfaces. The third analog sensor is the light sensor. The way a light sensor works is it has a photoreceptor in it that is similar to the film within in old camera which allows it to capture and sense light coming in. 2.) The Vex Cortex is essentially the brain of your robot. It has 12 digital ports and 8 analog ports for your digital and analog sensors. It also has 10 motor ports. What the Vex cortex does for the robot is it powers and commands it. The way it gets the programming is through a USB connection. From here it uses that to control the sensors and motors that are plugged into. 3.) There are three different types of behaviors for a robot. The three types are: basic, simple, and complex. Basic behaviors have codes that are really short. They are the simple things like telling a motor to turn on. Two examples of code are: { startMotor( rightMotor, 67); } And: {

StopMotor(Rightmotor); } The next type of behavior is simple behavior. Simple behaviors allow the robot to do simple tasks. These simple tasks can then be used in more complex codes to complete even more complicated tasks. Examples of simple behavior code would be:

3.1.7 Machine Control: Apple Elevator


{ startMotor (rightMotor, 67); wait(5); stopMotor(rightMotor); } And: { turnLEDon(green); wait(10); turnLEDoff(green); }

The third type of behavior is complex. Complex behavior is a longer more complicated code that is made up of various combinations of simple and basic behaviors. These behaviors also include while loops and if and else commands. Here are some examples: As you can see in this complex code that is using a while loop, the program consists of simple behaviors like setting the motor to a certain speed when true.

3.1.7 Machine Control: Apple Elevator

This is another example of complex code. It is just a single behavior made up of shorter simple behaviors. The simple behaviors would be setting the motors to turn on at different speeds. Although as we can see in the pseudo code that the whole behavior is the robot going straight ahead, turning left and then stopping which is a lot more complex of a behavior that the simple behaviors that make it up. 4.) What a while loop is, is a program that is run continuously over and over if a specific condition is met. The way code works is it is read top to bottom until the end of the program. The while command will be placed before the behavior so that the computer reads while first and knows that if the condition is met it then goes on to read the code below it. What a while loop does is that once a predetermined condition is met or the condition is true, it repeats the code that is in the curly brackets under the while command. Depending on how long the condition is true will determine how long the program within the while loop will be repeated. Once that condition is no longer true then the computer will stop repeating the while loop and continue on reading down the rest of the program.

3.1.7 Machine Control: Apple Elevator

Вам также может понравиться