TETRIX Add-On Extensions. Encoder Programming Guide (ROBOTC )

Similar documents
understanding sensors

After: bmotorreflected[port2]= 1; //Flip port2 s direction

Line Tracking Basic Lesson

How To Program An Nxt Mindstorms On A Computer Or Tablet Computer

Introduction to programming moway

North Texas FLL Coaches' Clinics. Beginning Programming October Patrick R. Michaud republicofpi.org

C.I. La chaîne d information LES CAPTEURS. Page 1 sur 5

Speed Based on Volume Values & Assignment (Part 1)

CONTENTS. What is ROBOTC? Section I: The Basics

The second goal is to provide a list of tips, tricks, and best known methods that have been discovered over the life span of the course.

YOSEMITE REGIONAL OCCUPATIONAL PROGRAM COURSE OUTLINE. COURSE TITLE: Robotics Engineering I ROP S1 Robotics Engineering I ROP S2

Tutorial for Programming the LEGO MINDSTORMS NXT

e d u c a t i o n NXT Solar Station

How To Turn On A Robot On A Computer On A Black Box On A Pc Or Macbook

What Is an Electric Motor? How Does a Rotation Sensor Work?

EV3 Programming. Overview for FLL Coaches. A very big high five to Tony Ayad

The Basics of Robot Mazes Teacher Notes

Quick Start Guide to computer control and robotics using LEGO MINDSTORMS for Schools

2/26/2008. Sensors For Robotics. What is sensing? Why do robots need sensors? What is the angle of my arm? internal information

Advanced Programming with LEGO NXT MindStorms

Programming LEGO NXT Robots using NXC

Tutorial 1. Introduction to robot

ROBOTC Natural Language - VEX Cortex Reference:

Additional Guides. TETRIX Getting Started Guide NXT Brick Guide

Conditionals (with solutions)

Classroom Activities for the Busy Teacher: EV3

Teacher Answer Key: Measured Turns Introduction to Mobile Robotics > Measured Turns Investigation

Robotics. Lecture 3: Sensors. See course website for up to date information.

File: C:\Program Files\Robotics Academy\RobotC\sample programs\rcx\arushi\robot_

ROBOTC Programming Competition Templates

Elfring Fonts, Inc. PCL MICR Fonts

Dr Robot C# Advance Sputnik Demo Program

Software Manual RS232 Laser Merge Module. Document # SU Rev A

The Little Man Computer

Questions: Does it always take the same amount of force to lift a load? Where should you press to lift a load with the least amount of force?

Introduction to the BackgroundWorker Component in WPF

Activities for LEGO WeDo in Scratch 1.4+ Barb Ericson

>

GANTRY ROBOTIC CELL FOR AUTOMATIC STORAGE AND RETREIVAL SYSTEM

How To Learn To Understand And Understand The Math Of The Year

ROBOTC Software Inspection Guide with Additional Help Documentation

Microcontroller Programming Beginning with Arduino. Charlie Mooney

UNIT 1 INTRODUCTION TO NC MACHINE TOOLS

FUNDAMENTALS OF ROBOTICS

Getting Started Manual

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0

Introduction WELCOME TO LEGO MINDSTORMS EDUCATION

A BRIEF INTRODUCTION TO COMPUTER PROGRAMMING Scratch, LEGO MINDSTORMS, and Visual Basic. July 24, 2015

PID Control. Proportional Integral Derivative (PID) Control. Matrix Multimedia 2011 MX009 - PID Control. by Ben Rowland, April 2011

Adding and Subtracting Positive and Negative Numbers

SSI. Modbus Analogue Output DEVICENET ETHERNETIP. Zero Slip, Zero Wear. Exact Measurement. No Moving Parts. Permanently Calibrated.

Introduction WELCOME TO LEGO MINDSTORMS EDUCATION

MSc in Autonomous Robotics Engineering University of York

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

ROBOTICS AND AUTONOMOUS SYSTEMS

Moving from CS 61A Scheme to CS 61B Java

FLL Advanced Programming & Best Practices Workshop

Downloading a Sample Program over USB

Mobile Robotics I: Lab 2 Dead Reckoning: Autonomous Locomotion Using Odometry

Arduino Lesson 16. Stepper Motors

Programming the VEX Robot

EasyC. Programming Tips

