1 / 43

College of Southern Maryland Vex Robotics Workshop EasyC Tutorial

College of Southern Maryland Vex Robotics Workshop EasyC Tutorial. Presented By: Willy Hamel Stewart Smith August 2012. Methods of Control. Driver Control Autonomous Programming Without Sensors With Sensors Sample Programs Competition Templates. Driver Control.

jethro
Download Presentation

College of Southern Maryland Vex Robotics Workshop EasyC Tutorial

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. College of Southern MarylandVex Robotics Workshop EasyC Tutorial Presented By: Willy Hamel Stewart Smith August 2012

  2. Methods of Control • Driver Control • Autonomous Programming • Without Sensors • With Sensors • Sample Programs • Competition Templates

  3. Driver Control • Choosing a joystick channel • Selecting method of control • Motor direction and power • While loop

  4. Choosing a Channel Ch5 Ch6 Ch7 Ch8 Ch3 Ch2 + Ch4 Ch1 - + -

  5. Methods of Control • Arcade Drive • Tank Drive • Holonomic Drive • Single Motor Control • Stick control • Button control • Variable control (Advanced)

  6. Arcade Drive Single stick control Two motor arcade drive is depicted left, however, a four motor block also exists.

  7. Tank Drive Two stick control Two motor tank drive is depicted left, however, a four motor block also exists.

  8. Holonomic Drive Two-stick control A holonomic drive enables greater range of motion at the expense of available power in any one direction

  9. Joystick to Motor This block will map a motor’s power to the joystick. The joystick channel dictates which way the stick must be pushed to power the motor

  10. Joystick Digital to Motor This block will map a motor’s power to a button on the controller. You must choose a channel as well as how much power the motor will receive when the button is pressed.

  11. Variable control (Advanced) This block will map a motor’s power to a defined variable. The motor will then no longer necessarily be controlled by the joystick, but by whatever the variable is equal to.

  12. Motor Direction and Power 127 0 -127 0 = Stop

  13. While Loop A while loop will repeat the commands within it until the condition in parenthesis is no longer met. An infinite loop, a while loop that is always true, is needed in any Driver code to constantly update the motor commands.

  14. Sample Driver Code

  15. Autonomous Coding • Programming Logic • Motor Control • Sensors • Sample Programs • Competition Templates • Timed • Field Control

  16. Programming Logic • Variables • If • Else-If and Else • Operators • While • Wait • Print to Screen • Comment

  17. Variables Variables are placeholder for values within the program. They can be used to hold sensor input values for later use within the code.

  18. If Statement An if statement will perform its commands only if the condition in parenthesis is true. If false, the statement will just be skipped and not read. An if statement can be used to prevent an unwanted action from occurring or to respond to a sensor input.

  19. Else-If and Else Statements An else-if statement is a logical branch that enables more control than a single if statement. An else statement is a catchall statement used to define an action if the preceding if/if-else statements are false

  20. Operators Operators are symbols that represent a logical function. They can be used in while loops and if statements to ensure the desired action/function occurs.

  21. While Loop A while loop will repeat the commands within it until the condition in parenthesis is no longer met. A while loop that that contains a get sensor value block allows you to constantly update the sensor value and make decisions based on your sensor values.

  22. Wait Statement A wait statement will cause the robot to wait a certain number of milliseconds before performing the next command . (Warning, this pauses ALL functions in the program!) A wait statement is typically used to control motors in the absence of sensors.

  23. Print to Screen Print to screen is a command that can be used to find the current value of a variable. It will be shown in the terminal window. This feature can be used to trouble shoot your sensors.

  24. Comments A comment is a line of text left by the user. Use it to keep track of what your code is doing.

  25. Motor Control Use output blocks to control individual motors. You must declare power and direction.

  26. Motor Control Control the duration of movement using wait blocks. You can also give motors commands based on sensors.

  27. Sensors • Potentiometers • Ultrasonic Rangefinders • Limit switches/Bumpers • Optical Shaft Encoders • Line Followers

  28. Potentiometers • Used for precise angle measurement • Maximum rotation of 250⁰ • This angle is divided into 1024 increments Potentiometer

  29. Ultrasonic Rangefinder • Used for measuring distance from an object • Maximum range of 115 inches (approx. 9.6 feet) Ultrasonic Rangefinder

  30. Limit Switches/Bumpers • Used for detecting contact • Differ in ability to take different contact forces. Limit Switch. Sensitive, but a little fragile. Bumper Bumper Switch. Less sensitive, but can take a beating.

  31. Shaft Encoder D = 2*π*r r = radius of wheel D = distance traveled in one revolution π = 3.14159~ • Used for counting rotations made and finding distance traveled • Capable of unlimited 3600 rotation (free spinning) Shaft Encoder

  32. Line Follower • Used for detecting color differences • Useful for following or detecting lines Line Follower

  33. Programming Sensors • Inputs • Wait Until

  34. Programming Sensors These blocks measure a sensor value and record it in a variable so it can be called later in the code. They are used in conjunction with logic statements to control the robot.

  35. Programming Sensors Potentiometer

  36. Programming Sensors These blocks are similar to Wait blocks. The robot will not proceed to the next action until the condition is met. These blocks do not require a variable in order to function.

  37. Programming Sensors Bumper Wait Until Block

  38. Programming Sensors Ultrasonic Wait Until Block

  39. Sample Code

  40. Sample Programs Sample Programs demonstrate how to set up and use vex sensors as well as other programming techniques.

  41. Competition Templates These are code templates that allow you to simulate or play in a Vex Robotics Competition.

  42. Template Types • Field control • Timed (in seconds)

  43. Resources • http://www.robotc.net/vex_full/ • http://www.education.rec.ri.cmu.edu/roboticscurriculum/vex_online/hardware/index.htm

More Related