5. A Close Look at Sensors

Robot Sensitivity Training Lesson #5: A robot can sense when you are mistaken.

In Chapter 1, “What Is a Robot, Anyway?,” we stated that the basic components of a robot are:

Image One or more sensors

Image One or more actuators

Image One or more end-effectors/environmental effectors

Image Controllers

Programming a robot’s sensors, actuators, and end-effectors using a microcontroller is what programming the robot is all about.

The sensors, actuators, and end-effectors are what make a robot interesting, capable of performing tasks, and able to interact with its environment. Each sensor gives the robot some kind of feedback from the environment. But let’s make sure we acknowledge the distinction between the “sense” and the “sensor.”

A sense is a specialized function of a mechanism that receives and perceives the consequence of a stimulus on a sense component. A sensor is the sense component, or device that responds to the physical stimulus in some way. It is the device that detects or measures a physical property of the environment and then produces output as a reading, measurement, reaction, or signal that the stimulus was received.

Human sensors are our eyes, ears, skin, and so on. Robots have sensors such as cameras and ultrasonic and infrared sensors, and they have access to many different types of sensors, maybe hundreds. A single robot can be equipped with as many sensors as its real estate permits, its microcontrollers can connect, and its power supply can support. Table 5.1 shows a list of many different kinds of sensing, and the human and robot sensors.

Image

Table 5.1 Human and Robot Sensors

A robot equipped with many types of sensors and actuators can perform all kinds of physical behaviors. Robots can simulate all kinds of abilities by combining sensors with actuators and devices.

What Do Sensors Sense?

Some sensors are transducers, devices that convert one form of energy to another. Transducers are used to sense different forms of energy such as

Image Magnetism

Image Movement

Image Force

Image Electrical signals

Image Radiant

Image Thermal

Transducer types can be used for input or output conversions depending on the type of signal or process being sensed or manipulated. Sensors are input devices that change a physical quantity into its corresponding electrical signal that is then mapped to a measurement. The physical quantity is normally nonelectrical.


Image Note

Many sound sensors are nothing more than a dynamic microphone that detects acoustic waves and then changes them to an electrical analog signal.


For example, a sound wave is a disturbance pattern caused by the movement of energy traveling through the air as it spreads out away from the source of the sound. A sound sensor is essentially a microphone that detects this form of energy.

The electrical signal is generated by the diaphragm, a thin sheet of metal that collects sound waves causing the magnets that surround the diaphragm to vibrate. The vibration of the magnets causes a metal wire coil that surrounds the magnets to vibrate too, inducing a current in the coil that is converted to the electrical signal. The sensor then produces a signal that quantifies the loudness or softness of that original sound wave. Figure 5.1 shows the sound sensor’s transformation of sound waves into an electrical signal measured in decibels.

Image

Figure 5.1 The sounds sensor’s transformation of sound waves

Sensors measure the different forms of energy that exist in the robot’s environment. Most of the time we are referring to the environment “outside” the robot, but there are sensors that measure the internal robot environment—the robot’s internal state—as well. These sensors are called proprioceptive. Gyroscopes, accelerometers, and compass sensors are all examples of proprioceptive sensors.


Image Note

A gyroscope can calculate the changes in orientation and the rotational motion or angular velocity measured in RPM (rotations per minute or degrees per second). Accelerometers measure the robot’s acceleration in units of meters per second squared or G-force. The compass sensor measures the earth’s magnetic field and calculates a magnetic heading that reflects the direction the robot is facing.


Sensors that measure the external environment as it interacts, intersects, or affects the robot are called exteroceptive sensors. The robot is the point of reference for these types of contact, proximity, or ranging sensors.


Image Note

Contact sensors are used to measure contact between the robot and some other object in the environment. Proximity sensors measure the distance to objects near (the robot) but not touching the robot sensor. Ultrasonic and optical sensors are examples of proximity sensors that use ultrasonic waves and light to measure the distance to an object.


Sensors that measure physical quantities in the environment such as surface temperature, pH levels in liquids, turbidity, air pressure, and magnetic fields are called environmental sensors. These quantities do not require the perspective of the robot. Figure 5.2 shows the different perspectives of the robot as it relates to proprioceptive, exteroceptive, proximity, and environmental sensors. Table 5.2 lists the types of sensors, a brief description, and examples.

