Page 142 - The Definitive Guide to Building Java Robots
P. 142

Preston_5564C04.fm  Page 123  Wednesday, October 5, 2005  7:22 AM



                                                                                 CHAPTER 4  ■  SENSORS   123


                        Section Summary

                        This section showed three different orientation sensors (compasses) and the software to get
                        those readings to your PC. The three compasses discussed were the Devantech CMPS03 digital
                        compass, the PNI Corporation Vector 2X, and the Dinsmore 1490.
                            I created two Java classes and one BASIC Stamp program as described in the following
                        bullets:
                           • Compass.bs2: A BASIC Stamp program to get sensor readings from one of the three
                             compasses
                           • CompassStamp.java: A Java class that models the BASIC Stamp configuration connected to
                             the three compasses
                           • Compass.java: A single compass class that’s used to connect to the Devantech CMPS03
                             compass
                            I would recommend the Devantech compass because of its response time, accuracy, and
                        single I/O pin.
                            The next type of sensors will return logic data—either a true or a false.


                        4.2 Switch Sensors

                        The types of sensors I’ll talk about in this section return a logic high (3V to 5V) or low (< 1V) to
                        your microcontroller. The four examples I’ll use will be

                           • Bump Sensors: Great for letting you or your robot know if it’s hit something.
                           • Line Detectors: Excellent for following lines, or for us as encoders or boundary edge
                             detectors.
                           • Proximity Sensors: Great for letting you or your robot know if it’s close to something.
                           • Combination Switch Sensors: When you have more than one logical sensor you want to
                             return data from at the same time.
                            The first sensor pictured is the bump sensor, shown in Figure 4-11, in which we see the
                        Lynxmotion Bumper switch assembly kit. These are nice backups to proximity sensors because
                        sometimes nonmechanical sensors can return false readings or the delay time is too large for
                        the speed of your robot. For example, if your robot is traveling at 36 inches per second and you
                        read the sensor five times a second, the sensor resolution is 36/5 or about 7 inches. Double that
                        speed and it’s 14 inches.
   137   138   139   140   141   142   143   144   145   146   147