Robotics Programming Using Shaft Encoders

Slides:



Advertisements
Similar presentations
ROBOTC for CORTEX While Loops Part 1
Advertisements

While Loops and If-Else Structures
08/2012Tanya Mishra1 EASYC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817.
Automation and Robotics
VEX and Robot C Chris Patterson Presented by Modified by J. Andazola.
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.
Available at: – Program Optical Quad Encoders in Autonomous Mode Program optical quad encoders in autonomous mode.
RobotC For Beginners Tyler Lutz and Keaton Bonds DRSS Enterprise.
Testbed: Exercises.
ROBOTC Software Introduction. ROBOTC Software ROBOTC developed specifically for classrooms and competitions Complete programming solution for VEX Cortex.
Program ultrasonic range sensor in autonomous mode
Engineering 1020 Introduction to Programming Peter King Winter 2010.
Getting Started in RobotC // Comment task main() motor[] {} wait1Msec() ; = Header Code Compile Download Run Take out your notes.
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.
Automated Mechanisms Help. Potentiometers Potentiometer Check –Analog Port 2 How they work –Analog sensor –Measures rotation of a shaft between 0 and.
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.
Programming your Robot
Mindstorm NXT-G Introduction Towson University Robotics.
VEX and Robot C Chris Patterson Frisco ISD CTE Center Presented by.
Vex Robotics Program Two: Using two motors. Program two: using the motors In the last section, you learned how to turn on one motor. Now, you will take.
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 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.
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
CHAPTER 4 DECISIONS & LOOPS
VEX Cortex Video Trainer using ROBOTC
ROBOTC for VEX Online Professional Development
ROBOTC for VEX Online Professional Development
ROBOTC for VEX On-Site Professional Development
ROBOTC for VEX Online Professional Development
ROBOTC for VEX Online Professional Development
StartStruck in a Virtual World
Introduction To Robot Sensors
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
RobotC Sensors.
Movement using Shaft Encoders
Using Encoders to go Straight
RobotC Sensors.
Getting Started in RobotC
Using variables, for..loop and functions to help organize your code
Automation and Robotics
TECH 1 BAMS Technology Education
While Loops and If-Else Structures
Sensors and Logic Switches
Basketball Drill Programming Alternatives
Getting Started in RobotC
Auto Straightening using VEX Shaft Encoders
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
Programming - Buttons Intro to Robotics.
RobotC While loop When and how to use the while loop
if-else Structures Principles of Engineering
Automation with RobotC
Robotics Programming Using Shaft Encoders
Programming - Buttons Intro to Robotics.
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 Concepts (Part B) ENGR 10 Introduction to Engineering
While Loops And If-Else Structures
Presentation transcript:

Robotics Programming Using Shaft Encoders

Learning Objectives Be able to use shaft encoders to control robot behavior.

Movement using Shaft Encoders Configure (Motors and Sensors Setup) We will look at the following in this section SensorValue[] while Conditions (<, >, <=, >=, !=, ==)

Quadrature/Shaft/Rotation Encoder 360 Ticks per revolution Counts up going forward, down going backwards Takes two digital input ports on the Cortex If the wires are plugged in in reverse order, then the counter will count backwards.

Configuring the Encoders Robot -> Motors and Sensors Setup

Name and Select 1) Select the VEX Cortex Digital Sensors 1-12 tab. 3) Select the Sensor Type. Quadrature Encoder in this case. 2) Name the encoder. (Start with a letter, no spaces, no punctuation, no reserved words, descriptive.) 4) Click ‘Apply’ and ‘OK’ Note: On the Cortex the quadrature encoder cables must be plugged in next to each other.

pragma Statements Created

Initializing and Reading the Encoder SensorValue[rightEncoder] is used to initialize (set to 0 in this case) and read encoder values. Initializes both encoder values to 0. While the value of the left encoder is less than 1800 it will go through the loop again. while (condition) { }

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.

Boolean Logic Decisions robots make must always based on questions which have only two possible answers: yes or no, true or false. Statements that can be only true or false are called Boolean statements, and their true-or-false value is called a truth value.

Boolean Logic Conditions: True or False Conditions: Compare two items and return a true or a false value RobotC Comparison Operations < Is less than > Is greater than <= Is less than or equal to >= Is greater than or equal to == Is equal to != Is no equal to

Boolean Logic

Conjunctions Conditions can be combined using conjunctions && (AND) while ((SensorValue[rightEncoder]<1800) && (SensorValue[leftEncoder] <1800)) { //while both encoders are less than 1800 it will repeat the code in the {} block } || (OR) while ((SensorValue[rightEncoder]<1800) || (SensorValue[leftEncoder] <1800)) { // While either the leftEncoder<1800 or the rightEncoder is <1800 it will //repeat the code inside the {} block ! (NOT) Turns true to false and false to true while !(SensorValue(leftEncoder)>1800)

Boolean Check: Fill in the Chart (T/F) x y x <= y y > 5 ( x <= y) && ( y > 5 ) ! (( x <= y) && ( y > 5 )) 10 11 4 100 90 3

Back to the Encoder Example SensorValue[rightEncoder] is used to initialize (set to 0 in this case) and read encoder values. Initializes both encoder values to 0. While the value of the left encoder is less than 1800 it will go through the loop again. while (condition) { } What happens if you add a wait1Msec(12000); command inside the while loop? Test this code in the Virtual World.

Debugging: Watching the Sensor Values Open Debugger window for Sensors Robot->Degugger Windows -> Sensors

Watch the Values Run the program in the Virtual World Watch the sensor values change Sensor Values

Online Time Complete the Labyrinth Challenge using encoders rather than timers You cannot use the wait1Msec or wait10Msec commands.