Image

Figure 5.2 Robot sensor perspectives

Image

Table 5.2 Types of Robot Sensors

Analog and Digital Sensors

The type and the classification of a sensor gives you some insight into how the sensor works, what it measures, how it measures, and how it can be used. As transducers, sensors can be classified by the input signal that measures whether it is input from a proprioceptive, exteroceptive, or environmental sensor and by the output signals it produces.


Image Note

Analog and digital are the most basic sensor classifications that describe how a sensor measures. A digital sensor produces a noncontinuous discrete output signal, and an analog sensor creates a signal that has a continuous value. Analog sensors are meant to help convert real-world information that isn’t electrical. Both types of sensors’ output will be represented in a digital format recognizable by a processor. Some sensors do not directly turn their signals into digital signals but instead create an analog signal that is converted later.


Digital sensors produce values outputted as a single “bit” like a simple switch. When the switch is on, the circuit is closed and electricity flows through the circuit; when the switch is off, the circuit is open and electricity does not flow.

A switch is an example of a serial transmission that outputs a binary signal that has only two discrete states: 1 or 0 (ON or OFF). Bits can also be combined to produce a single byte output of n bits as a parallel transmission. An example of a digital sensor is the built-in optical incremental encoder. It outputs a relative position of the motor to the last position.

The encoder, coupled with a microcontroller and tachometer, measures the velocity and direction of the motor. The optical encoder detects the movement of the servo motor. We discuss the optical incremental encoders and servo motor in Chapter 6, “Programming the Robot’s Sensors.” A digital sensor also has embedded electronics, which directly process the signal inside the sensor. The data transmission is also digital, which means it is not sensitive to cable length, resistance, or impedance and is not influenced by electromagnetic noise. The digital sensor can also return multiple values that provide additional information about the reading.

Analog sensors simply produce the signal output, the voltage reading. That’s all. True analog sensors do not have an embedded chip, so digital conversion is performed outside the sensor. Analog sensors are more accurate because the original signal is represented with a higher resolution. But these signals can be easily affected by noise or degrade in transmission. Analog signals are also hard to use in calculations and comparisons. But there is data loss when converting analog to discrete values. Table 5.3 compares some of the attributes of digital and analog sensors.

Image

Table 5.3 Digital and Analog Sensor Attributes

Reading Analog and Digital Signals

Both digital and analog sensors produce a signal, and that signal is mapped to or interpreted as a reading or measurement. But what is a signal? How can a signal be mapped to a measurement?

First, a signal is a time-varying quantity that conveys some kind of information. This means a signal is a value that changes over time; it is not constant. So the time-varying quantity is a voltage changing over time or a current. These signals can be passed through wires or through the air using radio waves as with WiFi or Bluetooth.

An analog sensor creates a signal that has a continuous value, and digital sensors produce a discrete output. With an analog sensor, the value it produces is proportionate to the quantity being measured. Examples of analog sensors are

Image Temperature

Image Pressure/force

Image Speed/acceleration

Image Sound

Image Light

All these sensors measure analogous quantities that are naturally continuous. An analog signal can have a range of 0 V to 5 V (volts). No sound detected by a sound sensor would return an analog signal of 0 V, and the maximum sound detected would have a maximum of 5 V. Sound sensors detect signals of any value within that range. Figure 5.3 (a) shows an analog signal as a continuous signal between 0 V and 5V, continuously detecting changes in the signal over time. This signal is smooth and continuous. For the microprocessor in our robot controller to do anything with these readings such as compute values and perform comparisons between signals, the signal has to be converted to a digital signal by an analog-to-digital (A/D) converter. The A/D converter may reside on the microcontroller or be a part of the sensor. Converting the analog signal to discrete values is called quantization as shown in Figure 5.3 (b).

Image

Figure 5.3 (a) An analog signal as a continuous signal between 0V and 5V, and (b) the conversion of the analog signal into discrete values

