A robot needs to be aware of what is happening in the world around it. That is why all our robots are equipped with several sensors linked to the controller. This section lists sensors that are often used in robotics.
Resistive sensors respond to changes in a quantity such as light or position and their response is a change in their resistance. A change in resistance is easily measured by passing a current through the sensor and generating a changing voltage which is sent to the controller. Usually the sensing circuit is a potential divider with the sensor as one of the resistances.
EMF sensors respond to changes in a given quantity by changing the EMF (electromotive force or, loosely, a voltage) that they produce. This is sent to the controller.
There is scope for ingenuity when using sensors. Shining a beam ahead of it, the Scooter (for example) has a light sensor to detect light reflected back to it by an object blocking the robot's path. The light sensor is being used as a proximity sensor.
The most commonly used light sensor in our robots is a light dependent resistor which, as its name implies is a resistive sensor. The resistance of a typical LDR, such as the ORP12, ranges from 1 MQ or more in darkness to about 80 Q in bright sunlight. Indoors, with indirect daylight or artificial illumination, their resistance is a few kilohms.
LDRs respond to light of most colours, with a peak response in the yellow. Of all the light sensors, the LDRs are the slowest and their response times are several tens or hundreds of milliseconds. Although this is seems quite fast to humans, the PIC works much faster than this. Programs may need a short delay to allow time for the LDR to catch up with it.
The potential divider (see drawing opposite) can have a fixed resistor, a variable resistor, or both. The variable resistor allows for setting the output voltage for any given light level. The total resistance should be in the same range as the average resistance of the LDR under the expected operating conditions.
As light increases the resistance of the LDR decreases and the voltage sent to the controller rises.
Another popular light sensor is the photodiode. The action of these depends on the fact that the leakage current when the diode is reverse biased varies with light intensity. The circuit is on p. 73. The leakage current is very small. In darkness it is only a few nanoamps and rises to about 1 mA in bright light. The resistor has a resistance of a few hundred thousand ohms, so the current generates a reasonable voltage across it. Often a 330 kQ resistor provides suitable output voltage. The output must be connected to a high impedance input so that the voltage is not pulled down. The PIC is a CMOS device so has high-impedance inputs.
A photodiode is generally more responsive to light from the red end of the spectrum. Some are specially sensitive to infrared. These are used with infrared LEDs for reading optical encoders (p. 84). They are employed as sensors in line-following robots because they are less subject to interference from external sources of visible light.
The response time of a photodiode is fast, generally a few hundred nanoseconds, so there are no problems with this.
A phototransistor (overleaf) has properties similar to those of a photodiode, though their response time is longer. They are connected in the same way as an npn transistor in a common-emitter amplifier. Phototransistors often lack a base terminal and, if present, the base is usually left unconnected.
Left: Some phototransistors have no base terminal. They are 2-terminal devices with collector and emitter.
The reason that a phototransistor can operate with a base current is that the light falling on the transistor releases a supply of electrons. These electrons act in the same way as a base current.
Phototransistors are often packaged with an amplifier circuit or a Darlington transistor output on the same chip for greater sensitivity. There are similar devices based on photodiodes.
The analogue output from a light sensor is usually processed by the PIC's in-built comparators but sometimes there are not enough of these, and in any case it is simpler to handle the triggering level in the hardware. This circuit uses an op amp comparator to convert the analogue output into digital.
The op amp has two inputs and there is no feedback, so the difference between the input voltages is multiplied by the open loop gain of the amplifier. The output swings very sharply from low to high when the voltage at pin 3 exceeds the voltage at pin 2.
The voltage at pin 3 is always half the supply. The voltage at pin 2 varies directly with light intensity. It is set by adjusting VR1 to bring it to half supply when the LDR is receiving light of the triggering intensity.
Was this article helpful?