ROBOTC for CORTEX Teacher Training © 2011 Project Lead The Way, Inc. Automation and Robotics VEX.

Slides:



Advertisements
Similar presentations
While Loops and If-Else Structures
Advertisements

Engineering Roles We will be forming groups of 3 students
Automation and Robotics
VEX and Robot C Chris Patterson Presented by Modified by J. Andazola.
Photos and Sensor Instructions
ROBOTC for CORTEX Teacher Training
Connecting VEX and ROBOTC
Testbed: Exercises.
VEX Robotics Platform and ROBOTC Software
Program ultrasonic range sensor in autonomous mode
Programming Concepts (Part B) ENGR 10 Introduction to Engineering 1 Hsu/Youssefi.
Programming Design ROBOTC Software Principles of Engineering
AUTOMATION WITH ROBOTC Starting to write and troubleshoot computer code.
Photos and Sensor Instructions
ROBOTC for CORTEX.
ROBOTC for CORTEX Teacher Training
While and If-Else Loops ROBOTC Software. While Loops While loop is a structure within ROBOTC Allows a section of code to be repeated as long as a certain.
ROBOTC for CORTEX Teacher Training – Not for students – Replace with studentds power point © 2011 Project Lead The Way, Inc.Automation and Robotics VEX.
VEX and Robot C Chris Patterson Frisco ISD CTE Center Presented by.
Automation and Robotics.  First you select the platform type so that you can use Natural Language PLTW.
ROBOTC for CORTEX Teacher Training. ROBOTC Overview Thinking about Programming.
Casne.ncl.ac.uk Taking care of the CrumbleBot Please do NOT stress the robot's motors 1.Do NOT push the robot 2.Do NOT hold the.
ROBOTC for Testbed © 2011 Project Lead The Way, Inc.Automation and Robotics VEX.
ROBOTC for CORTEX Teacher Training © 2011 Project Lead The Way, Inc.Automation and Robotics VEX.
Connect VEX and ROBOTC Electrical Engineer Responsibilities © 2011 Project Lead The Way, Inc.Automation and Robotics VEX.
ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?
Programming Design ROBOTC Software. Behavior-Based Programming A behavior is anything your robot does –Turning on a single motor or servo Three main types.
Basic Programming: Until Commands. The Problem with Wait States Motor Speed is affected by battery power. –If the battery is fully charged, the motors.
Robotics Programming Wall Follow Line tracking for a set amount of time Line tracking for a distance.
After Construction Name: Per #:.
Programming Design ROBOTC Software Principles Of Engineering
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
ROBOTC for VEX Online Professional Development
ROBOTC for VEX Online Professional Development
ROBOTC for VEX On-Site Professional Development
Robotics Programming Using Shaft Encoders
ROBOTC for VEX Online Professional Development
Informational Meeting
Electrical Engineer Responsibilities
Automation and Robotics
Programming Design ROBOTC Software Computer Integrated Manufacturing
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
ROBOTC for CORTEX Teacher Training
RobotC Sensors.
Movement using Shaft Encoders
RobotC Sensors.
Automation and Robotics
ROBOTC for CORTEX Teacher Training
TECH 1 BAMS Technology Education
While Loops and If-Else Structures
An Introduction to VEX IQ Programming with Modkit
While Loops and If-Else Structures
Programming Design ROBOTC Software Principles Of Engineering
While Loops and If-Else Structures
While Loops and If-Else Structures
While Loops and If-Else Structures
if-else Structures Principles of Engineering
Automation with RobotC
Robotics Programming Using Shaft Encoders
Photos and Sensor Instructions
Robotics Programming Using Shaft Encoders
ROBOTC for CORTEX Teacher Training
While Loops and If-Else Structures
Automation with RobotC
Robotics Programming Using Shaft Encoders
While Loops and If-Else Structures
Programming Design ROBOTC Software Principles of Engineering
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
While Loops And If-Else Structures
Presentation transcript:

ROBOTC for CORTEX Teacher Training © 2011 Project Lead The Way, Inc. Automation and Robotics VEX

 VEX ® Cortex ® (VEX 2.0)  12 digital ports  Touch Sensor, Ultrasonic Rangefinder, Shaft Encoders  8 analog inputs  Light Sensors, Line Tracking Sensors, Potentiometers, Accelerometers, Gyroscope  10 motor ports  8 standard 3-wire PWM  2 new 2-wire motor ports  Built-In VEXnet Connection  Enables Wireless Programming, Wireless Debugging, and Remote Control  Two UART Ports (Serial)  LCD Screen, Other External Devices  One I2C port  Will connect to multiple new smart sensors

