Digital output

The output of this circuit goes high when the light level rises above a preset amount.

This circuit is used for the LDR light sensor of the Quester robot (p. 258). The output of the CA3148E swings close to the supply rails, providing a clear signal for the controller.

The Quester demonstrates another way of producing digital output. A CMOS logic gate changes state when input voltage levels are close to half the supply voltage. They act like a comparator with the reference voltage set at Vsupply/2.

GZjDl(D3)

GZjDl(D3)

Left channel indicated; Right channel in brackets.

Output to PIC TP1 (TP3) O

4011 yscio)]

Left channel indicated; Right channel in brackets.

4011 yscio)]

Inverted output to PIC

The circuit for the two IR probes of the Quester robot (p. 258).

The circuit uses CMOS NAND gates but could use NOR or INVERT gates instead. There are two IR probes and the component numbers of the second probe are shown in brackets.

Each probe has an IR LED (D1, D3) to illuminate the area beneath the probe. The reflected IR is detected by a pair of BP204 IR diodes. Note that the polarities of the two diodes are in opposite directions.

Detecting colours

A robot may be required to detect the colour of an object. For example, it may have the task of sorting building blocks of different colours. A simple way to do this is to illuminate the object with light from two or three different colours, one at a time. A single LDR light sensor measures the amount of light reflected from the object.

As a test run of the technique, small (30 mm) squares of coloured paper are illuminated by light from red, green and blue high-intensity LEDs. An LDR is exposed to the light reflected from these squares. The LDR is part of a circuit like that on p. 75, and the output voltage is sent to a comparator. With a suitable setting for its reference voltage, the comparator's output is read for each coloured paper and for each coloured LED. The output is 0 for low reflection or 1 for high reflection. Here are some typical readings:

Paper White Red Green Blue Black colour

Red LED 1110 1

Green LED 10 10 0

Blue LED 10 0 10

Each paper except for red and black produces a different response. If the PIC is programmed to flash each LED in turn, and to read the output from the comparator each time, the colours of the papers can be identified. Possibly the problem with black is that it is reflecting (or emitting?) infrared, to which the LDR is sensitive. Under green light, the red paper reflects less than black, so it is possible to distinguish these colours if a suitable reference voltage is used.

A light detector with memory

This circuit detects brief flashes of light. Although the PIC's interrupt facilities can respond to this sort of thing it is not necessarily convenient to have the program interrupted at an unpredictable time. This circuit allows the controller to poll its output to discover if a flash has occurred.

The light flash sensor is based on a phototransistor and a set-reset flip-flop.

The light flash sensor is based on a phototransistor and a set-reset flip-flop.

Q1 is a phototransistor, preferably of the Darlington type. When a flash of light is received, Q1 conducts for an instant and the voltage at its collector briefly falls. This low pulse is inverted by gate 1 and sent by the OP1 terminal to the controller. If the input channel is configured to 'interrupt on change', an interrupt is generated.

Gates 2 and 3 form a bistable flip-flop. Its state is changed by low-going pulse at its set or reset inputs. This part of the circuit is intended to detect a break in a beam of light that is normally falling on Q1. A break in the beam generates a high pulse, which is inverted by gate 1 and triggers the flip-flop to change state from reset (output OP2 low) to set (OP high). Once made high, it stays high until the flip-flop is reset. While it is in this state the controller polls OP2 at a suitable time or times. Later the controller sends a short low pulse to the reset input, which is normally held high. OP2 returns to low.

The response of the circuit is the opposite if the IC (quadruple NAND) is replaced with a 4001 or 74HC02 IC. These have quadruple NOR gates. OP1 goes high when there is a flash of light. The flip-flop is triggered when there is a flash of light and OP2, normally high, goes low. It stays low until the flip-flop is reset by a high pulse.

0 0

Post a comment