The A/D converter divides that range into discrete values where the maximum number of volts is divided by the n bits of the converter. For example, the Arduino A/D converter is a 10-bit converter. This means 10 bits represent each signal in the sample. There is a 210 = 1023 discrete analog level. The voltage resolution divides the overall voltage measurement by the number of discrete values:

5V/ 1023 = .00488 V ≈ 4.8 mV

The voltage resolution is 4.8 mV (millivolts). Some A/D converters are 8 bits (28 = 256 discrete levels with a 19.4 mV), and others are 16-bit ADCs (216 = 65,535 discrete levels with 0.076295109 mV). The voltage resolution is the difference between the two readings. The lower the difference the more accurate the readings. The more bits the better the digitization of the original signal and a lower error.

Some digital sensors are really analog sensors with an A/D converter; true digital sensors generate a discrete signal. The sensor can output a range of values, but the value must increase in steps. Discrete signals typically have a stair-step appearance when they are graphed on chart as shown in Figure 5.4.

Image

Figure 5.4 A graphed chart with discrete signals

An example of a discrete sensor is a digital compass. It provides a current heading by sending a 9-bit value with a range from 0 to 359, that’s 360 possibilities.

The Output of a Sensor

An analog sensor produces an analog reading, which is the voltage of the signal converted to a digital value by the A/D converter. For example, what if a voltage reading was 4.38 V? What would the A/D converter return? To keep this simple and manageable, let’s say we are using a 3-bit converter. For a 3-bit converter, there would only be 8 discrete levels or 8 possible digital values and the voltage resolution would be

5V / 8 = .625 V

So after the sensor converts the analog reading, it returns a digital output of 111. We can make a table of the analog readings; it’s the binary representation in Table 5.4. As you can see, the ranges of analog signal readings are defined by the voltage resolution .625. The voltage reading of 4.38 V is in the range of 4.371 V to 5.00 V.

Image

Table 5.4 Analog Readings and Their Binary Representation

Decimal values can be calculated:

8 / 5 V = ADC Reading / Analog measured value

In this case:

8 / 5 V = ADC Reading / 4.38 V

( 8 / 5 V ) * 4.38 V = ADC Reading

7.008 = ADC Reading

This is equivalent to the binary to decimal conversion:

111 ≈ 7.008

Decimal values are mapped to values (such as colors) or value ranges interpreted (such as bright and dark light).

Where Readings Are Stored

The measurements of the sensor may be stored in a data structure depending on the API being used. A data structure may be necessary if multiple values are returned. As mentioned earlier, digital sensors may return multiple values. For example, a sensor detecting the color of an object may return RGB values in a single structure. A sensor may also provide additional information about the reading. A sensor that is to detect the location of the object may also capture its distance, color, and so on. These structures may also be stored in an array if the sensor can make multiple readings. In Chapter 6 we discuss that some sensors, such as an ultrasonic, can take a single reading or perform continuously. It has a mode that allows for continuous readings. An advanced ultrasonic sensor stores the distance of multiple objects within its range. Each reading is stored in an array. We discuss simple data types used to store values in Chapter 6.

Active and Passive Sensors

Active and passive sensors describe how the sensors make measurements and how they meet their power requirements. Passive sensors receive energy from their environment or from the object to be measured. Passive sensors have no effect on their surroundings or whatever they are measuring. This is especially useful when robots are to be inconspicuous in a given scenario. Passive sensors are considered nonintrusive and energy efficient.

Active sensors involve direct interaction with their environment. They make observations by emitting energy into the environment and therefore require a power source. They are less energy efficient but are more robust because they are less affected by the available energy sources.

Let’s contrast a passive infrared sensor (PIR) and an active ultrasonic sensor used for a robot object detection system. A PIR measures the infrared light that radiates off objects. The sensor detects when there is a change in the normal radiation. In Figure 5.5 (a), a robot enters the field of view of the sensor. The sensor is triggered because the robot breaks the continuous field. What the sensor detects is the disturbance. The sensor is passive because it does not emit an infrared beam; it just accepts the incoming radiation without any type of intervening.

Image

Figure 5.5 (a) A passive infrared sensor for object detection; (b) an ultrasonic sensor for object detection