While connected to USB To be used without USB

1. Connect the Cortex to your computer using the USB A-to-A cable. 2. Connect the Cortex to a charged robot battery. 3. Turn the Cortex ON.

Note: Digital Sensors can be configured as both inputs (touch sensors) and outputs (LEDs).

 Turn on the right motor and run it for 5 seconds at half speed (63) then turn it off.

 You can make motors go in reverse by going to Robot; Motors and Sensors Set Up; then selecting reverse for one motor.  Or you can simply type the speed as a negative number…

 Turn on the right motor and run it forward for 5 seconds at ½ speed (63) then turn it off.  Turn on the left motor and run it in reverse at ¾ speed (94.5) for 2.5 seconds.  Turn on both motors and run at full power (126), in the same direction, for 7.25 seconds then turn them off.

 Use an UntilTouch for the bump switch to turn on the right motor forward at ½ speed and the LED on  Then add an UntilTouch for the limit switch to turn off the motor and LED

 You can add an UntilTouch to make the testbed wait to start until you press the bump switch.  UntilBump will do this too, but not UntilButtonPress  You can also add an UntilTouch to make the testbed run until you press the limit switch

 Turn on the green LED until the potentiometer value is greater than Then the green LED should turn off, and the left Motor should turn on until the potentiometer is less than 2048.

 Use UntilPotentiometerGreaterThan to set the positive value you want  Use UntilPotentiometerLessThan to set the negative value you want

 “Active” Analog Light Sensor  Sends out a IR beam, and measure how much light is reflected back  Each reads values between 0 and 4095  Usually mounted as a set of 3 ¼ to 1/8 inches off what it is measuring  You have to calculate a threshold that allows it to distinguish light from dark.

 A threshold is a value (usually halfway) between two extremes (light/dark)  Open Sensor Debug Window – make sure that the refresh rate is set to Once  Place a white surface above the line tracker and record the value displayed in the window.

 Open and close the claw (run a motor clockwise or counter clockwise) by covering and uncovering the line follower.

Notice: I put this in a while loop (you will learn it later) to make it repeat continuously

 A while loop is a structure that allows a section of code to be repeated over and over again.  While loops are set up with a “condition” this is like saying “while this is true…” the robot will check the condition every time the code loops  The easiest While Condition is 1==1

 Put the while loop after the task main() command  Make sure you make an { after the while then a } at the end  Two opens = two closes

 Use a continuous while loop (1==1) to  UntilTouch for the bump switch to turn on the right motor forward at ½ speed and the LED on  Then an UntilTouch for the limit switch to turn off the motor and LED

 When the robot reaches an IF statement in the program, it evaluates the “condition” contained between the ()  If the “condition is true, any commands between the braces are run  If the “condition” is false, those same commands are ignored  Similar to a While loop, but the code does NOT repeat.

 This is an expansion of the IF statement.  The IF section still runs the commands inside the ()  The ELSE allows for specific code to run only when the condition is false  IF or ELSE is always run…

 Add an IF statement to turn of the LED if the bump switch is pressed and leave it off if it’s released. Loop it forever (While…)  Now try converting the IF to an IF-ELSE statement that runs the right motor if the bump is pressed, Else the light is on and no motor runs…

 Be careful when using two separate if-else statements, particularly when they are used to control the same mechanism.  One branch of each if-else statement is always run, so you may create a scenario where the two sets “fight” each other.

 In this example, if one of the touch sensors is pressed, the rightMotor will be turned on in one if-else statement, and immediately turned off in the other.

 This can be corrected by embedding the second if-else within the else branch of the first, so that it only runs if the first condition is false.

 An embedded if-else can also be represented as an else if:

 Use this information to write a multiple If-Else statement.

 There are many times when several steps may be repeated in a program. These steps can be grouped together as a function that can be named before task main.  During task main the function(void) can be used simply by typing the name of that function in task main.

 Program a robot to follow a path like the one below…  The path is made up of right turns, left turns and straight paths.  We can create functions for each turn and the straight path using the following structure.

Write a program that makes the wheels on your test bed follow the path below.