Compiled from various Internet sources Presented by Mr. Hatfield

Slides:



Advertisements
Similar presentations
Sensors.
Advertisements

BEGINNER EV3 PROGRAMMING Lesson
EIGHTH GRADE ROBOTICS KITTATINNY REGIONAL HIGH SCHOOL MR. SHEA Introduction to Robotics Day4.
Session 2  The Touch Sensor  The Colour Sensor.
BEGINNER EV3 PROGRAMMING Lesson
The NXT is the brain of a MINDSTORMS® robot. It’s an intelligent, computer-controlled LEGO® brick that lets a MINDSTORMS robot come alive and perform.
LEGO Mindstorms NXT Programming We will be using the Common Palette for our Robots This is how you download your program onto the brick Drag and drop a.
By Droids Robotics Infrared Sensor Intermediate EV3 PROGRAMMING LESSON © 2015 EV3Lessons.com, Last edit 5/26/
Programming 101 The Common Palette Content provided by Connor Statham (6 th Grade Student) Formatting by Shannon Sieber.
The George Washington University Electrical & Computer Engineering Department ECE 002 Dr. S. Ahmadi Class 2.
Today’s Agenda 1.Scribbler Program Assignment 1.Project idea due next class 2.Program demonstration due Wednesday, June 3 2.Attendance & lab pair groupings.
EV3 Workshop Oct 3, 2015 Instructor: Chris Cartwright
Obstacle Detection Introductory Presentation. Opening Activity If you were blindfolded, what senses would you use to find things in the room?
Sentry System Multiple Sensors
Programming 101 The Common Palette Content provided by Connor Statham (9 th Grade Student) Formatting by Shannon Sieber.
ROBOTC Software EV3 Robot Workshop
BEGINNER FLL PROGRAMMING WORKSHOP BY DROIDS ROBOTICS & EV3LESSONS.
ROBOTC Software EV3 Robot Workshop Lawrence Technological University.
BEGINNER EV3 PROGRAMMING LESSON By: Droids Robotics Topics Covered: Touch Sensor.
Lego Mindstorm Robots 9797 kit.  Students will learn how to identify how to detect a change in a condition.  Students will learn where and how to identify.
Basic Programming: Until Commands. The Problem with Wait States Motor Speed is affected by battery power. –If the battery is fully charged, the motors.
USING SWITCHES TO PROGRAM A CANDY SORTER DESIGNED FOR USE WITH LMS EV3 PROGRAMMING AND BUILDING ENVIRONMENT.
Robotics Programming Wall Follow Line tracking for a set amount of time Line tracking for a distance.
Python Programming Module 4 Sensors and Loops Python Programming, 2/e1.
ROBOTC for CORTEX Teacher Training © 2011 Project Lead The Way, Inc. Automation and Robotics VEX.
EV3 Attachments and Sensors. Ultrasonic Sensor  Purpose: detect distance from an object.  What it does: Generates sound waves and reads their echoes.
LEGO Robotics Workshop
Introduction to Programming in RobotC
NXT Mindstorms Kit Programming
By Sanjay and Arvind Seshan
Create a Halloween Computer Game in Scratch
LEGO MINDSTORMS PROGRAMMING
Exploring Computer Science Lesson 6-5
Lecture 10 Sensors.
BEGINNER EV3 PROGRAMMING Lesson
ROBOTC for VEX Online Professional Development
By Sanjay and Arvind Seshan
Touch Sensor.
Finch Robot Class L4 How do I… ? LED color (Range 0 to 100)
Sensors For Robotics Robotics Academy All Rights Reserved.
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
Using Switches to Program A candy Sorter
BEGINNER PROGRAMMING LESSON
INTERMEDIATE PROGRAMMING LESSON
Introductory Presentation
Automation and Robotics
BEGINNER EV3 PROGRAMMING Lesson
BEGINNER EV3 PROGRAMMING Lesson
BEGINNER EV3 PROGRAMMING Lesson
Introductory Presentation
Motors and Sensors Large Motor
Introductory Presentation
Introductory Presentation
INTERMEDIATE PROGRAMMING LESSON
Exploring Computer Science Lesson 6-5
BEGINNER PROGRAMMING LESSON
Holyoke Codes LEGO ROBOTICS
BEGINNER PROGRAMMING LESSON
Using Switches to Program A candy Sorter
BEGINNER PROGRAMMING LESSON
Robotics Week 3 beginning wheel control
Robotics Week 6 line follower
Robotics Week 4 Functions and reusable code
Compiled from various Internet sources Presented by Mr. Hatfield
Introductory Presentation
Obstacle Detection.
Creating a Simple Game in Scratch
Lego MINDSTORMS EV3.
BEGINNER PROGRAMMING LESSON
Getting started with LEGO EV3 Mindstorms software
Presentation transcript:

