18.11.2014 Views

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

• What power supplies are available to power the sensor? (+12V, +5V)<br />

<strong>The</strong> answers to these questions will help you narrow your choices as you research what’s<br />

available.<br />

On/off Sensors<br />

Using Sensors to Detect and Measure<br />

Sometimes, all you need to detect is the presence or absence of the sensed property. Some<br />

simple sensors act like switches, with a low resistance in the presence of the sensed property,<br />

and a high resistance in its absence.<br />

<strong>The</strong>re are many types of sensors that you can use in this way. A magnetic proximity sensor<br />

responds to the physical separation of the items connected to each of the switch elements.<br />

A vibration sensor responds to rapid motion. Both of these are often marketed as home-security<br />

devices for use on doors or windows, but you might come up with other uses for them.<br />

Another example is a mercury tilt switch, which uses a ball of liquid mercury as a conductor.<br />

<strong>The</strong> switch contacts open or close when the switch tilts and the mercury rolls to the opposite<br />

end of the switch. Figure 9-1 illustrates.<br />

Figure 9-2 shows two ways to detect the state of on/off sensors like these.<br />

Figure 9-2A is an unlatched input. When the resistance across the sensor is high, the pull-up<br />

resistor brings the input voltage high. When the sensor’s resistance is low, the input goes<br />

low.<br />

You can connect this circuit to any unused pin on an input port. If you use the 8052-BASIC’s<br />

INT1 input, you can use an ONEX1 statement to trigger a subroutine whenever the sensor<br />

detects the property in question. If you use an ordinary port input, reading the port bit will<br />

tell you the current state of the sensor.<br />

In Figure 9-2B, when the sensor switches from high to low resistance, a 74LS73 JK flip-flop<br />

stores the information as a high Q output, which your program can read at its leisure. After<br />

reading the input, strobing the CLR input low brings Q low again, until the next sensing event.<br />

<strong>The</strong> flip-flop “remembers” past events, so you don’t have to detect or respond to events as<br />

they happen.<br />

Figure 9-1. <strong>The</strong> tilt, or physical angle, of the mercury switch determines<br />

which of its three terminals connect.<br />

<strong>The</strong> <strong>Microcontroller</strong> <strong>Idea</strong> <strong>Book</strong> 155

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!