An active sensor generates an electrical signal that changes the excitation signal by passing an electric current or pulse through the signal; the sensor measures the changes in the current that is reflected back. Using the active ultrasonic sensor for motion detection, sound waves are generated in the ultrasonic frequency range, typically 30 kilohertz to 50 kilohertz (kHz). The sensor emits cone-shaped sound waves in the 40 kHz frequency. This frequency is inaudible to people (which is 20 Hz to 20 kHz) and cannot pass through most objects.

The sensor listens to the sound that is reflected back off the objects in its field of view. The time it takes to transmit and then receive the reflected wave determines the distance to the object. So for a robot detection system, the ultrasonic sensor is continuously sending ultrasonic waves. If something is within the ultrasonic sensor’s field of view, the sound waves are reflected off the new object, returning a different reading as shown in Figure 5.5 (b).

Some sensors have an active and passive mode or active and passive versions of the sensor. A digital camera is an example of a device that has both an active and a passive mode. Figure 5.6 shows two images of a group of tin toy robots: (a) is an image taken in passive mode; (b) is the same image taken in active mode. A digital camera has an image sensor that converts optical images to electronic signals, right? In passive mode, the sensor uses the existing ambient light. As you see, the robots’ characteristics are not clear or illuminated in the low lighting. The image sensor records or captures the radiation provided in the environment.

Image

Figure 5.6 (a) Image taken in passive mode, (b) image taken in active mode

If there is not enough light, the user can select a flash or the camera detects there is not enough light and switches to an active mode where a flash is used. The flash is its own energy source that illuminates the field and records the radiation that is reflected (Figure 5.6 (b)). Now the robots are better lit and the characteristics can be seen. This is also how active and passive modes work for a light sensor. The passive mode measures the ambient light rather than the reflected light from the LED in active mode. In active mode the sensor emits its own light source, the LED, and measures the light that is reflected off the objects.


Image Note

There is an active version of the infrared sensor that works similarly to the ultrasonic sensor. It is the light version of the sound sensor. An active infrared sensor uses invisible light as opposed to high-frequency sound to scan an area. The light is reflected off the objects in the scan zone and detected by the receiver.


Table 5.5 lists examples of active and passive sensors along with a description of each.

Image

Table 5.5 Active and Passive Sensors

Sensor Interfacing with Microcontrollers

For these sensors to be of any use, they have to be connected to the microcontroller. There must be an interface for the sensors composed of an analog-to-digital converter for analog sensors and a bus interface communication protocol that transfers data between components inside a computer (like SPI, UART, or I2C). Sensors connect to the microcontroller via the serial port, the physical I/O connector that converts the data to a series of bits that flow over a single wire for transmission. A sensor plugs in to the serial port allowing for communication between the sensor and the microcontroller. Figure 5.7 shows three sensors plugged in to the EV3 microcontroller and sensors connected to the Arduino interface sensor shield used to connect magnetic and pH sensors.

Image

Figure 5.7 Three sensors plugged into the EV3 microcontroller and two sensors connected to the Arduino interface sensor shield

The microcontroller sends a signal to the sensor, and then the sensor sends a signal back to the microcontroller one bit at a time through the serial port. These signals are actually messages, and there are four types:

Image System

Image Command

Image Info

Image Data

The message is just part of the payload that may also include bits indicating the type of message and where the message starts or stops. The microcontroller can send a message composed of a command and info, and the sensor can send a message composed of data and info. Messages can be transferred through the serial port in two ways: asynchronously and synchronously. With each type of serial communication, there is a clock and a signal so communication can be coordinated. Each approach has a synchronization method that controls how and when the high or low, 1 or 0 bit is received.

With asynchronous data transfer, there is no common clock signal between the sender and receivers. The sender and the receiver agree on a data transfer speed (baud rate). The baud rate usually does not change until after the data transfer starts. Special bits are added to each word that are used to synchronize the sending and receiving units. There is a three-wire connection between the sensor and the microcontroller. The devices share a ground connection used as the reference point to measure voltage and two communication wires, one for transmitting data and the other for receiving data.