Compiled from various Internet sources Presented by Mr. Hatfield Robotics Week 5 Sensors

Previously In Robotics We learned to use the display We learned to use the motors We learned about the sleep command We learned to make the robot move a specific distance at a specific power We learned to encapsulate code in functions

Motor and Sensor Setup In order to use sensor we have to set them up in ROBOTC Click on the Motor and Sensor Setup button

Motor Setup A new dialog box pops up with several tabs. Choose the Motors tab. Our standard setup is with motorB driving the left wheel and motorC driving the right wheel with the Large motors. Set yours up like this:

Sensor Setup The next tab over is the sensors tab, click it and set up the sensors like this: Select OK at the bottom of the dialog box.

We Pause Now To: Set up your motors and sensors

Back to the Code When we go back to the code we find that ROBOTC has modified the top 7 lines. Leave these alone. We can use the new names we have given the motors and sensors in our code.

Quickly Using Motor Names Instead of saying motor[motorB] = pwr; // or motorC We can say: motor[left] = pwr; // or right This is more descriptive and if we change where we put our motors we don’t have to change the code.

Now it is Time to Learn Sensors Sensor Types Color Ultrasonic Gyro Touch Infrared – not covered The following pages are from: http://www.legoengineering.com/ev3-sensors/ Visit this site for more information.

Color Sensor (from legoengineering.com) The color (or color) sensor can detect either the color or intensity of light. The color sensor has three different modes: color, reflected light intensity, and ambient light intensity. color – In this mode, the color sensor can differentiate up to seven different colors: black, blue, green, yellow, red, white, and brown. Each color is also represented by a value (see “color and light data table” below). Note: For best results, the color sensor needs to be 1-2 cm away from the color you are trying to detect, and have consistent lighting. Reflected light intensity – In this mode, the color sensor emits a red light and measures the amount reflected back into itself from the surface you are testing. The intensity of the light is measured as a percentage from 0 to 100, with 0 being very dark, and 100 being very bright. Ambient light intensity –  In this mode, the color sensor measures the amount of light in its environment, without producing its own light source. Ambient light intensity is measured as a percentage from 0 to 100, with 0 being very dark, and 100 being very bright.

Ultrasonic Sensor (from legoengineering.com) The ultrasonic sensor measures distance to an object up to a maximum of 255cm (or 100 inches) away. It does this by sending out high frequency sound waves that bounce off any object in range, and measuring how long it takes the sound to return to the sensor. In the software, you can select whether the distance is given in centimeters or inches. The ultrasonic sensor also has a “listen only” mode that can detect whether another robot is using an ultrasonic sensor nearby. In this mode, the sensor listens for signals but does not send them.

Gyro Sensor (from legoengineering.com) The gyro sensor detects rotational motion in the plane indicated by the arrows on the top of the sensor housing. The sensor measures the rate of rotation in degrees per second and keeps track of the total angle of rotation in degrees. Note: When connecting the gyro sensor to your EV3 brick, you should hold it completely still in order to minimize drift. For best results, reset the angle using the reset mode of the gyro sensor block before every angle of motion you want to measure.

Infrared Sensor (from legoengineering.com) The infrared sensor can measure distance or detect signals that are sent from the infrared beacon (see below). The infrared sensor can be used in three different modes: proximity, beacon, and remote. Proximity – The infrared sensor sends an infrared signal and detects the reflection of this signal by an object in front of the sensor. The strength of the reflected signal can be used to estimate the distance to the object. Its maximum range is approximately 100 cm. Beacon – In this mode, the infrared sensor can detect an infrared beacon, set to beacon mode. The infrared sensor can detect the beacon’s proximity (relative distance from the sensor) and its heading (angle from the direction the sensor is pointing). See the table below for more information. Remote – The infrared sensor can detect button presses on the IR beacon. The infrared sensor can detect which button on the remote infrared beacon is pressed. You can also detect when certain combinations of two buttons are pressed at the same time.

