Testbed: Exercises.

Slides:



Advertisements
Similar presentations
ROBOTC for CORTEX While Loops Part 1
Advertisements

While Loops and If-Else Structures
Automation and Robotics
VEX and Robot C Chris Patterson Presented by Modified by J. Andazola.
Photos and Sensor Instructions
Autonomy using Encoders Intro to Robotics. Goal Our new task is to navigate a labyrinth. But this time we will NOT use motor commands in conjunction with.
ROBOTC for CORTEX Teacher Training
RobotC For Beginners Tyler Lutz and Keaton Bonds DRSS Enterprise.
ROBOTC for VEX Online Professional Development
ROBOTC Software Introduction. ROBOTC Software ROBOTC developed specifically for classrooms and competitions Complete programming solution for VEX Cortex.
Programming 101 The Common Palette Content provided by Connor Statham (6 th Grade Student) Formatting by Shannon Sieber.
LabVIEW Program and Data Flow Review LabVIEW Robotics Fundamentals.
ROBOTC for VEX On-Site Professional Development
Programming Design ROBOTC Software Principles of Engineering
Robot C and Natural Language
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.
Programming 101 The Common Palette Content provided by Connor Statham (9 th Grade Student) Formatting by Shannon Sieber.
Programming - Motion Intro to Robotics. Motors and Sensors Setup The first thing we need to do is tell ROBOTC that we have motors on our robot. Choose.
ROBOTC for CORTEX Teacher Training – Not for students – Replace with studentds power point © 2011 Project Lead The Way, Inc.Automation and Robotics VEX.
ROBOTC Software EV3 Robot Workshop Lawrence Technological University.
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.
Vex Robotics program three: using motors and sensors together.
ROBOTC for CORTEX Teacher Training. ROBOTC Overview Thinking about Programming.
ROBOTC for Testbed © 2011 Project Lead The Way, Inc.Automation and Robotics VEX.
Testbed Coding In this activity you will code different challenges for the Testbed. For each challenge a sample program is shown. Use what this sample.
Robot C and Natural Language. Create a folder Create a folder on your desktop to insert all your Robot C files, Here you will begin with your template.
ROBOTC for CORTEX Teacher Training © 2011 Project Lead The Way, Inc.Automation and Robotics VEX.
ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?
Testbed Coding In this activity you will code different challenges for the Testbed. For each challenge a sample program is shown. Use what this sample.
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.
Decision Making: while loops and Boolean Logic. While Loops A while loop is a structure within ROBOTC which allows a section of code to be repeated as.
Sensor Information: while loops and Boolean Logic.
ROBOTC for CORTEX Teacher Training © 2011 Project Lead The Way, Inc. Automation and Robotics VEX.
Programming Design ROBOTC Software Principles Of Engineering
ROBOTC for VEX Online Professional Development
Introduction to Programming
ROBOTC for VEX Online Professional Development
ROBOTC for VEX On-Site Professional Development
Robotics Programming Using Shaft Encoders
ROBOTC for VEX Online Professional Development
Automation and Robotics
Programming Design ROBOTC Software Computer Integrated Manufacturing
Movement using Shaft Encoders
Automation and Robotics
TECH 1 BAMS Technology Education
While Loops and If-Else Structures
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
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
While Loops And If-Else Structures
Presentation transcript:

Testbed: Exercises

Be Mindful / Not Random! (be a thinker not a tinker) There are a lot of variables when it comes to programming [ variables hinder troubleshooting ] If you are not mindful of what you do or don’t do, I cannot systematically help you eliminate variables. [ IDK, I think so = frustration for you ] If we can not limit the variables, I cannot help you solve your problem in a timely manner If I cannot solve your problem in a timely manner, I will need to move on to the next group

Safety Keep long hair clear of your testbed, especially your gears! No plugging or unplugging of anything with the power on! – Turn-off the Cortex 1st!! You could get shocked and have to pay for anything you damage (intentional or not)

Check your Cortex - Properly inserted plugs? Parallel to top and bottom edges White wire towards the middle

Are you ready to program your testbed? If you followed your packet, your software should be set-up, now check your hardware: Hardware Checklist: properly inserted plugs into the cortex (white wire to the middle as shown on the last slide) two motors with motor controllers plugged into motor ports 2 & 3 (red to red & black to black as shown on the next slide) limit switch & bump switch in digital ports 1 & 2

Connecting the Motors Two-wire motors can be plugged directly into MOTOR ports 1 & 10 on the Cortex, and 2-9 using the Motor Controller 29 – red to red, black to black

FYI - VEX Motors 2 Types (labeled on motor): 2-wire motor 269 Newer 2-wire motor 393 Review All motors have the same values between 127 (full forward) and -127 (full reverse)

Practice Exercise Copy the code on the next slide into your RobotC file Trainer Notes: This slide is meant to be a class activity, for trainees to actually get some guided experience with the ROBOTC interface, ROBOTC Commands, Cortex system, ect. The steps should be: Open ROBOTC Verify the Platform Type is set to Cortex Natural Language Lilbary Create the Program Connect the Cortex to the Computer (via USB or VEXnet) Turn on the Cortex Go to Robot > Compile and Download Program Run the program – Observe the testbed Turn on Motor Port 3 in the program, after Motor Port 2 and before the wait command Compile and Download the Program Run the Program – observe the testbed Talk about the testbed design, how the motors are mirrored images of one another – even though you gave them the same motor power, they turn in opposite direction. This is something common on actual robots, where they mirror one another. In ROBOTC, us the Motors and Sensors Setup to reverse the appropriate Optional – rename the motors in the Motors and Sensors Setup Download and run the program – observe the motors spinning in the same direction.

Practice - Motor for 5 Seconds

Running a Program Choose Robot, compile and download, and start

How it works The next series of slides explain what is happening

Motor for 5 Seconds PRAGMA – generates from motors & sensors setup Displays configuration changes from the Motors and Sensors Setup Defines the “main task” of the robot All commands belonging to task main must be in-between these curly braces

Motor for 5 Seconds Turns the port2 rightMotor on at half power forward

Motor for 5 Seconds Causes the robot to wait here in the program for 5.0 seconds

Motor for 5 Seconds End Result: rightMotor spins for 5.0 seconds. Stops the port2 rightMotor. End Result: rightMotor spins for 5.0 seconds.

Modify the code from the practice activity so it works for the 1st programing exercise on the next slide.

Motor Exercises [1 of 6] Turn the rightMotor on forward at half speed for 5 seconds, then stop. Turn the leftMotor on in reverse at three-fourths speed for 2.5 seconds, then stop. Turn both motors on at full power, and spinning in the same direction, for 7.25 seconds, then stop. Trainer Notes: Recommend that trainees name their finished programs by the title of the slide, including the number and whether it was a group or individual activity. This will help them refer back to the code later. Teacher initial ____________

Basic Programming: Until Commands

Touch Sensors Touch Sensor Check How they work Two Types Plugged into Digital 1 & 2 How they work Digital sensor - Pressed or Released 1 = pressed 0 = released Two Types Limit Switches Bumper Switches A very brief wait can be inserted after touch sensor related commands to reduce the bouncing effect: ( bumpSwitch ) ;

Use a combination of the practice code from earlier and the bumpswitch code on the last slide to complete the programing exercise on the next slide

Bump Switch Exercise [2 of 6] Exercise: Program the rightMotor to turn on at half power, until the bump switch is pressed. The motor should then stop.

Use your limit switch to complete the exercise on the next slide Instead of bumping the bumpSwitch, your are bumping the limitSwitch

Limit Switch Exercise [3 of 6] Wait for the limit switch to be touched before the right motor turns on at half power for 5 seconds, then stops. Wait for the limit switch to be touched before both motors turn on at half power, until the sensor is bumped again. Both motors should then move in reverse at half power for 3.5 seconds. Discuss how the limit and bump switch would be used for Grandmas Chair, Toll booth, Sign, Tekrocks Bridge

VEX LED Plugged into DIGITAL Port 12 (with an extension see next slide) Set as “VEX LED” Red, Green, and Yellow colors available

VEX LED Connect the LED to the PWM Extension wire. Turn-off the cortex! – no plugging or unplugging of anything with the power on! The outer terminal on the LED should be plugged in on the white wire. The center terminal on the LED should be plugged in on the red wire. The black wire should have nothing connected.

Decision Making: While Loops and Boolean Logic

While Loops A while loop is a structure within ROBOTC which allows a section of code to be repeated as long as a certain condition remains true. There are three main parts to every while loop.

1. The word “while” Every while loop begins with the keyword “while”.

2. The Condition The condition controls how long or how many times a while loop repeats. While the condition is true, the while loop repeats; when the condition is false, the while loop ends and the robot moves on in the program. The condition is checked every time the loop repeats, before the commands between the curly braces are run.

3. Commands to be Repeated Commands placed between the curly braces will repeat while the (condition) is true when the program checks at the beginning of each pass through the loop.

The Truth About while() Loops

1. while() Loops do NOT Constantly Check their Conditions while() loops check their conditions before running the body of code After the body of code is run, the while() loop checks the condition again The condition is NOT checked while the body of code is being run

2. while() Loops do NOT Keep Programs Running Forever Exception: Infinite while() loops example “while (1 == 1)” or “while (true)” Once the while() loop’s condition is met/false, the robot moves past the while loop in the program and does not revisit it Students often assume that because there is a while() loop in the code, the program keeps on running

3. while() Loops are a Programming Structure, not a Command They do not get a semicolon (;) after the condition Adding a semicolon will cause the while() loop to constantly check the condition, without running the body of code

4. All “until” commands in the NL are actually while() loops All “until” commands are just a while() loop with a wait command, to hold the “Program Flow” at that spot in the code

Modify the code on the previous slides to complete the exercise on the next slide

While Loop Exercise 1 [4 of 6] Example: Program the greenLED to repeatedly turn on for 2 seconds, then off for 2 seconds, while the limit switch isn’t pressed. So pressing the limit switch will stop the led from flashing Trainer Notes: Recommend that trainees name their finished programs by the title of the slide, including the number and whether it was a group or individual activity. This will help them refer back to the code later.

Timers More loop control please? Solution: Timers Question: Where would the wait statement go if we wanted the loop to repeat for a controlled amount of time? Answer: Nowhere! We need something else. Solution: Timers Can be thought of as internal stopwatches (4 available) Timers should be “cleared” anytime before they are used Watch where you clear them!

Timers In the program below, timer T1 is used as the condition for the while loop, which will run for 30 seconds: [bumpSwitch] == 1)

While Loop Exercise 2 [5 of 6] Program the greenLED to repeatedly turn on for 0.5 seconds, then off for 0.5 seconds, while less than 5 seconds have elapsed. Trainer Notes: Recommend that trainees name their finished programs by the title of the slide, including the number and whether it was a group or individual activity. This will help them refer back to the code later.

If Statements When your robot reaches an if Statement in the program, it evaluates the condition contained between the parenthesis. If the condition is true, any commands between the braces are run. If the condition is false, those same commands are ignored. Very similar to how a while loop works, but does not repeat the code!

If-else statements The if-else Statement is an expansion of the basic if Statement. The “if” section still checks the condition and runs the appropriate commands when it evaluates to true Using the “else” allows for specific code to be run only when the condition is false. Either the “if” or the “else” branch is always run; no more, no less.

If-else if Exercise 1 [6 of 6] Program the greenLED to turn on if the bumpswitch is pressed, and off if it’s released. Loop Forever. .