TECHNICAL UNIVERSITY OF CRETE DATA STRUCTURES FILE STRUCTURES

Autonomous Advertising Mobile Robot for Exhibitions, Developed at BMF

RobotC Tutorial Packet I

cs281: Introduction to Computer Systems Lab08 Interrupt Handling and Stepper Motor Controller

RapidScan3D Ultrasonic Instrumentation Quick Start Guide

EE 402 RECITATION #13 REPORT

Measurement Tools in Inventor

Solar Tracking Controller

Chapter 22: Electric motors and electromagnetic induction

OPERATING PRINCIPLES FOR PHOTOELECTRIC SENSORS

Basics of Web Tension Control Summary Presenter: Darrell Whiteside, Sales Channel Manager Tension Control Maxcess International

FOUNDATION. Observing the way different shaped objects such as balls, blocks and tubes move.

WISER 14. By the Robosses (Nila, Ishaa, Parvathi, Shivadharshne) National Public School, Bangalore, India And Vishnu Ram

Best Robotics Sample Program Quick Start

(Refer Slide Time: 01.26)

V out. Figure 1: A voltage divider on the left, and potentiometer on the right.

CE801: Intelligent Systems and Robotics Lecture 3: Actuators and Localisation. Prof. Dr. Hani Hagras

KS3 Computing Group 1 Programme of Study hours per week

Creating a Project with PSoC Designer

ROBOTICS 01PEEQW. Basilio Bona DAUIN Politecnico di Torino

Academic Crosswalk to Common Core Standards. REC ELA.RST LA k LA

DeviceNet Bus Software Help for Programming an Allen Bradley Control System

STEP 7 MICRO/WIN TUTORIAL. Step-1: How to open Step 7 Micro/WIN

What s Left in E11? Technical Writing E11 Final Report

FRC WPI Robotics Library Overview

Digital Systems Based on Principles and Applications of Electrical Engineering/Rizzoni (McGraw Hill

A Surveillance Robot with Climbing Capabilities for Home Security

1. Kyle stacks 30 sheets of paper as shown to the right. Each sheet weighs about 5 g. How can you find the weight of the whole stack?

Building Robots with NXT and LEJOS. Introduc<on. What is the NXT Robot Michael Wooldridge liv.ac.uk)

Chapter 11. h = 5m. = mgh mv Iω 2. E f. = E i. v = 4 3 g(h h) = m / s2 (8m 5m) = 6.26m / s. ω = v r = 6.

Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game

1. Use the class definition above to circle and identify the parts of code from the list given in parts a j.

Manual Software SPECTRO3-MONITORING V5.0

Transcription:

