IR SENSORS AND ENCODERS. LCDs Timothy Friez Class # 2.

Slides:



Advertisements
Similar presentations
Variables and Functions ROBOTC Software. Variables A variable is a space in your robots memory where data can be stored, including whole numbers, decimal.
Advertisements

Add and Use a Sensor & Autonomous For FIRST Robotics
Engineering Roles We will be forming groups of 3 students
Microprocessor Motor Control Spring Introduction  Stamp projects Robots  Sensors  Motor control  Logic Rocketry  Reading acceleration (“g”
ELECTRICAL. Circuits Outline Power Hub Microcontroller Sensor Inputs Motor Driver.
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.
Motor control drive in circles Pragmas configure motors Turning right in function of time Turning left in function of time Main program starts from here.
RobotC Programming for LEGO Mindstorms NXT Carnegie Mellon Dacta Lego Timothy Friez Miha Štajdohar SOURCES:
LEGO Mindstorms NXT Carnegie Mellon Dacta Lego Timothy Friez Miha Štajdohar SOURCES:
Micromouse Meeting #3 Lecture #2 Power Motors Encoders.
Indian Institute of Technology Hyderabad CONTACTLESS TACHOMETE R Group members: Moruboyina Alekhya Kodi Padmasree D.Hima Varsha.
Embedded Programming and Robotics
1. A guide to wiring your robot. Jerry Skene Past mentor – Chantilly Robotics
ARDUINO PROGRAMMING Working with the Arduino microcontroller.
Working with Arduino: Lesson #1: Getting Acquainted with the Kit EGN1007.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
ROBOTC Software Introduction. ROBOTC Software ROBOTC developed specifically for classrooms and competitions Complete programming solution for VEX Cortex.
Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.
Programming Concepts Part B Ping Hsu. Functions A function is a way to organize the program so that: – frequently used sets of instructions or – a set.
The George Washington University Electrical & Computer Engineering Department ECE 002 Dr. S. Ahmadi Class 2.
ROBOTC for VEX On-Site Professional Development
Programming Concepts (Part B) ENGR 10 Introduction to Engineering 1 Hsu/Youssefi.
ROBOTC Training Session 1 Timothy Friez 1/10/08 Revision 1.
CS 478: Microcontroller Systems University of Wisconsin-Eau Claire Dan Ernst Hybrid I/O – Pulses.
Robot sensors MVRT 2010 – 2011 season. Analog versus Digital Analog Goes from 0 to 254 Numerous values Similar to making waves because there are not sudden.
2008 SBPLI/FIRST Programming Workshop Tom Boehm Patchogue Medford High School, Team 329 Motorola Inc. Mark McLeod Hauppauge High School Team 358 Northrop.
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 4.
Automatic accident avoiding system PROJECT MEMBERS MUTHUKUMAR.K (05ME33) SAKTHIDHASAN.S (05ME39) SAKTHIVEL.N (05ME40) VINOTH.S (05ME56) PROJECT GUIDE:
Session 12 Sensors and Timers. 3 Main Types of Robot Projects Command-Based Robot A more complicated project for more complicated robots Iterative Robot.
Variables and Functions ROBOTC Software © 2012 Project Lead The Way, Inc.Principles of Engineering.
Oregon Robotics Tournament and Outreach Program RCX Basics.
Microcontrollers, Microcomputers, and Microprocessors
Variables and Functions ROBOTC Software. Variables A variable is a space in your robots memory where data can be stored, including whole numbers, decimal.
INTERNET OF EVERYTHING SDU 2016 Week 4. Simple Digital and Analog Inputs  The Arduino’s ability to sense digital and analog inputs allows it to respond.
Deriving Consistency from LEGOs What we have learned in 6 years of FLL by Austin and Travis Schuh © 2005 Austin and Travis Schuh, all rights reserved.
Automation and Robotics.  First you select the platform type so that you can use Natural Language PLTW.
MEH108 - Intro. To Engineering Applications KOU Electronics and Communications Engineering.
Limited rotation servo basics David Hall output shaft servo horn red wire = 5V + black wire = Gnd - white wire = control signal standard servo.
Variables. A variable is a space in your robot’s memory where you can store data, such as whole numbers, decimal numbers, and words. Variable names follow.
ROBOTC for CORTEX Teacher Training © 2011 Project Lead The Way, Inc. Automation and Robotics VEX.
Harpeth Hall Jan 2016 Introduction to Arduino Prepared for Harpeth Hall Winterim January 2016.
Arduino.
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 4.
Introduction to Programming in RobotC
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
simple example program to control a DC-Motor
Assist. Prof. Rassim Suliyev - SDU 2017
Deriving Consistency from LEGOs
Variables and Functions
Introduction to Handshaking Communication with SSC-32U
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
How to avoid catching things on fire.
RobotC Sensors.
Movement using Shaft Encoders
Using Encoders to go Straight
Variables and Functions
Trainings 10/28 Woooooo!!.
Variables and Functions
Working with Arduino: Lesson #1: Getting Acquainted with the Kit
Variables and Functions
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 5.
Auto Straightening using VEX Shaft Encoders
Robotics Programming Using Shaft Encoders
Robotics Programming Using Shaft Encoders
RobotC Programming for LEGO Mindstorms NXT
Robotics Programming Using Shaft Encoders
Compiled from various Internet sources Presented by Mr. Hatfield
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
Oregon Robotics Tournament and Outreach Program
Presentation transcript:

IR SENSORS AND ENCODERS. LCDs Timothy Friez Class # 2

Outline for Tonight Variables overview IR Board –Purpose –Wiring –Programming –Testing –Using in an Autonomous Program (code sample) *10 minute break* Encoders –Purpose –How it works –Testing and Developing a Program Questions

Why use variables? Variables help to simplify your code. –You can use variables more than once –When you change a variable once, it changes the reference to that variable everywhere. –Makes your code more “english” readable. Example: motor[port1] = 100; motor[port2] = 100; Or, better… int speed = 100; motor[port1] = speed; motor[port2] = speed;

Other Advantages of variables Any variable declared appears in the “global variables” –This screen will show the current value of all variables. Variables can be modified in a program –example: int motorspeed = 50; motorspeed = motorspeed * 2;

Ideas for using variables Setting global motor speeds –int motorspeed = 100; Knowing the condition of your joysticks –int joystick_x; –joystick_x = frcRF[p1_y];

Fun with Variables Common types of variables: –int = integer (whole numbers) –float = floating point number (decimals) –bool = boolean values (true or false) Valid uses: –int motorspeed = 100; –float pi = ; –bool sensor_check = true;

Types of Operators (Boolean) 7 primary types of Boolean operators for conditional statements < Less Than > Greater Than <= Less Than or Equal To >= Greater Than or Equal To && And (both conditions must be true) || Or (either condition can be true) == Equal (one condition equals another condition) != Not Equal (one condition does not equal another) Values are Boolean, arguments not necessarily.

IR Sensor Board Used for “Hybrid” mode Allows the Human Player to send up to 4 signals (but not at the same time…) Called also the IR board = Infrared sensors

IR Sensor Board Wiring the board –2 positive voltage wires (pin 1 and 2) –2 negative voltage wires (pin 3 and 4) –4 Signal wires (pins 5, 6, 7, 8) These wires go to the “Digital I/O” port on the FRC

Pin 1 and 2: Voltage Pos Pin 3 and 4: Voltage Ground Pin 5 – Output #3 Pin 6 – Output #2 Pin 7 – Output #1 Pin 8 – Output #4 Pins 9 and 10 are not used.

But it’s not that easy… You have to hook the signal wires up to the white wire of a 3-pin PWM Cable –Pin 5, Pin 6, Pin 7, and Pin 8 are all signal wires You then have to hook the ground wire from the IR board to the Black wire of the PWM cable to complete the electrical circuit! –Pin 3 and Pin 4 are ground

Wiring Diagram for IR Board, Robot and 4 digital sensors IR Board Robot Voltage + Pin 1 Pin 2 Robot Ground Pin 3 Pin Pin 5 Pin 6 Pin 7 Pin 8

So what’s that look like? A mess, kind of.

So how do we “program” it? First you have to “train” the receiver. –Step 1: Turn power off –Step 2: Hold button down on IR Board –Step 3: When LED 1 turns on, press the first button. If the signal is good, the LED will go off, and then back on again. –Step 4: Press the first button again until LED 1 goes off once more. –Step 5: LED 2 will light up… repeat with buttons 2, 3 and 4. Once done, all LEDs will turn off, and the IR board is programmed.

How do we ROBOTC program it? All 4 of these inputs are treated like digital inputsAll 4 of these inputs are treated like digital inputs –Reminder: Digital inputs are like touch sensors. Code: (assume we’ve put this on port 3) –frcDigitalIODirection[pio3] = dirInput; –Access with frcDigitalIOValue[pio3]

Encoders Know how many time your drive wheels have gone around. Need an encoder on each drive motor output.

Our Encoders? Gear Tooth! Each FIRST kit comes with 2 gear tooth encoders.

How encoders work The gear tooth encoder works on a principal called the “Hall Effect” –Detects differences in magnetic fields and produces a result. When the sensor reads a tip, it sends a high digital value (a “1”) When the sensor reads a valley, it sends a low digital value (a “0”)

How encoders work Gear tooth Sensor Output: 1 Metal Gear

How encoders work G.T. Sensor Metal Gear Output: 0

Problems with encoders Extremely fragile (look at how tiny it is!) Requires 2 cables –12 volt power supply –5 volt digital signal cable (PWM) Must be mounted no further than 2mm away from top of gear tooth. Not a problem?: –able to be mounted in the 2008 gearboxes directly

Recommendations for use Larger, more robust gear tooth sensor! Honeywell 1GT101DC - Hall Effect Gear Tooth Sensor Digikey.com - $22.29 each + shipping Advantages: –Only requires one PWM cable –Rated up to RPM

Mounting idea Almost touching the gear… needs to be very close.

How to program encoders using RobotC? Wires into a Digital I/O port. Will only tell number of rotations, not direction Returns a 1 at a tip, returns a 0 at a valley ROBOTC will take care of the counting for you. Setup with Motors and Sensors Setup screen Access with –SensorValue[encoder1] Reset to zero with –SensorValue[encoder1] = 0;

Encoder – Go Straight Last Week’s Notes –Use Motors and Sensors Setup to configure our encoders –Clear the encoders before using them –Program: Go straight using encoder feedback If left wheel lags behind, slow down right wheel If right wheel lags behind, slow down left wheel If both wheels are equal, go an equal speed. Use Three “If” statements