The UART (Universal Asynchronous Receiver-Transmitter) is an asynchronous serial communication. Your microcontroller and sensor may use this type of serial communication protocol (Arduino, Raspberry Pi, EV3, and a host of new EV3 sensors). Figure 5.8 shows a UART connection.

Image

Figure 5.8 The three-wire UART connection

UART has three wires: Tx is the transit wire, Rx is the receive wire, and GND is the ground wire. The transmit pin always transmits data, and the receive pin always receives data. Tx is connected to Rx, and Rx is connected to Tx.

I2C (Inter Integrated, I2 part, Circuit) is a synchronous serial communication protocol to connect low-speed devices (like A/D converters, I/O interfaces, and sensors) to microcontrollers. The bus interface has an SDA wire used for a data signal, and the SCL wire is used for a clock signal.


Image Note

With synchronous data transfer, both the sender and the receiver access the data according to the same clock with a special line for the clock signal. The microcontroller provides the clock signal to all the receivers in the synchronous data transfer. There is another line or wire for data transmission. When the clock pulses, a bit of data is transmitted. The sensors are made aware as to when to listen to the bits coming down the wire and when to ignore them.


The wires are bidirectional for sending and receiving data between sensors and devices. Devices on the I2C bus can be either masters or slaves. Masters initiate data transfers, and slaves react only to master requests. The current master dictates the speed of the clock that determines how fast the data will be transferred. But a slave device (sensor) can force the clock low at times to delay the master from sending data too fast or delay how fast it should prepare for transfer. There is no strict baud rate.

I2C is easy to use considering it can have more than one master or primary (usually the microcontroller) and an almost infinite number of slaves or secondaries (devices and/or sensors) utilizing the same bus by using an I/O/ port expander. Figure 5.9 shows the bus interface with one master and multiple slave devices.

Image

Figure 5.9 I2C bus interface with multiple slave devices

As mentioned earlier, a single robot can be equipped with as many sensors as its real estate permits, its microcontrollers can connect, and its power supply can support. This is one way it’s done. Using the I2C bus interface, more than 1,000 devices can be connected to the microcontroller. Table 5.6 shows some of the attributes of UART and I2C serial bus interfaces.

Image

Table 5.6 UART and I2C Serial Bus Interface Attributes

Attributes of Sensors

The attributes or characteristics of sensors describe things like the reading ranges, how long it takes the sensor to respond to a stimulus, its overall accuracy, and so on. What is its resolution and repeatability? With several sensors connected to the microcontroller, the voltage level and the power consumption have to be considered. That may determine how long an individual sensor is used or how long other sensors with a high power consumption are used.


Image Tip

Being aware of these attributes helps determine the sensor limitations and which sensors can be used to compensate for those limitations. These attributes can also assist in comparing the quality of sensors by different manufacturers.


Table 5.7, for example, compares compass sensors. The resolution could depend on the version of firmware in use. Comparing these characteristics helps in deciding which sensor will work the best for a robot scenario.

Image

Table 5.7 Compass Sensor Comparison

Sensors have a number of attributes listed in Table 5.8. The values for these attributes should be supplied by the manufacturer of the sensor as part of the documentation or datasheet, but not all manufacturers supply this level of technical information. There may be other information manufacturers feel is important to their customers. Most manufacturers supply accuracy, response time, range, and resolution, and they believe linearity and repeatability are not so important. But importance is relative and depends solely on the system and the scenario in which the sensors are used.

Image

Table 5.8 Sensor Attributes

Range and Resolution

Range and resolution are two of the most common attributes that people are interested in.

Range is the difference between the smallest and the largest outputs that a sensor can produce or the inputs in which the sensor can properly operate. These values can be absolute or a percent of the appropriate measurement.

For example, let’s compare the ranges for a few sensors. For the ultrasonic sensor, the output range is 0 cm to 255 cm because distance is being measured, and the output range for a compass is 0° to 360°. But for a light sensor, 0 to 1023 is returned to the microcontroller.

In a well-lit room, the darkest reading may be 478 and the brightest reading may be 891. In a dimly lit room, the darkest reading may be 194 and the brightest reading might be 445. So a scale is used where 0 is dark and 100 is brightest represented as a percentage. The sensor is calibrated to the light of that particular environment. So from the example, in the well-lit room, once calibrated, 478 will have a reading of 0, and 891 will have a reading of 100.

