Файл: The quintessential PIC microcontroller (S. Katzen, 2000).pdf
ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 15.06.2025
Просмотров: 5273
Скачиваний: 0
11. One Byte at a Time 303
zone. An alternative approach would be to replace each zone’s 3-state bu er by a PIC. Each PIC would drive a 4-wire common bus back to the main base PIC. One wire can be used as a shared handshake line to signal the base that an intruder has been sensed at the zone indicated on the three data wires.
Show how a PIC16F84 could be configured as a Zone PIC paying particular attention to the usage of the single handshake line shared with all zones.
Would it be possible to reduce the number of wires to three? How could a local display be added to show which sensor has been set o ?
11.2 A certain PIC running at 20 MHz has its Port C connected to LEDs tied high through a 1 kΩ resistor and with a 300 pF capacitance to ground. All LEDs are o and the programmer attempts to turn on LED 7 and LED 0 as follows:
bcf |
PORTC,7 |
; |
Turn |
on |
LED7 |
bcf |
PORTC,0 |
; |
Turn |
on |
LED0 |
However, only LED 0 actually turns on. What is happening?
11.3A certain system needs to be able to both activate eight LEDs and to be able to read the state of up to eight normally-open (N.O.) push switches. It has been proposed that a single Port B might be able to combine these functions – the former when set to output, the latter when set to input. Can you devise a suitable circuit?
11.4A PIC-based reaction meter is to be designed to act as a crude bloodalcohol level indicator. The principle of the device is that a buzzer is sounded for 100 ms when the unseen tester closes his or her switch. The subject is to respond to the sound by immediately pressing his/her switch. An 8-LED barograph display is to indicate the passage of time by progressively illuminating an additional LED every 50 ms. The number of lit LEDs at the conclusion of the test is the reaction time in 50 ms steps.
Show how a PIC16F84 could be configured in hardware and software to read both switches and activate the eight LEDs and one buzzer.
11.5 The variation of logic 0 output voltage VOL against sink current IOL for the two extremes of the commercial temperature range is shown in Fig. 11.15. Using this graphical relationship determine the maximum value of series resistor to ensure a current of no less than 20 mA will
304 The Quintessential PIC Microcontroller
flow through an LED connected to +5 V, as shown in the diagram, for any temperature. With this value what will be the current be at −40◦C? You can assume that the conducting voltage across the LED is a constant 2 V.
+5 V |
|||
VOL |
IOL |
RB |
|
5 V |
|||
4 V |
|||
3 V |
|||
2 V |
|||
Min @ +85 C |
Max @ -40 C |
||
1 V |
|||
0 |
20 |
40 |
60 |
80 |
100 |
IOL (mA) |
Sink
Fig. 11.15 Low-level output voltage against sink current.
11.6Repeat the exercise of SAQ 11.4 but coding in C.
11.7Extend the digital comparator of Example 11.2 to compare two external digital bytes presented to a 28-pin footprint PIC, with byte P being input at Port B and Q at Port C.
11.8In a low-power wireless data logging system placing the PIC in its sleep mode will not a ect the current consumption of the radio transmitter. It is proposed to use a port pin to supply current to the transmitter and in way this auxillary circuitry can be switched on and o as necessary. Discuss.
CHAPTER 12
One Bit at a Time
Parallel data transmission is fast, with a minimum of software overhead. However, there are circumstances where its use is inappropriate; either because of the additional hardware cost (see Fig. 11.10 on page 287) or more commonly where the receivers are geographically distant, with the concomitant cost or non availability of multiple communication channels and their necessary interface hardware. In such situations data can be sent one bit at a time and assembled by the remote device into the original data bytes. In this manner a comparison can be made with the parallel port on a PC, commonly used for local peripherals, such as a printer, and the serial port frequently used with a modem to link into the internet via a single telephone line.
Smart bank |
||
.com |
||
VISA |
||
+5V |
||
RST |
||
CLK |
Serial I/O |
Hologram |
Embossing area |
DEBIT |
CARD |
Fig. 12.1 The smart card.
As an example, consider the smart cards in your wallet. Each card will have an embedded microcontroller, typically 8-bit, giving it its intelligence. Cost constraints are severe to give a manufacturing price of under $1, and a large component of this is accounted by the non corrosive gold-plated contacts via which the microcontroller is powered and clocked when in contact with the card reader. In order to keep the mechanical precision of the reader low and hence reliability high, the number of contacts must be minimized and pad size maximized.