Introduction: In this extension, motor encoders will be added to the wheels of the Ranger Bot. The Ranger Bot with Encoders will be programmed to move forward until it detects an object, turn 90, and move forward until it detects a second object. The program will remember the encoder count distances from the start to the first object and from the first object to the second object. Using these encoder values, the robot will turn 90, move a distance equal to the first encoder value, turn 90, and finally move a distance equal to the second encoder value. From start to finish, this sequence of steps will make the robot move in a rectangle shape back to its starting point. This guide is for use with the ROBOTC programming language. Getting Started: 1. To start the program, type the Main Task function followed by an opening brace. task main() 2. Declare six integer variables as seen in the code below. Set them to the values shown. After each variable there are two slashes (//) followed by what that variable is representing. These mark a comment. Notice that comments appear in green when code is typed into ROBOTC. Note: A comment is not part of the code that the NXT Brick will execute, but it helps the programmer by allowing the addition of notes to describe what has been done. int object1dist; // Distance from start to first object int object2dist; // Distance from first to second object int stopdist = 30; // Stopping distance before objects int turndist = 1380; // Encoder counts that wheels rotate during each 90-degree turn int fwdpower = 10; // Motor power when robot drives forward int turnpower = 15; // Motor power when robot turns 3. Add the code below to set the encoder of the left motor to zero. A motor encoder is a sensor that determines the amount and speed of rotation of a motor. In this program we will be concentrating on using the motor encoder to control the movement of the robot. // Sets the motord encoder to zero 4. Add a While Loop that executes while the Ultrasonic Sensor reading is greater than the stopdist variable (set to 30 cm). Set both DC motors power to the fwdpower value while this condition remains True. This will make the robot move forward in a straight line towards the first object. while(sensorvalue(sonarsensor) > stopdist) motor[motord]= fwdpower; motor[motore]= fwdpower; // Moves forward until within 30 cm (stopdist) of first object 135

Encoder 5. After the robot is 30 cm from the first object, turn off the motors and make the robot wait for half a second. // Stop motors and make the robot wait for half a second 6. The code below reads the current output value of the encoder sensor. This value is the number of encoder counts that make up the distance from the robot s starting point to the point 30 cm from the first object. The program needs to remember this value for later on in the program, so it writes it to the variable object1dist. object1dist = nmotorencoder[motord]; // Sets distance from start to first object 7. The motor encoder needs to be set to zero again to read it correctly in the next step. // Resets the motor encoder of motor D to zero 8. Add a While Loop that executes while the current encoder value is below the variable turndist. This variable is an encoder count that is equal to the distance that a wheel rotates during a 90-degree turn. Set the DC motors power to the turnpower variable while this condition remains True; however, the right motor will be set to the negative value of turnpower. This will make the robot turn on the spot. Note: You must adjust the turndist value so the robot turns exactly 90 degrees. The preset value of 1380 shown in Step 2 is a good starting value; however, the robot turns different amounts on different ground surfaces. The value will probably have to be adjusted for a specific surface. // Must tweak the turndist encoder count value so that robot turns 90 degrees 9. As was done after the first While Loop, turn off the motors and make the robot wait for half a second. These three lines of code will be repeated after every While Loop. 10. Now the robot is ready to search for the second object. First, the motor encoder needs to be reset to zero. 136

11. As in Step 4, add a While Loop that drives the robot straight until it is within 30 cm of the second object. After the loop has been executed, turn off the motors and make the robot wait for half a second. while (SensorValue[SonarSensor] > stopdist) // Moves forward until within 30 cm (stopdist) of second object 12. Similar to Step 6, the distance from the first object to the second object must be remembered and written to the variable object2dist. After storing the encoder value, reset the encoder to zero. object2dist = nmotorencoder[motord]; // Sets distance from first to second object 13. Make the robot turn again using the same turning loop as in Step 8. Then, turn off the motors and make the robot wait for half a second. 14. The robot will now begin traveling back to its starting point. First, reset the motor encoder to zero. // Begins to travel back to the start 15. Add a While Loop that drives the robot straight for the distance of the encoder count value stored in the variable object1dist. This means the robot will travel the same distance as it did from its starting point to the first object. After the loop finishes, turn off the motors and make the robot wait for half a second. while (nmotorencoder[motord] < object1dist) 137

Encoder 16. Reset the motor encoder to zero. Then make the robot turn 90 degrees for the third and last time. Use the same code section from the previous turns as displayed below. 17. Reset the motor encoder. Similar to Step 15, add a While Loop that drives the robot straight for the distance of the encoder count value stored in the variable object2dist. This means the robot will travel the same distance as it did from the first to the second object. Now the robot is back to its starting point, having traveled in a rectangle movement. while (nmotorencoder[motord] < object2dist) 18. Before ending the program, the robot should be instructed to stop the DC drive motors. 138

19. Add a closing brace to end the program. Completed Code: task main() int object1dist; int object2dist; int stopdist = 30; int turndist = 1380; int fwdpower = 10; int turnpower = 15; // Distance from start to first object // Distance from first to second object // Stopping distance before objects // Encoder counts that wheels rotate during each 90-degree turn // Motor power when robot drives forward // Motor power when robot turns // Searching for the first object // Sets the motord encoder to zero while (SensorValue[SonarSensor] > stopdist) // Moves forward until within 30 cm (stopdist) of first object // Stop motors and make the robot wait for half a second object1dist = nmotorencoder[motord]; // Sets distance from start to first object // Resets the motor encoder of motor D to zero // Must tweak the turndist encoder count value so that robot turns 90 degrees 139

Encoder Completed Code (continued): // Searching for the second object while (SensorValue[SonarSensor] > stopdist) // Moves forward until within 30 cm (stopdist) of second object object2dist = nmotorencoder[motord]; // Sets distance from first to second object // Begins to travel back to the start while (nmotorencoder[motord] < object1dist) 140

Completed Code (continued): // Drives back to starting point while (nmotorencoder[motord] < object2dist) 141