Resolution is the minimum step size within the measurement range of the sensor. For example, the resolution of the HiTechnic compass was 1° where the resolution of an ultrasonic sensor is 3 cm. The resolution affects the accuracy of the sensor.

Remember the voltage resolution? With a voltage resolution of .625, an accurate reading of .630, the decimal representation is closer to 000 than it is to 001. For an ultrasonic sensor, an accurate reading of 7.5 cm could not be represented.

Precision and Accuracy

Precision is the capacity of a sensor to give the same reading when repetitively measuring the same quantity under the same conditions. Precision implies agreement between successive readings and not the closeness to the true value, which is accuracy. Accuracy is the maximum difference that exists between the actual value and a new reading of the sensor. The difference between the true value and the new reading is the absolute or relative error:

Absolute Error = New Reading – True Value

Relative Error = Absolute Error / True Value


Image Note

The smaller the resolution the more accurate the sensor.


Precision and accuracy are actually unrelated to each other, meaning a sensor can be precise but not accurate. Precision is also as a synonym for the resolution of the measurement; for example, a measurement that can distinguish the difference between 0.01 and 0.02 is more precise (has a greater resolution) than one that can only tell the difference between 0.1 and 0.2 even though they may be equally accurate. So precision and resolution are also frequently abused. Figure 5.10 shows the various relationships between precision and accuracy.

Image

Figure 5.10 Relationship between precision and accuracy

Linearity

Linearity is the relationship between the input and output variations in analog sensor readings. Linearity can be used to predict the readings of the sensor (based on input), used to determine accuracy and measure error. If a sensor’s output is linear, any change in the input at any point within its range produces the same change in the output. The output is proportional to input over its entire range. The graph of the slope of output versus input would be a straight line.

For example, if the ratio of input to output is 1 to 1, if there is an increase in the input (the stimulus) of the sensor by two, that would be reflected in the output. Ideally, sensors are designed to be linear, but not all sensors are linear when it comes to actual values. Figure 5.11 (a) shows the ideal linear relationship between input and output and the measured curve of a fictitious sensor and where the maximum error occurs. Figure 5.11 (b) shows the linearity of an ultrasonic sensor.

Image

Figure 5.11 (a) Ideal linear relationship between input and output, and where the maximum error occurs for a fictitious sensor; (b) the linearity of an ultrasonic sensor

When measuring the distance to an object 2 cm to 64 cm from the sensor, using 63 samples, the average error was 1.079 cm. Often nonlinearity is specified by a percentage:

Nonlinearity (%) = ( Din(max) / Inf.s. ) * 100

where Din(max) is the maximum input deviation, and INf.s. is the maximum full-scale (f.s.) input. But the linearity of a sensor, like the ultrasonic sensor, depends on the conditions in which the readings were taken. A sensor should have linear readings in the best conditions. But if an environment is hostile to the performance of the sensor (for example, if there were multiple ultrasonic sensors transmitting sound waves at the same time) or the target object is not ideal (oddly shaped or odd position), the performance of the sensor will degrade and readings will not be linear.

Sensor Calibration

As mentioned earlier in this chapter, programming the robot’s sensors, actuators, and end-effectors using a microcontroller is what programming the robot is all about. The sensors along with the actuators and end-effectors are what make a robot interesting, capable of performing tasks, and able to interact with its environment.

We have discussed many types of sensors, what they measure, how they measure, and how well they measure. There are a lot of good sensors available to be used by robot enthusiasts to program an exceptional robotics system. But sensors are not perfect. And as we discuss actuators in Chapter 7, “Programming Motors and Servos,” we see that actuators are not perfect either. Many sensors are good enough right out of the box for many noncritical applications, but to achieve the best possible accuracy, precision, and so on, a sensor should be calibrated in the system where it will be used. There are several reasons why sensors may not perform as expected. Table 5.9 lists some of the issues.

Image

Table 5.9 Factors That Warrant Sensor Calibration


Image Note

