ENGR 101: Robotics Lecture 4 – Making Decisions Outline  The Stall Sensor  Making Decisions  Random Number Generation References 

Slides:



Advertisements
Similar presentations
08/2012Tanya Mishra1 EASYC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817.
Advertisements

Boe-bots and STEM Boe-bots and STEM – This sectional will introduce participants to a programmable robot that is useful for engaging students in building.
VEX and Robot C Chris Patterson Presented by Modified by J. Andazola.
1 Lecture 1: Your Boe-Bot's Servo Motors Presentation based on: "Robotics with the Boe-Bot" By Andy Lindsay Parallax, Inc Presentation developed by: Martin.
Navigating the BOE-BOT
Hardware Meets Software CPSC 120 Principles of Computer Science February 15, 2012.
Chapter 4 Control Structures I. Objectives ► Examine relational and logical operators ► Explore how to form and evaluate logical (Boolean) expressions.
ENGR 101: Robotics Lecture 2 – Text Programming Outline  Introduction to PBASIC  Variables, I/O, Arithmetic  Controlling the LEDs References 
ENGR 101: Robotics Lecture 5 – Subprograms Outline  Subprograms  The Infrared Sensor System References 
Introduction to Sensors
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Programming Epson Robots – Part 2 ME 4135 – Fall 2012 Dr. R. Lindeke.
chipKit Sense Switch & Control LED
Program ultrasonic range sensor in autonomous mode
GIRLS Robotic Camp. Let’s Begin Meet and Greet – Camp leaders introduce themselves – Students introduce themselves.
Unit 5 – “Watch Out!”. Introduction New Topics Case Structures New Functions Less? Comparison Function Ultrasonic Sensor.
The Basic Stamp Instruction Set Architecture. The Microprocessor A microprocessor is a computer that typically has an architecture that is well suited.
Basic Stamp OEM module By Wilmer Arellano. OEM BASIC Stamp 2sx Wiring diagram Note: - is connection to negative pole of the battery 220 Ohm Push button.
Python – Making Decisions Lecture 02. Control Structures A program that only has one flow is useful but limited. We can use if statements to make these.
Programming the CheapBot-14. Start the Editor Set the Mode.
10/10/ Controlling YOUR ROBOT. 10/10/2015 Basic Stamp  Basic Stamp Input - output pins Interpreter Chip Power supply: 5 Volts voltage Memory: EEPROM.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
Control Structures – Selection Chapter 4 2 Chapter Topics  Control Structures  Relational Operators  Logical (Boolean) Operators  Logical Expressions.
More switches, Comparison Day 7 Computer Programming through Robotics CPST 410 Summer 2009.
More on Input Output Input Stream : A sequence of characters from an input device (like the keyboard) to the computer (the program running). Output Stream.
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.
Software and documentation Download and install: “Setup-Stamp-Editor-Lrg-v2.2.6.exe”  Downloads  BASIC Stamp software BASIC Stamp Syntax.
Basic Stamp OEM module By Wilmer Arellano. 2  The BASIC Stamp 2 OEM is a discreet component version of the BS2 which may be purchased in kit form. 
Microcontroller I Seth Price Department of Chemical Engineering New Mexico Tech Rev. 9/22/14.
© Jalal Kawash Programming Peeking into Computer Science 1.
Control Structures CPS120: Introduction to Computer Science Lecture 5.
Mathematical Expressions, Conditional Statements, Control Structures
IR Communication October 27, Sources  Lindsay, Andy. IR Remote for the Boe- Bot. v
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
Introduction 2 Smart Design. What is smart design? 2 Everything is designed except nature The packaging of a Band-Aid The curve of a bike frame The shape.
Slide Menlo Drive Suite 100 Rocklin, CA Presentation based on: “What’s a Microcontroller?" by Andy Lindsay Presented by Andy.
ENGR 101: Robotics Lecture 3 – Robot Motion Outline  Robot Motion  FOR Loops  Making Music References 
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
July 7, 2003 Slide 1 of 6 Automation, Robotics and Mechatronics Lab, SUNY at Buffalo Introduction To Programming Chetan Jadhav Talib Bhabharawala Seung-Kook.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Slide Menlo Drive Suite 100 Rocklin, CA
Slide 1 Chapter #7: Measuring Light Light Sensor Circuit Parts (1) (1)Resistor – 220 Ω (red-red-brown) (1) Capacitor – 0.1  F (1) Capacitor – 0.01  F.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Basic Stamp OEM module By Wilmer Arellano. 2  The BASIC Stamp 2 OEM is a discreet component version of the BS2 which may be purchased in kit form. 
Basic Stamp OEM module By Wilmer Arellano. 2  The BASIC Stamp 2 OEM is a discreet component version of the BS2 which may be purchased in kit form. 
ENGR 101: Robotics Lecture 6 – Follow That Light! Outline  The Scribbler's Light Sensors  Using EEPROM Memory References 
USING CONDITIONAL CODE AMIR KHANZADA. Conditional Statement  Conditional statements are the set of commands used to perform different actions based on.
1 BOE-BOT Lecture #2 DE - Digital Electronics Servos and the BOE-BOT.
Casne.ncl.ac.uk Taking care of the CrumbleBot Please do NOT stress the robot's motors 1.Do NOT push the robot 2.Do NOT hold the.
Learning Javascript From Mr Saem
Limited rotation servo basics David Hall output shaft servo horn red wire = 5V + black wire = Gnd - white wire = control signal standard servo.
The “Board of Education” 1 Three-position switch 0 = OFF 1 = ON / wheels OFF 2 = ON / wheels ON breadboard (for building circuits) electrical power (V.
Making Choices with if Statements
OEM BASIC Stamp 2sx 220 Ohm.
Introduction To Robot Sensors
PROMGRAMING YOUR ROBOT
Introduction to MATLAB
Controlling YOUR ROBOT
While Loops and If-Else Structures
Visual Basic – Decision Statements
Selection Statements.
While Loops and If-Else Structures
While Loops and If-Else Structures
Karl Jean-Francois-James Madison H.S. & Eldiquen Mangubat-IS 232
While Loops and If-Else Structures
While Loops and If-Else Structures
Programming the BASIC Stamp
While Loops and If-Else Structures
Lego MINDSTORMS EV3.
While Loops And If-Else Structures
Presentation transcript:

ENGR 101: Robotics Lecture 4 – Making Decisions Outline  The Stall Sensor  Making Decisions  Random Number Generation References  PBASIC Programming Guide: Setting Up PBASIC Programming Guide: Writing Programs BASIC Stamp Syntax and Reference Manual 1

Lecture 4 – Making Decisions The Stall Sensor We have used pins only for output, but it is also possible to use a pin for input. Pin 7 is connected to a stall sensor. When both motors are on and the wheels are turning the sensor sends a low voltage to pin 7. If the motors are on and BOTH wheels are stuck (not turning) the sensor sends a high voltage to pin 7. A low voltage is interpreted as a binary 0, while a high voltage is a binary 1. 2

Lecture 4 – Making Decisions The Stall Sensor We can refer to the value at pin 7 using the PBASIC bit name for the pin, IN7: LOW RtMotor'Motor init. LOW LtMotor PAUSE 100 PULSOUT RtMotor, 2400 'Start your PULSOUT LtMotor, 2400 'engines... DO DEBUG HOME, DEC IN7 PAUSE 50 LOOP 3

Lecture 4 – Making Decisions The Stall Sensor This program continuously displays the state of the stall sensor (0 – running, 1 – stalled) in a loop. It is preferable to label the stall sensor pin: Stall PIN 7 DO DEBUG HOME, DEC Stall PAUSE 50 LOOP 4

Lecture 4 – Making Decisions The Stall Sensor We will typically want to “read” the stall sensor setting at the beginning of a loop and then do something depending on the setting. You may want to store the value in a variable: Stall PIN 7 stuck VAR Bit'Declare var DO stuck = Stall 'WE ARE STUCK - DO SOMETHING!!! LOOP 5

Lecture 4 – Making Decisions IF-THEN-ELSE-ENDIF Robots (and computer programs) seem intelligent because they can respond differently to different events. The standard computer program decision structure is an IF-THEN-ELSE-ENDIF block: IF (stuck = 1) THEN 'Code to stop motors goes here ELSE 'Code for full ahead goes here ENDIF 6

Lecture 4 – Making Decisions IF-THEN-ELSE-ENDIF If the condition is TRUE the THEN block of code is executed. If FALSE the code in the ELSE block is executed. The parentheses around the condition are optional but recommended. The comparison operators that can be used in a condition are: =, <>, >, =, <=. The operators compare for equality, inequality, greater than, less than, greater than or equal, and less than or equal respectively. 7

Lecture 4 – Making Decisions IF-THEN-ELSE-ENDIF Condition negation uses the NOT operator. Compound conditions can be constructed using AND, OR, and XOR operators: IF ((stall=0)AND(count<=10)) THEN PULSOUT RtMotor, 2400 PULSOUT LtMotor, 2400 ENDIF Note that an ELSE code block is optional and that multiple statements are permitted in a THEN (or ELSE) block. 8

Lecture 4 – Making Decisions IF-THEN-ELSE-ENDIF If the Scribbler gets stuck, you will normally want to take some action. This code shuts the motors down for two seconds: IF (stuck = 1) THEN PULSOUT RtMotor, 2000 PULSOUT LtMotor, 2000 FREQOUT SPEAKER, 500, 440 PAUSE 1500 ELSE PULSOUT RtMotor, 2600 PULSOUT LtMotor, 2600 ENDIF 9

Lecture 4 – Making Decisions Random Behavior To program random behavior, we need a random number generator. There is one built into the Scribbler: maxval CON 20'# 0 to 19 seed CON $AAAA'RNG seed dice VAR Word dice = seed DO RANDOM dice DEBUG DEC dice//maxval, CR PAUSE 500 LOOP 10

Lecture 4 – Making Decisions Random Behavior To use the RNG we must first seed the RNG variable. The RANDOM command will generate a new random number between 0 and 65,535 (since dice is word sized). A // is the remainder (or modulus operator), dice//20 will always return a number between 0 and

Lecture 4 – Making Decisions Assignment Program the Scribbler so that when it becomes stuck, it should back up a short, random distance, turn through a random angle and then proceed forward. When not stuck it should go forward in a straight line. Add LED flashes and sounds as desired... 12