interfacing pic microcontrollers

Page 181

Else_IPM-BATES_ch007.qxd

6/29/2006

11:38 AM

Page 166

Interfacing PIC Microcontrollers

A specific type of op-amp is normally used for this type of application, which has an open collector output. The output transistor switching circuit has to be completed by an external pull-up (load) resistor. This allows the output switching voltage to be different from the comparator supply voltage, which is useful for interfacing circuits operating at, say, ⫹/⫺ 15 V or with a 24 V single supply, which must be connected to a TTL MCU input or output. The switching speed can be increased by using a lower value pull-up resistor, at the cost of higher power consumption. Some MCUs have comparator inputs built in, as a simple form of analogue input. Three types of comparator circuit are shown in Figure 7.13. The default chip type used here is the TLC339, a quad comparator.

Simple Comparator The comparator detects whether the input is above or below the reference voltage. The circuit shown (Figure 7.13 (a)) has a reference voltage of 2.5 V applied to the - terminal. As the input changes, the output switches at this voltage. The transfer characteristic shows the effect by plotting the output against the input voltage. The reference voltage can be changed as required, giving a different switching level. The output of the comparator is connected to an LED indicator in the load circuit, which is useful, but not essential. The open collector output provides sufficient output current to drive an LED (~10 mA), without any additional driver stage.

Trigger Comparator The output voltage in this circuit (Figure 7.13 (b)) is fed back to the ⫹ terminal to set the reference level, which changes depending on whether the output is high or low. The switching level therefore depends on the previous setting of the output. This gives two switching levels: the output switches at a higher voltage when increasing from low to high and at a lower voltage when decreasing from high to low. In the circuit shown, the LED circuit affects the switching level, and may be omitted. Notice that the input is applied to the − terminal, so the transfer characteristic is inverted. When identifying circuits, positive feedback indicates a comparator, or an oscillator. The trigger circuit is often incorporated into digital signal paths as it helps to reduce noise (unwanted high frequencies). In a simple TTL gate, noise on a slowly changing input signal might cause multiple transitions at the output; with a schmitt trigger input (as it is known), once the gate has changed state, it does not change back unless there is a relatively large change in the input in the opposite direction. The PIC MCU has schmitt trigger inputs on the port input buffers for improved noise immunity. 166


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.