Ultra Sonic Rangers tell the robot how far
Ultra Sonic Rangers tell the robot how far away objects are. Light sensors measure light intensity. l And Part 1. Sensors for a robot Heat Sensors which measure temperature. Resistive Sensors gyroscopes tell the robot which direction is up. Touch sensors tell the robot when it bumps into something. 1. Resistive 2. Infra-red 3. Light 4. Sonar 5. Other Based on book by Fred Martin
The simplest possible use of sensors z The diagram serves to illustrate the general case of sensing a specific phenomenon. y In this case it is the presence or absence of light. z The sensor in this case is a photo-resistor. y When sufficient light strikes it, its internal resistance is reduced to several hundred Ohms. y When no light strikes it its resistance is typically several million Ohms. light Look to Radio-Shack stores Remember Breitenberg’s Vehicles?
6. Sensors z. In this chapter we will do: y. Tactile sensors / switches y. Shaft encoders y. A/D converters y. Infrared position sensitive devices (PSD) y. Digital cameras
Sensors z General Remarks y. There are millions of different sensor types y. You have to select the right one for your application and budget and read the specs y. Note: some sensors require input from the CPU as well z E. g. activation/deactivation, triggering data transfer, etc. y. Our scope here is more on interfacing sensors than on understanding the sensors themselves
Sensors z Typical Sensor Outputs y. Binary signal (0 or 1) y. Analog signal (e. g. 0. . 5 V) y. Timing signal (e. g. PWM) y. Serial link (RS 232 or USB) y. Parallel link z Examples y�� Tactile sensor y�� Inclinometer y�� Gyroscope y�� GPS Module y�� Digital Camera
What Is a Sensor? z Anything that detects the state of the environment. z For instance, we already used sensors in the Braitenberg vehicles. z Are the following, sensors? y. Positioning devices y. Encoders y. Vision y. Mine detectors (detector vs. sensor) The material presented in our textbook and here relates to Handy. Board, but the same principles are true for Robix, Lynxmotion, Lego, etc. Read the manuals.
What can a robot do without sensing? z. Simple Sensors · Can be used without much processing · Still require electronics (and connectors) · The basic electronics laws to know: · Ohm's law · combining resistance · dividing voltage Review from ECE 201
What you (and the robot) can do without sensors? z Close your eyes. Plug your ears. Hold your nose. Tie your hands behind your back. y Shut your mouth. Tie your shoelaces together. Spin yourself around a few times. z Now walk. How does it feel? That's exactly what your robot feels: nothing - without sensors. z You have been given many types of sensors that can be used in a variety of ways to give your robot information about the world around it. z We will explain each of the sensors you can find in the lab, how it works, what it's good for, and how to build it.
Biological Analogs z. All of the sensors we describe in this and next parts exist in biological systems · Touch/contact sensors with much more precision and complexity in all species (spiders? ) · Polarized light sensors in insects and birds · Bend/resistance receptors in muscles · and many more. . .
You have to understand sensors z Before we can teach you what sensors do, we need to make one point very clear: y. Sensors are not magical boxes. y. All information you get from sensors must be decoded by you, the human builder and programmer. z Sensors convert information about the environment into a form that can be used by the computer. y. The sensors that are on the robot can be related to sensors found in humans.
You have to understand sensors z These sensors convert information about the environment into neural code that your brain can understand: y Touch sensors embedded in your skin, y visual sensors in your retina, y and hair cells in your ears y Your brain needs to understand the neural code before you can react. y Since you will be programming the robot, you will need to understand the output of the sensors before you can program your robot to react to different stimuli. x. Learn about sensors in animals and think how to use this knowledge in your projects.
Some types of Sensors: z Ladar (laser distance and ranging) y. Time of flight y. Phase shift z Sonar z Radar z Infra-red z Light sensing z Heat sensing z Touch sensing
Sensors and their use z. Topics to be discussed: · What are sensors? I’m Mr. Sensitivity. . . · Types of sensors (many examples) · Sensor complexity · Signals -> symbols · Levels of processing · Poor and good design of perception · Biological perception and lessons · Sensor fusion Not every quarter
Gas Sensor Gyro Accelerometer Pendulum Resistive Tilt Sensors Metal Detector Piezo Bend Sensor Gieger-Muller Radiation Sensor Pyroelectric Detector UV Detector Resistive Bend Sensors Digital Infrared Ranging CDS Cell Resistive Light Sensor Pressure Switch Miniature Polaroid Sensor Limit Switch Touch Switch Mechanical Tilt Sensors IR Pin Diode IR Sensor w/lens Thyristor IR Reflection Sensor Magnetic Reed Switch IR Amplifier Sensor Hall Effect Magnetic Field Sensors Polaroid Sensor Board IRDA Transceiver Lite-On IR Remote Receiver Radio Shack Remote Receiver IR Modulator Receiver Solar Cell Compass Piezo Ultrasonic Transducers
What are the types of Sensors? z Active y send signal into environment and measure interaction of signal w/ environment xe. g. radar, sonar z Passive y record signals already present in environment xe. g. video cameras x. GPS z In past, most often we used sensing using the following: y Touch y Active Light y Passive Light z There are many more ways y (sound, heat, magnetic field, smell. . . ) In our lab we used infrared, light (photodiodes, phototransistors), compass, volt and amperometers, ions, p. H, magnetic, temperature, voice, sound, camera, sonars and of course all resistance based micro-switches and pads. .
Passive versus Active Sensors z All of the sensors that will be presented in this part are passive y in that the stimulus, i. e. , the physical property, they were measuring, comes from the environment. z In contrast, active sensors provide their own signal/stimulus (and thus typically require extra energy), and use its interaction with the environment as the property to be measured. z Active sensors include: y reflectance and break-beam infra-red (IR) sensors, y ultrasound sensors, y laser range finders, y and others. z They will be presented in next parts of this set of lectures.
How to Choose a Sensor? There are four main factors to consider in choosing a sensor. z Cost: y y y z Environment: y z there are many sensors that work well and predictably inside, but that choke and die outdoors. Range: y y y z sensors can be expensive you can buy cheap sensors but often without good documentation knowing main principles and experimentation is useful when you purchase such sensors (usually military old sensors) Most sensors work best over a certain range of distances. If something comes too close, they bottom out, and if something is too far, they cannot detect it. Choose a sensor that will detect obstacles in the range you need. Field of View: y y y depending upon what you are doing, you may want sensors that have a wider cone of detection. A wider “field of view” will cause more objects to be detected per sensor But it also will gives less information about where exactly an object is when one is detected. Tell our stories about sensors in lab as examples
Types of Sensors according to their purpose in a robot z Exteroceptive: deal with external world ywhere is something ? No experience yet yhow does is look ? (camera, laser range-finder) z Proprioceptive: deal with self ywhere are my hands ? (encoders, stretch receptors) yam I balanced ? (gyroscopes) z. Interoceptive ywhat is my thirst level ? (biochemical) ywhat is my battery charge ? (voltmeter)
Try to understand sensors practically z Take time to play with each of the sensors you find in the lab, especially in Lego, Lynxmotion and Robix kits. y Figure out how they work. y Look at the range of values they return. y Check under what conditions they give those values. y Look to code of previous students related to sensors. z The time you spend here will greatly ease your integration of hardware and software later. z The better you understand your sensors, the easier it will be for you to write intelligible control software that will make your robot appear intelligent. y So as you read about the sensors, you should assemble a bunch of sensors as shown in Webpages of previous classes.
There can be no feedback without sensors! Remember this!! z Sensors provide feedback to your program about the environment. y Feedback is important in any controlled situation. z So far, we were discussing mostly open-loop, or timed programs that simply follow a pattern y but have no real knowledge of the world. z Sensors can provide the feedback necessary to let a robot make decisions about how to act in its environment. y They will make these programs smarter. z The feedback mechanism is very important in an environment that is continually changing.
There can be no feedback without sensors z During the rounds of the contest, the objects on the playing field will be changing their location (i. e. , the other robot moves, the drawbridge closes, or you bump into a block). Robot soccer, robot theatre z We strongly encourage you to use closed-loop feedback design when planning and implementing your strategy. z There will be a smaller chance of random errors completely messing up your game if you use sensors wisely. z In addition to Braunl: y Read Chapter 6 of Martin about sensors. y Read Chapter 8 of Martin for more information on the control problems you may encounter.
Electric Sensors: digital
Example of Sensor Interfacing Handy Board’s Sensor Input Banks Each sensor ports provides three signals to the sensor: • +5 v power - middle row Handy Board has two banks for sensors: • Digital inputs, numbered 15 to 7 on the left • Analog inputs, numbered 6 to 0 on the right • Ground - lower row • Sensor signal line - upper row Not all sensors require +5 v power, e. g. , switches and photocells may be wired between sensor signal and ground lines
Location of Digital and Analog Ports on the Handy. Board z The digital ports on the main board are labeled from 0 -7. z There also four analog ports on the main board, but when you use the expansion board, the analog ports get remapped to the connectors on the right side of the expansion board. z The ports are all arranged in the same format. z The innermost row of pins are the signals, followed by a space, then microprocessor power, and finally on the outer side is the ground. This slide is of no interest this year. Reed documentation of your robot
Analog versus Digital Sensors z In all our robotics kits the sensors are digital or analog. z For instance, in Handy. Board, analog sensors can be plugged into the analog sensor ports, which return values between 0 and 255. z Digital sensors can be plugged into either the digital ports or the analog ports, but will always return either 0 or 1. ANALOG 0 =< x =< 255 DIGITAL 0 or 1 z Each type of sensor has its own unique uses. z Think about new uses, not shown in these slides and tell me your ideas. May be we will use them.
Figure 5. 1: Generic Digital Sensor Schematics.
z Digital inputs all have pull-up resistors connected to them as shown in Figure 5. 1. Digital Sensors z Digital switches are wired such that the sensor is wired across the signal pin and ground. y This means that when the digital sensors is closed, the signal is grounded or LOW. y When the switch is open, the signal pin outputs +5 V, or HIGH. z This value is INVERTED by software, so reading the digital port with the switch open returns 0, while reading the digital port with the switch closed returns 1. • With nothing plugged in, the value of a digital port should be 0. • Digital sensors can be used in the analog ports on the Controller board (such as 6. 270 board) as well • This relieves any restrictions the small number of digital inputs may cause.
Digital Sensors used in Analog Parts of the Handy. Board y In this board, for instance, the typical analog values for digital sensors are: x somewhat above 250 for an open switch, xand less than 20 for a closed switch. z When using the IC command, digital(port) {where port is an analog port number (i. e. , greater than 7)} : y the sensor value is compared to a threshold value, y and the command returns: x a 0 if the analog value is above threshold xor a 1 if the analog value is below it (remember the inversion of the actual signal that digital does? ). z This threshold's default value is 127, but it can be changed y (See the section on IC commands for information on this).
Digital Sensors used in Analog Ports z A good way to get digital information from an analog sensor is to plug the analog sensor into a analog port and call it with the digital(port) command. y For example, a reflectance sensor would return: x a 0 for black or xa 1 for white if read with the digital command - provided the threshold is properly set. z This can reduce some of the programming complexity by abstracting away the thresholding. z You should however experiment with the sensors to determine: y the range of thresholds you get y and under what conditions these thresholds are valid.
Analog sensors in digital ports? z. It is not recommended to plug analog sensors into digital ports. y. This is because the digital ports threshold to conventional logic levels which cannot be adjusted to suit each analog sensor. z. The valid analog readings may fall into the invalid range for digital logic. z. Read in book about some mountings and uses for some digital sensors in the 6. 270 kit.
Switch Sensors z Switches are perhaps the simplest sensors of all. z They work without processing, at the electronics (circuit) level. z Their general underlying principle is that of an open vs. closed circuit. z If a switch is open, no current can flow; y if it is closed, current can flow and be detected. z This simple principle can (and is) used in a wide variety of ways. Think about all possible uses of switch sensors in robot arms, mobile robots and robot-animals of various kinds
Switch Sensors z Switch sensors can be used in a variety of ways - recall which were already discussed and shown in lab. z You have seen many kinds of switches already; y button switches, y mouse switches, y key board keys, y phone keys, etc. One dollar switch z Go to Shops (like Wacky Willy or Tek Country) and you will find plenty of cheap industrial switches useful for your robot project Various Switches
What are the ways that Switch Sensors can be used? • Contact (touch) Sensing Various Switches –detect when the sensor has made physical contact with another object – triggers when a robot grabs an object; – contact of whiskers – a robot’s body runs into a wall, – a robot’s gripper closes around a cube • Limit Sensing: – triggers when a gripper is as open as it can be – a limit sensor detects when a mechanism has moved to the end of its range of travel, signaling that the motor should be turned off • Shaft Encoding: – an axle may be fitted with a contact switch that clicks once per revolution. –Software counts the clicks and determines the amount and speed of the axle’s rotation. –e. g. , triggers for each turn, allowing for counting rotations 1. Bumpers 2. Limit in robot arms 3. Shaft encoders
Use of Dip Switches on Robots z There are four dip switches on the Expansion Board 6. 270. z They can be used to select user program options during testing. y. One dip switch will be used in the starting code for the contest to determine the side your robot starts on and at which frequencies it transmits and receives the modulated IR. z They can also be useful for outside control of program parameters, like enabling certain functions or selecting programs to run. y. While these switches are connected to the analog port, they are really digital switches.
Analog Sensors and Thresholding z Analog sensors, such as photo-resistors, can tell you: y how far the sensor has bent, y or how much light is hitting the sensor. z They answer questions with more detail. y. Analog sensors, however can be converted to digital sensors using thresholding. z Instead of asking the question “How much is the sensor bent? ” you can ask the question: “Is the sensor bent more than half way? ” • The threshold can be determined by playing around with the specific sensor.
How to interface a Digital Sensor to Handy Board? Digital Inputs • Nine digital sensor ports connect to circuitry on the HB that interprets each sensor’s Vsens voltage as a digital true/false Vsens > 2. 5 v, signal is logic one Vsens < 2. 5 v, signal is logic zero • To connect switch to digital input circuit: – Wire between the sensor signal line and ground Similar to Robix Vsens
Sensor Interfacing to Digital Inputs • “normally open” switch – Switch is released: it is open, so there is no connection between the Vsensor line and ground. The 47 KW pull-up resistor on the HB then provides the default value of +5 v or logic one to the sensor input circuitry. – Switch is pressed: it connects the Vsensor line to ground, the zero volt level. Then the sensor input circuitry detects a logic zero reading. • Switch reading is inverted in software: digital()
Touch sensors Mostly using micro-switches
Normally closed Figure 5. 2: Microswitch Assemblies Normally open
Double Pull Micro-Switches z The two micro switches are double pull. z This means they can be wired so that when not depressed they: y return a one y or return a zero. z The only major difference is how you think about the device in your code. y Reading a sensor can be thought of as asking a question. y Here, the question could be, “Are you open? " or “Are you closed? " z If you wire the switch normally open, the answers are yes and no, respectively, y where they would be no and yes for a switch wired normally closed, y all for the same situation where the switch is not depressed.
Normally open and Normally closed switch z Depending on how you wire a switch, this switch can be: y normally open y or normally closed. z This would of course depend on: y your robot's electronics, y mechanics, y and its task. z The simplest yet extremely useful sensor for a robot is a "bump switch" y it tells when it's bumped into something, so robot can back up and turn away. z You'll find that even for such a simple idea, there are many different ways of implementation.
Switch Sensor Construction Pushbutton Switch Wiring Diagram Microswitch Normally Open Configuration Microswitch Normally Closed Configuration
Possible arrangements for touch switches z Touch switches should be wired in a normally open configuration y In such cases the signal line is brought to ground only when the switch is depressed. Normally open z In some cases, a slight advantage may result from one of these arrangements, because there may be a difference between the position where the open side makes contact and the closed side breaks contact. y When this is the case, the choice of normally open or normally closed will affect how sensitive the switch is to outside forces. y This can allow you to make a very touchy sensing device or help block out noise. z The small black switches with the white lever arm respond to a shorter arm movement when wired normally open y They require a little more movement to cause a transition in the normally closed configuration. Normally closed
Switch Sensors Switch Sensor Applications These are not standard touch sensors in Lego. You can add them inexpensively buying in standard hardware store rather than through Lego. Left- and Right-Hand Switch Construction Design for a Simple Touch Bumper
Micro-Switches as object detectors z The standard kit includes three types of small switches: y two micro switches y and a small push button. z These make great object detectors, y so long as you are only interested in answering the question, Am I touching something right now? with a yes or no. z This is often enough for responding to: y contact with a wall y or the other robot y or for actuator position sensing. z Using a switch for actuator position sensing (called a “limit" switch) can be a good way to protect drive mechanisms y which would self destruct when over driven.
Other uses of Micro-Switches in our robots z. Actuator position sensing: y. This could be handy for limiting the motion of: x hinged joints or x linear actuators y. This is done by requiring that a switch be open (or closed, depending upon the situation) before running the motor and monitoring it while things are moving. z They could also be used for extended user interface for testing and development purposes.
Bouncing and Debouncing of microswitches z Bouncing is a problem found in many switches. y At the point where the switch goes from open to close or vice versa, the output from the switch is very glitchy. y The switch may output several transitions. z Bounciness occurs especially when the switch is used in a sensitive mode. z One way to debounce the switch is to add a delay between samples of the digital input. y If the sampling is sparse enough, the bouncing section of the data will not be collected. Discuss debouncing using NAND latches and recall asynchronous state machines from ECE 271
Touch Sensors other than microswitches z. Whiskers, bumpers etc. ymechanical contact leads to xclosing/opening of a switch xchange in resistance of some element xchange in capacitance of some element xchange in spring tension x. . .
What are three types of sensing with touch? z Normally done to avoid collisions y. Avoiding is a lot better than Detecting z There are basically 3 forms y. Bumper Switch y. Whisker y. Pressure Pad
Bumper Switch z Mounted on the chassis of the robot z When plunger depressed collision is about to occur z Characteristics ysmall surface area ylow cost = low sensitivity
Use of Touch Sensor as Bumper
Bumper Example 1
Two other Bumper Design Examples Example 2 Example 3 Design for Bi-Directional Touch Bumper Design • rotational and sliding pivot points allow the bumper to react to pressure from any forward direction • can detect pressure from front or behind • movement in either direction pushes levered arm away from contact sensor • rubber bands pull arm back onto switch when pressure is released
Touch Sensors: bumper skirt • When the robot runs into a wall the bumper skirt hits a micro switch • which lets the robot controller know that the robot is up against a wall.
z. Extends sensing like a cat extends its sensing through its whiskers z. Care should be taken in determining things like Whiskers ylength yweight yshape • Cat whiskers measure space. If a whisker touches the cat knows that it will not be able to go through an opening as the whiskers define the size of entrance it is capable of moving through. Things like suspended ceiling wire, coffee sticks or tooth picks can all act as whiskers. They should not interfere with the actual sensing element.
Binary Sensors
6. 2. Encoder
Encoder z. Incremental encoder yusually requires 2 sensors to determine speed and direction ysee motor control z. Technology ymagnet + hall sensors (incremental) yoptical sensors with black/white segments (incremental)
Encoder • Encoder signal (2 lines) are connected to microcontroller like 2 binary sensors (digital input lines) • Microcontrollers usually have special internal registers for pulse counting z ⇒ This is done in parallel to normal calculations z Does not slow down the cpu
6. 5 Digital Sensors z. Digital sensors are y • usually more complex than analog sensors y • often more accurate than analog sensors y • sometimes are analog sensors with built-in A/D converters
Digital Sensors z Example: Sharp GP 2 D 02 • Available as digital or analog version (GP 2 D 05) • Versatile optical distance measurement sensor (requires reflective surfaces) • Uses infrared LED and light detector • Often called PSD (position sensitive device) • Measurement range 6 cm - 80 cm • Accuracy: about 1 cm
Digital Sensors
Digital Sensors
Digital Sensors
Digital Sensors
6. 6 PWM Sensors z. We have already seen PWM for: y • Velocity control for DC motors y • Position specification for servos z. Now we see PWM for: y • Sensor data y • Examples: x– Accelerometer x– Gyroscope x– Inclinometer
PWM Sensors
Today’s Laboratory z. The purpose of this lab is to expose your team to some of the sensors that you might use in your robot design. y Learn the basic operating principles of micro-switches and photo sensors (Cd. S cells). y. Write and run a program to control the speed and direction of an erector set motor using a microswitch and a Cd. S cell. y. Learn how to test the motor ports, analog ports, and digital ports of your Handy Board.
Procedure z. Connect the Handy Board to the computer using the interface board, phone cable, and serial cable provided. z. Run Interactive C on your computer. y. Follow the instructions to download pcode to your handy board. y. Select the file Handy_Board_1. 2. icd when prompted.
Procedure z Determine if your Handy Board is working correctly by loading and running the program "hbtest. c". z This program will allow you to check the motor ports, analog ports, digital ports, and the control knob. z Run the following subroutines (one at a time) by typing them at the bottom of the Interaction Window. xtestmotors ( ); xtestdigitals ( ); xtestanalogs ( );
DC Motor z Connect the motor to one of the motor ports.
DC Motor z. Write a program using the motor (int m, int p) command to turn the motor on and off, and to reverse its direction. y. Be sure that the motor has stopped before reversing its direction y. Use printf statements to show the status of the motor on the LCD screen.
Microswitch z Solder a microswitch to a twowire ribbon cable. z Trim a male header strip (use four pins only) and solder it to the other end of the ribbon cable (See figures on section 6 of the Handy Board Technical Reference. )
Microswitch z Connect the microswitch to a digital port. z Write a program that allows the motor to run while the microswitch is "not pressed" (switch open). z The motor should stop whenever the microswitch is "pressed" (switch closed). z Use printf statements to show the status of both the motor and the microswitch on the LCD screen.
Cd. S (Cadmium Sulfide) Cell z Plug a Cd. S cell directly to an analog port of the handyboard. z Write a command to print the output of the Cd. S cell on the LCD screen.
System to Sense and Control z Connect the DC motor, the microswitch, and the Cd. S cell to the Handy Board z Write a program that will continuously change the speed and direction of the motor based on the output of the Cd. S cell. y. Use the start button on the Handyboard to run the motor at a maximum power level of 100 in one direction. y. As you cover the Cd. S cell with your hand, the motor will slow down, stop, reverse its direction of rotation, and run at a power level of 100. y. The motor should stop whenever the microswitch is pressed (switch closed) or when the stop button is pressed.
System to Sense and Control z. NOTE: Make sure that each team member can operate the Handyboard including setup, initialization, connection of devices, operating the devices in command mode, writing code in IC, and operating the devices under program control.
Individual lab reports z Four pages maximum (including cover page, sketches, and attachments). z Cover page: title, name, section, team #, date, and professor. z Description of the lab procedure, problems encountered, and how problems were solved. z Include a sketch of the controller, motor, microswitch, and Cd. S cell connected. Use labels to indicate the ports used. z Include copies of the programs used for parts 5 and 6.
Some sources z. John T. Demel z. Students from previous 479
Questions for students 1. 2. 3. 4. 5. 6. 7. 8. 9. Present analog and digital robot sensors. Analog sensors based on measuring current or voltage. Examples and their use in a mobile robot. Role of sensors in feedback control of a robot. Examples. Analog sensors and digital sensors in analog and digital ports of the processor. Give examples. List all uses of microswitches in a robot. List all uses of Cadmium Sulfide Cells in a mobile robot. Encoders. PWM sensors. Describe a sensor system for a soccer team of robots.
- Slides: 80