1 / 59

Light Sensors

Light Sensors. Light Sensors. Light Sensors or Dark Sensors?. Light sensors measure the amount of light impacting a photocell, photocell is basically a resistive sensor: the light effects the amount of resistance. The resistance of a photocell is low when it is brightly illuminated,

analise
Télécharger la présentation

Light Sensors

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Light Sensors

  2. Light Sensors

  3. Light Sensors or Dark Sensors? • Light sensors measure the amount of light impacting a photocell, • photocell is basically a resistive sensor: the light effects the amount of resistance. • The resistance of a photocell is low when it is brightly illuminated, • i.e., when it is very light; it is high when it is dark. • In that sense, a light sensor is really a "dark" sensor. • In setting up a photocell sensor, you will end up using the equations we learned above • you will need to deal with the relationship of the photocell resistance Rphoto, and the resistance and voltage in your electronics sensor circuit.

  4. What can be measured by Light Sensors? • Of course since you will be building the electronics and writing the program to measure and use the output of the light sensor, you can always manipulate it to make it simpler and more intuitive; • for example, most people invert the values, so low means dark and high means light. • You can also be clever about what you put around a light sensor, to affect its properties. • You can shield it and position it in various ways. • If you use multiple sensors, you can arrange them in useful configurations and isolate them from each other with shields. • Just like switches, light sensors can be used in many different ways: • Light sensors can measure: • light intensity (how light/dark it is) • differential intensity (difference between photocells) • break-beam (change/drop in intensity) • Light sensors can be shielded and focused in different ways • Their position and directionality on a robot can make a great deal of difference and impact

  5. Figure 5.6: Photocell Light Sensor • The photocell • is a special type of resistor which responds to light. • The more light hitting the photocell, the lower the resistance it has. • The output signal of the photo-cell is an analog voltage corresponding to the amount of light hitting the cell. • Higher values correspond to less light. • A photoresistor • changes its resistive value based on the amount of light that strikes it. • As the light hitting it increases, the resistive value decreases. • They are somewhat sensitive to heat, but stand up to abuse well. Try not to overheat when soldering wires to them. • Photocell versus photoresistor

  6. Photocells versus photoresistors • As with all the light-sensing devices, shielding is very important. A properly shielded sensor can make the difference between valid and invalid values reported by that sensor. • The idea is simple: restrict the amount of light striking the sensor to the direction you expect the light to be coming from. • You do not want light from external sources (i.e., camera ashes or spot lights) to interfere with your robot. • Black heat shrink tubing often works well to shield the photoresistor from external light sources.

  7. light-sensitive robot • One good way to get a feel for how these sensors work, and how your robot and software interact, is to make a light-sensitive robot. • With two or more photo-resistors, try to create a simple robot that can: • move around a room, • either avoiding light • or avoiding shadows in a controlled manner. • Ambient light conditions play a major role in how to interpret the data from any light sensors. • A combination of photocells,one pointed up and one pointed down, may be used to adjust for ambient light levels, which may be useful in some applications. These robots are easy to build and many high-school and undergraduate projects for wheeled robots were build

  8. Photoresistors are the simplest light sensors • Photoresistors are probably the only sensor required to be on your robot. • A starting light will be used to start each contest round, and the robot must be able to sense that light. This is for all wheeled robot contests. • You must place one photoresistor on the underside of your robot, probably near the center. • Be sure to shield it as much as possible from the overhead ambient light. • Write the starting code that reads the value of that sensor to start the match.

  9. Photoresistors are the simplest light sensors • Mounting the photoresistors doesn't tend to be difficult. • You can use a small amount of hot glue to attach the photocell to a LEGO brick, or double-sticky tape will also work. • Be inventive.

  10. Photo Transistors and Infra Red Light Emiting Diodes

  11. Photo Transistors • Phototransistors are usually tuned to a specific wavelength of light. • The wavelength is usually near visible red, or in the infrared spectrum. • They have similarproperties to the photoresistors. • The main difference is that the phototransistors are usually tuned to a specific wavelength.

  12. Photo Transistors • The other important difference is that the time delay for a change in light conditions is much smaller for a phototransistor. • This can be useful in doing fast controllooking for polarized light. • The time constant for a phototransistor is much smaller than a photoresistor, so it may be used in situations where timing is critical.

  13. Infra Red LEDs • An IR LED is a type of diode which emits radiation in the infrared range. • This part could be used as a component in a break beam sensor or a reflectance sensor. • We used two kinds of phototransistors, each of which are packaged in cylindrical brass-colored cans with a glass lens. • The first kind is packaged individually, with no wires attached, and with three leads. • The second is surplus parts, with wires already attached, and with each phototransistor paired with an LED. • (Note: surplus parts are usually overstocked or obsolete parts that didn't sell through retail channels. See the book's appendix on ordering electronics parts.) • The individual Phototransistors cost 6.270 about $1 each, about the same as an entire surplus assembly bundle of wires and phototransistors and LEDs.

  14. How to tell apartthe phototransistors from the LEDs: Figure 5.7: The LEDs • Be careful to differentiate the phototransistors from the LEDs: • the phototransistors have relatively flat lenses, • while the LEDS lenses are more convex. • Fig 5.7 shows one of the LEDs.

  15. How to tell apartthe phototransistors from the LEDs: • Also, the two different kinds of phototransistors (surplus vs virgin manufactured) have very different characteristics, and cannot be used in sensors interchangeably. • The surplus phototransistors respond almost exclusively to infrared light • They have a “resistance" of approximately 100 k when activated and 1 M when not activated. • The individual, un-wired phototransistors, on the other hand, respond to visible light as well as infrared, and have “resistances" about one hundred times smaller.

  16. Interfacing to the Board • These phototransistors require pull-up resistors, a resistor connected between Vcc and the signal line, to work properly. • In past years, all of these sensors required 47k pull-up resistors, but that is no longer the case. • Each individually packaged phototransistor now can be used with a 220k pull-up, while the “bundle of wires" phototransistors work well with 100k pull-ups. • This may present a slight problem if you have already installed RP6, one of the 47k pull-up resistor packs on your expansion boards. • Fear not! By installing the pull-up resistors on the connector as shown in Fig 5.8. • For the individually packaged phototransistors, the 2.2k resistor on the connector will be in parallel with the 47k pull-up on the board.

  17. Interfacing to the Board • Since resistors in parallel add reciprocally, the combination of the two will electrically look like a2.2k resistor (approximately). • However, if you have the “bundle of wires" phototransistors, you will have to cut a trace on the bottom side of the expansion board to disable the 47k pull-up resistor, since it would otherwise dominate. • Warning! Once you cut a trace, that analog port should be used only for the 220k phototransistors. • This means that you will have to be sure to plug these sensors into the correct analog ports each time you use them. • Ask me or a TA before you cut this trace!

  18. Visible Light sensor • The phototransistors respond very well to visible (far-red, we hypothesize) light as well as infrared. • They should be wired with a 2k to 4k resistor for best results (we recommend 2.2k). • Because they respond to visible light, they are extremely susceptible to interference from ambient light. • You may be able to use them as floor-color sensors using just ambient light. • But if you want to use them for break-beam sensing, they will have to be very well-shielded.

  19. Light Sensors • Light sensors are used to detect the presence and Intensity of light. • These can be used to make a light seeking robot and are often used to simulate insect intelligence in robots.

  20. Light Sensors CdS photocell (or other resistive sensor) Analog sensor -- Change resistance in response to light stimuli

  21. Shielding Photocell • Read photocell values: • while (1) { printf("%d\n", • analog(0)); • msleep(100L); • } • Mounting photocell through Lego beam makes it easier to attach to robot • Build optical shield to limit the amount of ambient light that is able to fall on the sensor Photocell Sensors with Light Shields Photocell Sensors Mounted on LEGO Technic Beam

  22. Single PhotocellLight Sensor Circuit Building light shields • After building the photocell and test that it works: (port 0) • while (1) { printf("%d\n", • analog(0)); • msleep(100L); • } • Mount the photocell’s leads through holes of a LEGO Technic beam, making a sensor device that can easily be positioned anywhere on the robot and subsequently reused • If your photocell easily floods from ambient room light, then the next order of business is to build an optical shield to limit the amount of ambient light that is able to fall on the sensor Photocell Sensors with Light Shields Photocell Sensors Mounted on LEGO Technic Beam

  23. Single PhotocellLight Sensor Circuit • Photocell element is connected to the circuit ground and the HB’s sensor input line via a voltage divider circuit • Vsens , resulting sensor voltage, varies as to the ratio between 47KW and Rphoto • When the photocell resistance is small (brightly illuminated), the Vsens ~= 0v • When the photocell resistance is large (dark), Vsens ~= +5 v • Continuously varying range between extremes • Sensor will report small values when brightly illuminated and large values in the dark • May invert the sense of the readings from the HB’s analog ports: • int light(int port) {return 255 - analog(port);} “dark sensor” Photocell Voltage Divider Circuit

  24. Differential PhotocellLight Sensor Circuit • Instead of comparing the single photocell to a fixed resistor value, the values of two photocells are compared to each other • Differential sensor provides a signal that can be directly interpreted to indicate which side of the sensor is receiving more light, and by how much • Rphoto2 = Rphoto1, Vout = 2.5 v • Rphoto2 << Rphoto1, Vout ~= +5 v (R2 more light) • Rphoto2 >> Rphoto1, Vout ~= gnd Ideal Photocell Sensor: Differential photocell sensor is constructed by wiring two like photocells in the voltage divider configuration

  25. Differential PhotocellLight Sensor Circuit Actual Differential Photocell Sensor Schematic • Considerations: • Use photocells with small dark resistance values, e.g., 10KW, Otherwise 47KW pull-up resistor on HB will bias sensor reading in the dark • Mount a “nose” between two sensor elements to cast shadow on one element if there is a distinct source of light off to the side

  26. Differential PhotocellLight Sensor Circuit Program tests the value of the differential light sensor to decide which way to turn If the value is less than 128, the program causes HandyBug to take a step to the left Otherwise, HandyBug takes a step to the right /* stepdiff.c - Light-Seeking Program for HandyBug */ int LEFT_MOTOR= 0; int RIGHT_MOTOR= 3; int DIFF_EYE= 0; void main() { while (1) { if (analog(DIFF_EYE) < 128) { /* turn to left */ motor(RIGHT_MOTOR, 100); sleep(0.1); off(RIGHT_MOTOR); } else { /* turn to right */ motor(LEFT_MOTOR, 100); sleep(0.1); off(LEFT_MOTOR); } } }

  27. Polarized light • "Normal" light emanating from a source is non-polarized, which means it (i.e., the light waves) travels at all orientations with respect to the horizon. • However, if we put a polarizing filter in front of a light source, only the light waves of a given orientation (i.e., the characteristic plane) of the filter will pass through. • This is useful because now we can manipulate this remaining light with other filters; • if we put it through another filter with the same characteristic plane, almost all of it will get through. • But if we use a perpendicular filter (one with a 90-degree relative characteristic angle), we will block all of the light. • You can use polarized light to make specialized sensors out of simple photocells; • if you put a filter in front of a light source (i.e., an emitter) and the same or a different filter in front of a photocell, you can cleverly manipulate what and how much light you detect. • Note that polarized light, like all other sensor types we have discussed today, has its equivalent in nature; many insects and birds use polarized light.

  28. Polarizing Film • Polarized film has printed or etched straight lines. • The polarizing film allows the light to travel in parallel perpendicular planes rather than in all directions. • Assume for this section that the lines are running up and down, and therefore the light waves will be traveling up and down. • If a second film is placed such that the lines are horizontal, the light traveling past the first filter will not pass through the second filter.

  29. Polarizing Film • Two pieces of film which are perpendicular to each other will block out most of the light. • Parallel pieces will allow maximum light to go through. • The Polarizing lm can be used to enhance the photo transistors and photo resistors. • The beacons at each end of the playing field are emitting polarized light. • One side is polarized at positive 45 degrees from the vertical and the other side is at negative 45 degrees. • You can detect the difference between one side and the other by placing a piece of polarizing lm in front of a phototransistor or photoresistor.

  30. Polarized Light Seeking for Light Sensor Circuits • Two opposing goals consists of a light box with light filter; one has the polarization filter aligned vertically, while the other has it aligned horizontally • If polarized light is passed through a filter at a right angle to the plane of polarization, it is completely blocked out • At angles in between the 0 - 90 deg, light passes through proportional to the ratio of the polarization angle • Using differential sensor with polarized shields makes it easy to tell if robot is pointed at a light beacon or not • Sensor readings above the midpoint indicate readings from one beacon and readings below the midpoint indicate readings from the other

  31. Polarized Light Seeking for Light Sensor Circuits • Robot employs a pair of photocells, one with a +45 deg rotation (right photocell) and one with a -45 deg rotation (left photocell). Depending on the polarization of the light source, either • light will pass equally through both photocells’ filters (no polarization) • be blocked in the left and transmitted in the right (+45 deg polarization) • be blocked in the right and transmitted in the left (-45deg polarization)

  32. Use of Light Sensors

  33. Two Thresholds for Hysteresis Line Following performance run : Setpoint =20 • Problem with single threshold – variances in sensor readings • Bump on floor may spike the readings • Shiny spots on line may reflect as well as the floor, dropping the sensor readings up into the range of the floor

  34. Figure 5.8: Phototransistorbody and connector

  35. Two Thresholds for Hysteresis Line Following performance run : Setpoint =20 • Solution: two setpoints can be used • Imposes hysteresis on the interpretation of sensor values, i.e., prior state of system (on/off line) affects system’s movement into a new state int LINE_SETPOINT= 35; int FLOOR_SETPOINT= 10; void waituntil_on_the_line() { while (line_sensor() < LINE_SETPOINT); } void waituntil_off_the_line() { while (line_sensor() > FLOOR_SETPOINT); }

  36. Light Sensor States • Using two sensors to keep track of one of four states: • Light-on-Left • Light-on-Right • Light-in-Center • No light • Options: • Use hysteresis on each sensor individually and combine values into single state • Combine sensor readings first and then apply hysteresis on resulting value • Try to maintain “light-in-center” state – make closed-loop motor changes when in other states

  37. Simple Feedback Control – Wall Following • Robot turns towards wall if distance sensor indicates too far away; turns away from wall if too close • Single threshold for “too far” and “too close” = goal variable You can use either bend sensor or reflective IR sensor

  38. Simple Feedback Control – Wall Following void main() { calibrate(); ix= 0; while (1) { int wall= analog(LEFT_WALL); printf("goal is %d; wall is %d\n", goal, wall); if (wall < goal) left(); /* too far from wall -- turn in */ else right(); /* turn away from wall */ data[ix++]= wall; /* take data sample */ msleep(100L); /* 10 iterations per second */ } }

  39. Hard Turns Control void left() { motor(RIGHT_MOTOR, 100); motor(LEFT_MOTOR, 0); } void right() { motor(LEFT_MOTOR, 100); motor(RIGHT_MOTOR, 0); } Hard turns • Results with bend sensor: • HandyBug oscillates around setpoint goal value • Never goes straight

  40. Soft Turns Control void left() { motor(RIGHT_MOTOR, 100); motor(LEFT_MOTOR, 50); } void right() { motor(LEFT_MOTOR, 100); motor(RIGHT_MOTOR, 50); } • Gentle Turning Algorithm: • Swings less abrupt • HandyBug completes run in 16 sec (vs. 19 sec in hard turn version) for same length course • In light following we want to include a go-straight function and a random-movement-to-find-light function as well

  41. Separate Sensor State Processing from Control Functions might each make use of other sensors and functions – need to decide how to implement each

  42. 5.5.7 Reflectance Sensors • A reflectance sensor is made up of a combination of an infrared or red LED and a phototransistor that is sensitive to the wavelength of light being emitted by the LED. • Over dark surfaces, the light is absorbed, whereas over light surfaces, the light is reflected back to the phototransistor. • A reflectance sensor (Figure 5.9) can be made using discrete components. • The reflectance sensors are useful for detecting what color the floor is. • They could also be used as object detectors, but they are very near sighted and quite responsive to outside lighting.

  43. 5.5.7 Reflectance Sensors • In any application, good shielding is an absolute requirement if any reliability is desired. • The sensors are very sensitive to distance from the reflecting surface. • Distances greater than an inch will give very poor reading, and distances that are too small will not allow the right to be reflected. • The angle at which the light is reflected to the surface is important and can produce better or worse results at different distances.

  44. 5.5.8 Motor-Force Sensors • There are four motor force sensors built into the 6.270 Controller board, attached to motors 0 through 3. • These sensors are included to detect when the motors might be stalled. • When the motors stall, they draw a large amount of current, which appears as a large voltage on the analog inputs to the 6811. • When a motor force value increases sharply, that's a good sign, but not guaranteed, that the motor may be stalled. • The value that it reaches will depend on the load attached to the motor. • Experiment by stalling the motor yourself while printing the values on the LCD to determine a threshold that's right for your robot. • Motor force values are not very accurate when you are driving the motors at anything less than 100%. • Driving the motors at lower speeds will cause the motor force value to oscillate wildly, so it is recommended that you only use this information when you are driving a motor at full speed.

  45. Modulation / Demodulation of Lightand Infra-Red Sensors

  46. Modulation and Demodulation of Light • We mentioned that ambient light is a problem because it interferes with the emitted light from a light sensor. • One way to get around this problem is to emit modulated light, i.e., to rapidly turn the emitter on and off. • Such a signal is much easier and more reliably detected by a demodulator, which is tuned to the particular frequency of the modulated light.

  47. Modulation and Demodulation of Light • Not surprisingly, a detector needs to sense several on-flashes in a row in order to detect a signal, i.e., to detect its frequency. • This is a small point, but it is important in writing demodulator code. • The idea of modulated IR light is commonly used; for example in household remote controls. • Modulated light sensors are generally more reliable than basic light sensors. • They can be used for the same purposes: • detecting the presence of an object • measuring the distance to a nearby object (clever electronics required, see your course notes)

  48. Infra Red (IR) Sensors • Infra red sensors are a type of light sensors, which function in the infra red part of the frequency spectrum. • IR sensors are active sensors: they consist of an emitter and a receiver. • IR sensors are used in the same ways that visible light sensors are: as break-beams and as reflectance sensors.

  49. Infra Red (IR) Sensors • IR is preferable to visible light in robotics (and other) applications. • This is because it suffers a bit less from ambient interference, • because it can be easily modulated, • because it is not visible.

  50. IR Communication • Modulated infra red can be used as a serial line for transmitting messages. • This is is fact how IR modems work. • Two basic methods exist: • bit frames (sampled in the middle of each bit; assumes all bits take the same amount of time to transmit) • bit intervals (more common in commercial use; sampled at the falling edge, duration of interval between sampling determines whether it's a 0 or 1) • Notes: • you are strongly encouraged to pay careful attention to the exercises and problems given in your assigned readings. • Projects, exams, homeworks and reports will use some of those, so it is in your interest to think about the answers to their questions, and work some of them out as practice. • Also the additional recitations (Fridays) problems may appear on the exams.

More Related