What makes a sensor good is when a sensor has ideal values for all the attributes discussed earlier. When referring to accuracy, it is really a combination of precision, resolution, and calibration. Calibration is the method of improving the sensor’s performance by removing structural errors in the sensor readings or measurements. Structural errors are differences between a sensor’s expected output and its measured output.


These errors show up consistently every time a new measurement is taken. But any of these errors that are repeatable can be calculated during calibration, so that during actual use the measurements made by the sensor can be compensated in real-time to digitally remove any errors. If you have a sensor that gives you repeatable measurements with good resolution, it can be calibrated for accuracy.

Problems with Sensors

Sensors are manufactured devices, and two sensors from the same manufacturer may produce some slightly different readings due to errors in production. Sensors are also sensitive to environmental changes, such as heat, cold, shock, humidity, and so on, they may have been exposed to during storage, shipment, or assembly. This may ultimately show up as a change in a sensor’s responses. Some sensors can actually become worn over time, and their responses naturally change over time requiring periodic recalibration.

Also keep in mind that the sensor may be only one component of the robot’s measurement system. For example, with analog sensors, the ADC is also part of the measurement and is subject to variability. Light and color sensors can be affected by spectral distribution, ambient light, specular reflections, and the effectiveness of the LED. These factors are discussed in Chapter 6 in the section on programming color sensors.

End User Calibration Process

The manufacturer performs calibration on the sensor, of course. But as mentioned earlier, recalibration may be necessary. This is done by the end user to improve sensor measurement accuracy. A known value or way to accurately take a measurement is needed to perform the calibration. Table 5.10 lists the possible sources that can provide a standard reference to calibrate against.

Image

Table 5.10 Standard References for Calibration

Each sensor has a “characteristic curve.” This curve defines the sensor’s response to an input. The calibration process maps the sensor’s response to an ideal linear response. The best way to do this depends on the nature of the characteristic curve. If the characteristic curve is a simple offset, this means that the sensor output is higher or lower than the ideal output. Offsets are easy to correct with a single-point calibration. If the difference is a slope, this means that the sensor output changes at a different rate than the ideal. The two-point calibration process can correct differences in slope. Very few sensors have a completely linear characteristic curve. Some sensors are linear enough over the measurement range. But some sensors need complex calculations to linearize the output.

Calibration Methods

In this section we discuss two calibration methods:

Image One-point calibration

Image Two-point calibration

One-point calibration is the simplest kind of calibration and can be used as a “drift check” to detect changes in a response or when there is a deterioration of the performance of a sensor. One point can be used to correct sensor offset errors in these cases:

Image When only one measurement point is needed: If the sensor usage only needs a single-level accurate measurement, and there is no need to worry about the rest of the measurement range. For example, a robot is using an ultrasonic sensor to position itself 3 cm from a container.

Image When the sensor is known to be linear and have the correct slope over the desired measurement range: Calibrate one point in the measurement range and adjust the offset if it’s necessary.

To perform a one-point calibration, follow these steps:

1. Take a measurement with your sensor.

2. Compare the measurement with your reference standard.

3. Subtract the sensor reading from the reference reading to get the offset.

Offset = Reference_reading – Sensor_Reading

4. In the program, add the offset to every sensor reading to obtain the calibrated value.


Image Note

We used sensors from Venier, HiTechnic, WowWee, and the LEGO Mindstorms Robotic kit for this book. Although these are not industrial-strength sensors, they are pretty good for what we used them for. They are low cost and easy to use. Table 5.11 lists the sensors we used and their sources.

Image

Table 5.11 Sensors Used and Their Sources


For the example mentioned, to calibrate the ultrasonic sensor use a measuring tape for the reference standard. Position the robot exactly 3 cm from the container. Take a reading with the sensor. If the reading is not 3 cm but is 4 cm, then there is a –1 cm offset. Subtract 1 cm from every reading. This will work if the sensor has a linear characteristic curve and will be accurate over most of its range.

What’s Ahead?

In this chapter, we talked about the different types of sensors, how they work, and what they measure. In Chapter 6, we will discuss how to use and program sensors, namely the color, Pixy Vision, ultrasonic, and compass sensors.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset