1 / 125

VEX/ROBOTC Session 1

VEX/ROBOTC Session 1. Agenda. Introductions to VEX and ROBOTC . Basic Programming- Inputs and Outputs Basic Outputs Programming Basic Input Programming Basic Programming While and If statements Variable and Functions Basic Programming Open and Closed Loop Systems. Getting Started.

prem
Download Presentation

VEX/ROBOTC Session 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. VEX/ROBOTC Session 1

  2. Agenda • Introductions to VEX and ROBOTC. • Basic Programming- • Inputs and Outputs • Basic Outputs Programming • Basic Input Programming • Basic Programming • While and If statements • Variable and Functions • Basic Programming • Open and Closed Loop Systems

  3. Getting Started • There are three main sections to the ROBOTC Integrated Development Environment (IDE): • The Editor • The Code Templates / Function Library • The Main Menu / Toolbar

  4. The Editor • This is the part of the interface where the user can write code.

  5. The Code Templates / Function Library • This portion of the interface allows user to see all the functions available in ROBOTC at their user level. • Portions of code from the "Function Library" can be dragged into the Editor.

  6. The Main Menu / Toolbar • This area allows you to perform basic tasks (saving, copy & pasting, undo, etc.), switch between multiple open programs using the tabbed interface, and access all of ROBOTC's additional functionality through the various menus.

  7. Parts are more than just parts The poe test bed

  8. The POE Test Bed

  9. VEX Components • The Cortex • STMicroelectronics ARM Cortex-M3 user processor • Wireless with built-in VEXnet technology • (8) Standard 3-wire Motor ports • (2) 2-wire Motor ports • (1) I2C "smart sensor" port • (2) UART Serial Ports • (8) Hi-res (12-bit) Analog Inputs • (12) Fast digital I/O ports which can be used as interrupts

  10. The Bump Switch • The Bumper switch works as a trigger that provides feedback to the Microcontroller as events "happen". • Rugged bumpers allows triggering by large impacts. • Useful as a trigger in a variety of applications. • Functionality is pre-programmed in the VEX Microcontroller.

  11. The Limit Switch • These switches are great for signaling when a robot arm has reached the top or bottom of its motion. • Bendable sheet metal switch "arm" is very versatile • Useful as a trigger in a variety of applications • Functionality is pre-programmed in the VEX Microcontroller

  12. The Line Tracker • Program your robot to follow a black line over a white surface. • Navigate down a marked path. • Use for light sensing. • More autonomous function.

  13. The Potentiometer • With the Potentiometer you can determine both position and direction of rotation. • Measure Angular Position. • 250-Degrees of Adjustment. • Adjustable mounting angle.

  14. The Optical Shaft Encoder • With the Quadrature Encoder's two output channels you can measure both the position and direction of rotation of a VEX shaft. • Calculate Shaft Speed. • Calculate Distance Traveled. • Increase Navigational Control.

  15. Ultrasonic Range Finder • Avoid obstacles and measure distances with the ultrasonic range finder. Device emits a high-frequency sound wave that alerts the robot to things in its path.

  16. The Light Sensor • The light sensor uses a photocell that allows your robot to detect and react to light. • Analog input of light levels. • Usable range of 0 to 6 feet. • Find dark or bright areas.

  17. The Two Wire Motor • The motor connects directly to 2-Wire Motor Ports (Ports 1 & 10 on the Cortex Microcontroller). • For 3-Wire Motor Ports (Ports 2-9 on the Cortex), a Motor Controller must be used in between the Microcontroller and the motor.

  18. Three Wire Servo Motor • Servo motors are a type of motor that can be directed to turn to face a specific direction, rather than just spin forward or backward. • Expand functionality • Add pan and tilt to a camera • 100 degrees of rotation • Do exact positioning

  19. Other Parts Green LED Flashlight Motor Controller Battery

  20. Getting Started… Opening the pltw template

  21. Open the PLTW Template Notice the File Path – If you are not in the VEX2 Folder take this time to find it. Select the PLTWtemplate

  22. The PLTW Template • Once the Template is Opened – Have the students SAVE AS the name of the assignment that they are working on. • For this example save as A3_1_1

  23. Setting the Platform and Communications method: • Select View • Preferences • Detailed Preference…

  24. ROBOTC Preferences • Select the Platform Type so that it shows Natural Language (VEX Cortex) • Leave the Communication as Automatic Selection NOTE – Get your students in the habit of checking this every time they start a new project

  25. Put your Name on your Assignments • Project Title: INPUTS AND OUTPUTS 3.1.1 • Team Members: ROY ROSNIK • Date: SEPT 1 2012 • Section: 1

  26. Setting up the Motors and Sensors • For this Project ROBOTC has pre-programmed some Standard Model Configurations

  27. Motor and Sensors Setup • Select the Motors Tab • Notice that each item has a name • When naming the motor • Use a descriptive name • Good time to check to see if the motor is actually in the correct port on the VEX Cortex

  28. Motor and Sensors Setup • VEX 2.0 Analog Sensors • Naming the sensor • Use descriptive names • Like before, have the students check the wiring

  29. Motor and Sensors Setup • VEX 2.0 Digital Sensors • Naming the sensor • Use descriptive names • Like before, have the students check the wiring

  30. Time to Compile and Download… • Select Robot • Compile and Download Program

  31. Three most commons Messages The VEX Cortex is not plugged into the computer The wrong Compiler Target is selected Power is turned off or the battery needs to be replaced

  32. Program Debug • This is used to check to see if all of the Inputs, Outputs and motors are working correctly. • Make sure that the Refresh is set to Continuous

  33. Debugger Windows • From the Menu • Robot • Debugger Windows • Motors and Sensors

  34. The Debugger Window • Bottom of your screen • Tabs for each item • Errors – gives you an idea what is wrong with the code • Motors – lets you test each motor • Power can be manually changed from -127 to 127 • Try different values for each item • Sensors • Both Analog and Digital are displayed • Items in red will automatically change their value • Items in Black will change to red when input is given • Try each Sensor

  35. Check your Understanding • How are motors and sensors used. • Describe a scenario where a motor or sensor might not respond as you would predict. • What is the purpose of the ROBOTC Editor Window? • What is the purpose of the ROBOTC Debug window? • What it the purpose of the FUNCTION LIBRARY? • What is the function of the Menu Bar?

  36. Basic Outputs Programming – VEX • Close all previously opened Programs • Open a new copy of the PLTW Template • SAVE AS A3_1_2_PART1 • Edit – • Project Title: • Team Members: • Date: • Section: • Task Description:

  37. Set up the Motors and Sensors Set the Motors so that only Ports 2,3 and 9 are used. Set Digital Sensors so that only digl 12 is being used

  38. The Color of the Code • Normal Text is displayed as black text. • Normal text is used for variable and function names that are user-defined and not recognized by the compiler as reserved words. • Comments are displayed as green text.  • Comments are text in a program prefaced with a// or surrounded by a /* * / . • This "commented text" is not considered code and is ignored when the compiler generates byte-code to send to the robot controller. • Reserved Words/Pre-Defined Functions (int, motor) are displayed asblue text. • These are words that are 'reserved' by ROBOTC and have special meaning; because of this, they cannot be used as names for variables, functions, etc. • Constants and Parameters (50, motor1) are displayed as dark red text. • Operators (+, -, *, {, <, [, etc.) are displayed as light red text .

  39. Comments • Project title, Team Members, Date and Section • Task Description – Overview of the program • Pseudocode – Detailed step-by-step account of the program. • All Comments are in GREEN

  40. #pragma – not a dirty word • When you set up the motors and sensors, you gave each one a port and name. • RobotC gave it more information • When entering commands, the programmer will indicate what is to operate by port or the name you gave it.

  41. The Actual Code The Program starts with task main() task main() { turnLEDOff(green); wait (1); turnLEDOn(green); wait(1); turnLEDOff (green); wait(1); turnLEDOn (green); wait (1); turnLEDOff (green); } Program begins within the curly braces must have one at the start and end. All commands end with a semi-colon Special command to turn on or off the LED Once finished typing in the code – Compile and Download the program

  42. green vs. dgtl12 task main() { turnLEDOff(dgtl12); wait (1); turnLEDOn(dgtl12); wait(1); turnLEDOff (dgtl12); wait(1); turnLEDOn (dgtl12); wait (1); turnLEDOff (dgtl12); } • Notice that the word green has been replaced by dglt12 • Either word will work • Give it try – replace green with dgtl12 • Compile and download

  43. Check for Understanding • In the ROBOTC Editor Window the Comments are displayed as what color? • In the ROBOTC Editor Window the Reserved Words are displayed as what color? • In the ROBOTC Editor Window the Constants and Parameters are displayed as what color? • The Motor and Sensor Setup is one of the central points of ROBOTC. What is it used to do?

  44. Try it on your own • Save A3_1_2_PART1 • SAVE AS A3_1_2_PART2 • This will keep all the Motor and Sensor Setting • Delete the Task Description, Pseudocode and the code between the curly braces. • Save

  45. A3_1_2_PART2 You can drag and drop these commands in between the curly braces

  46. Drag and Drop • You can drag and drop the commands from the Function Library in between the curly braces. • Notice the text in black • These are user defined variables or functions Before changing the black text After changing the black text – noticed it turned dark red

  47. Edit your program • Turn on leftMotor at the same time that rightMotor is turned on. • Test the program and troubleshoot if needed until the expected behavior has occurred. • Spelling does matter. • In this case, line 31 leftmotor should have been spelled leftMotor • Do not let your students get away with this.

  48. Modify your Program even more • Reverse both motors using two different programming methods. One option is change the setting Second option is to change the value to negative

  49. A3_1_2_Part3 • Save A3_1_2_Part2 • Save As A3_1_2_Part3 • Delete the Task Description, Pseudocode and code between the curly braces.

  50. A3_1_2_Part3 • Write a program that performs the following simple behaviors. • Add comments at the end of each command line to explain the purpose of each step. • 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.

More Related