Touch Sensor The touch sensor gives your robot a sense of touch. The touch sensor detects when it is being pressed or released. It can even be programmed to wait until it is both pressed and released (we call this bumped).

So How Do I Use Sensors? The commands for the sensors are located in the list of text functions under ‘Sensors’ The main commands we will use will involve resetting and getting the values of sensors.

Give Me Code!!! (Gyro Sensor) Getting a sensor value, there is a single command that can be used to get any sensor value: SensorValue(namedSensor) //Resets the motor encoder using the resetMotorEncoder command resetGyro(gyro); //Using our gyro setup from earlier //Run motors until the gyro reaches 90 or -90 degrees (abs value) while(abs(SensorValue(gyro)) < deg) {//move until requested deg motor[motorC] = 25; motor[motorB] = 0; //one of the motors needs to be still } motor[motorC] = 0; motor[motorB] = 0;

Give Me More Code!!! (Still Gyro) To do the same with the gyro specific command. getGyroDegrees(gyro) //Resets the motor encoder using the resetMotorEncoder command resetGyro(gyro); //Using our gyro setup from earlier //Run motors until the gyro reaches 90 or -90 degrees (abs value) while(abs(getGyroDegrees(gyro)) < deg) {//move until requested deg motor[motorC] = 25; motor[motorB] = 0; //one of the motors needs to be still } motor[motorC] = 0; motor[motorB] = 0;

Touch Sensor This will cause the program to wait until the touch sensor is pressed. Uses getTouchValue(touch), also works with SensorValue(touch) Notice == means equals for conditions //No need to reset the touch sensor //Waits while the touch sensor reads 0, 1 means pressed while(getTouchValue(gyro) == 0) { //Do nothing here… } //Do the rest of the code here…

Color Sensor Let’s make the robot move until the Color Sensor senses Dark Uses getColorAmbient, works with SensorValue //Again, no need to reset a color sensor int gray = 25; //Set a middle light/dark value, depends on room //While the Color Sensor senses light color while(getColorAmbient(color) > gray) { motor[motorC] = pwr; motor[motorB] = pwr; } motor[motorC] = 0; motor[motorB] = 0;

Ultrasonic Sensor (US Sensor) Let’s make the robot move until the Ultrasonic Sensor is 10cm from something Uses getUSDistance, works with SensorValue //Again, no need to reset a US sensor //While the US Sensor is > 10 cm while(getUSDistance(sonic) > 10) { motor[motorC] = pwr; motor[motorB] = pwr; } motor[motorC] = 0; motor[motorB] = 0;

Use these example in Functions For Example: The Ultrasonic Sensor void moveToObject(float d, int pwr) { //Desc: moves the robot until the distance specified in ‘d’ // at a power specified by ‘pwr’ while(getUSDistance(sonic) > d) {//runs until US reads distance motor[left] = pwr; //Uses the new left motor designation motor[right] = pwr; //Uses the new right motor designation } motor[left] = 0; motor[right] = 0;

Different Settings The different commands used by the sensors may require different sensor settings An example would be to ‘SEE’ the color ‘RED’ the color sensor would need to be set to ‘COLOR’ in the Motor and Sensor Setup Search online for more specific information concerning setup, or Just Try It for yourself

Good Function Comments When you make functions use good comments to help yourself and others later… For example: void brake () { // Name: brake // Author: Andy Hatfield // Desc: Stops the wheels for a duration of 1/10 sec. // This is just enough for the wheels to stop. //Notes: Nov 1, 2018 – changed motor[] commands to // setMotorSync command setMotorSync(left, right, 0, 0); //New function sleep(100); }

The Beauty of Sensors Using the sleep command can give varied results due to battery power Using distance based functions can be tricky because of small differences in the game board and wheel slippage (will be addressed later) SENSORS ARE SUPER COOL

Now It’s Your Turn Create and test the following functions: waitUntilTouch(){} moveToObject(float dist, int pwr){} moveFromObject(float dist, int pwr){} moveToLine(int pwr){} turnRight(int deg, int pwr){} turnLeft(int deg, int pwr){} Modify the functions to display the function name and the parameters when they are called

Congratulations!!! I am assuming that you have a functioning EV3 with ROBOTC I am assuming that you were able to use the sensors and create the new usable functions