lightbar and siren interface for the consolidated advanced ...

100
LIGHTBAR AND SIREN INTERFACE FOR THE CONSOLIDATED ADVANCED TECHNOLOGY FOR LAW ENFORCEMENT PROGRAM BY ANTHONY WHITESELL Bachelor’s of Science in Electrical Engineering, University of New Hampshire, 1997 THESIS Submitted to the University of New Hampshire in Partial Fulfillment of the Requirements for the Degree of Master of Science In Electrical Engineering September, 2001

Transcript of lightbar and siren interface for the consolidated advanced ...

LIGHTBAR AND SIREN INTERFACE FOR THE CONSOLIDATED ADVANCED TECHNOLOGY

FOR LAW ENFORCEMENT PROGRAM

BY

ANTHONY WHITESELL

Bachelor’s of Science in Electrical Engineering, University of New Hampshire, 1997

THESIS

Submitted to the University of New Hampshire

in Partial Fulfillment of

the Requirements for the Degree of

Master of Science

In

Electrical Engineering

September, 2001

This thesis has been examined and approved.

____________________________________ Thesis Director, Dr. W. Thomas Miller, III Professor of Electrical Engineering ____________________________________ Dr. William H. Lenharth Associate Research Professor of Electrical Engineering ____________________________________ Dr. John R. LaCourse Professor of Electrical Engineering ____________________________________ Date

iii

TABLE OF CONTENTS

DEDICATION ....................................................................................................................................................vi

ACKNOWLEDGEMENTS ..............................................................................................................................vii

LIST OF TABLES ..............................................................................................................................................viii

LIST OF FIGURES ............................................................................................................................................ix

ABSTRACT ........................................................................................................................................................xi

CHAPTER PAGE

INTRODUCTION..............................................................................................................................................1

I. HARDWARE DESIGN REQUIREMENTS.........................................................................................4

Hardware Requirements for the Control of the Lightbar.............................................................4

Hardware Requirements for the Muting of the Police Radio ......................................................4

Hardware Requirements for the Control of the Siren...................................................................5

II. HARDWARE DESIGN OF THE LIGHTBAR DRIVER...................................................................6

Original Hardware Operation ...........................................................................................................6

Theory of Operation ...........................................................................................................................6

Hardware Design ................................................................................................................................8

Alternate Designs................................................................................................................................11

III. HARDWARE DESIGN OF THE MUTING OF THE POLICE RADIO.........................................12

Original Hardware Operation ...........................................................................................................12

Theory of Operation ...........................................................................................................................12

Hardware Design ................................................................................................................................14

IV. HARDWARE DESIGN OF THE SIREN CONTROLLER................................................................16

Original Hardware Operation ...........................................................................................................16

iv

Theory of Operation ...........................................................................................................................16

Hardwa re Design ................................................................................................................................21

Software Design..................................................................................................................................25

V. INSTALLING THE HARDWARE.........................................................................................................29

Installing the Lightbar Driver ...........................................................................................................29

Installing the Radio Mute Box..........................................................................................................31

Installing the Siren Controller..........................................................................................................32

VI. SUMMARY AND RECOMMENDATIONS........................................................................................34

Summary ..............................................................................................................................................34

Recommendations for the Lightbar Driver.....................................................................................37

Recommendations for the Radio Mute Box...................................................................................37

Recommendations for the Siren Controller....................................................................................38

LIST OF REFERENCES ..................................................................................................................................39

APPENDICES.....................................................................................................................................................40

APPENDIX A: Allegro MicroSystems ULN2003A Data Sheet ................................................................41

APPENDIX B: Lightbar Driver .......................................................................................................................48

Complete Schematic ...........................................................................................................................48

Bill of Materials ..................................................................................................................................49

Printed Circuit Board-Top Side........................................................................................................50

Printed Circuit Board-Bottom Side..................................................................................................50

Printed Circuit Board-Silkscreen .....................................................................................................51

APPENDIX C: Police Radio Mute Box.........................................................................................................52

Complete Schematic ...........................................................................................................................52

Bill of Materials ..................................................................................................................................53

Printed Circuit Board-Top Side........................................................................................................55

Printed Circuit Board-Bottom Side..................................................................................................55

Printed Circuit Board-Silkscreen .....................................................................................................56

APPENDIX D: Siren Controller ......................................................................................................................57

v

Complete Schematic ...........................................................................................................................57

Bill of Materials ..................................................................................................................................58

Printed Circuit Board-Top Side........................................................................................................60

Printed Circuit Board-Bottom Side..................................................................................................60

Printed Circuit Board-Silkscreen .....................................................................................................61

Serial Tone Code Waveforms ...........................................................................................................62

Source Code-SIREN.H ......................................................................................................................65

Source Code-SIREN.C ......................................................................................................................66

APPENDIX E: Dallas Semiconductor Serial Shift Register Operation....................................................75

APPENDIX F: Microchip PIC Serial Shift Register Operation .................................................................88

vi

DEDICATION

I dedicate this thesis to my family and the Faculty of the Department of Electrical and Computer

Engineering at the University of New Hampshire, whom have always pushed me to do a little more.

vii

ACKNOWLEDGEMENT

I would like to acknowledge the entire Project 54 team. All the members of the team were a part

of this thesis. The hardware designed as part of this thesis was only one piece of the project.

viii

LIST OF TABLES

Table 2-1: Circuit Board Version 3: DB25 Connector Wiring...................................................................10

Table 4-1: Pin Out, Color Code, and Function of the Communications Cable Wires ............................17

Table 5-1: Lightbar Wiring and Command List............................................................................................29

ix

LIST OF FIGURES

Figure 1-1: Project 54 Hardware Connectivity..............................................................................................1

Figure 1-2: IDB Bus Connectivity...................................................................................................................2

Figure 2-1: Original Lightbar Wiring Diagram.............................................................................................6

Figure 2-2: IDB Controlled Lightbar Wiring Diagram................................................................................7

Figure 2-3: Schematic for a Single Channel of the Lightbar Driver..........................................................8

Figure 2-4: Alternative Design 1......................................................................................................................11

Figure 2-5: Alternative Design 2......................................................................................................................11

Figure 3-1: Original Police Radio Wiring Diagram......................................................................................12

Figure 3-2: Mute Box Implementation Diagram...........................................................................................13

Figure 3-3: Basic Schematic for the Mute Box.............................................................................................14

Figure 4-1: Original Siren Wiring Diagram...................................................................................................16

Figure 4-2: IDB Controlled Siren Diagram....................................................................................................18

Figure 4-3: Example Serial Tone Code Waveform.......................................................................................19

Figure 4-4: Pin 2 Wire Serial Signal at Time 1 .............................................................................................20

Figure 4-5: Pin 2Wire Serial Signal at Time 2 ..............................................................................................20

Figure 4-6: Siren Controller Block Diagram .................................................................................................21

Figure 4-7a: Version 1 Relay Structure with DPST Relays........................................................................24

Figure 4-7b: Version 1 Relay Structure with SPST Relays.........................................................................24

Figure 4-8a: Version 2 Relay Structure with DPST Relays........................................................................24

Figure 4-8b: Version 2 Relay Structure with SPST Relays.........................................................................24

Figure 4-9: Main Loop Flowchart ....................................................................................................................25

Figure 4-10: Detecting the Start Bit and Bit Sampling ................................................................................26

Figure 4-11: Sampling Complete, Determine the Bit Value .......................................................................26

Figure 4-12: Transmitting the Tone Code ......................................................................................................27

x

Figure 4-13: Reading Input Waveforms .........................................................................................................28

Figure 4-14: Sending Output Waveforms .......................................................................................................28

Figure 5-1: Lightbar Critical Test and Troubleshooting Points ..................................................................30

Figure 5-2: Radio Mute Box Critical Test and Troubleshooting Points....................................................31

Figure 5-3: Siren Controller Critical Test and Troubleshooting Points ....................................................33

Figure D-1: No Tone Waveform......................................................................................................................62

Figure D-2: Wail Waveform.............................................................................................................................62

Figure D-3: Yelp Waveform.............................................................................................................................63

Figure D-4: Piercer Waveform.........................................................................................................................63

Figure D-5: Horn Waveform............................................................................................................................64

Figure D-6: Manual Piercer Waveform..........................................................................................................64

xi

ABSTRACT

LIGHTBAR AND SIREN INTERFACE FOR THE CONSOLIDATED ADVANCED TECHNOLOGY

FOR LAW ENFORCEMENT PROGRAM

by

Anthony Whitesell

University of New Hampshire, September, 2001

The Consolidated Advanced Technology for Law Enforcement Program (Project 54) is a joint

effort between the University of New Hampshire and the New Hampshire State Police funded by the

United States Department of Justice to integrate embedded and wireless mobile technologies into the police

cruisers of New Hampshire State Troopers. This system allows the state troopers to have faster and more

complete information and makes the job of the New Hampshire State Troopers safer and easier. The on-

board system contains several high-tech components, including voice recognition and synthesis, touch

screen display, a global positioning system (GPS), and hands off control of much of the standard equipment

such as the lights, siren, and radar.

The police equipment on-board the cruiser is attached to the Intelligent Transportation Data Bus

(IDB) through IDB controllers developed by Project 54. The IDB Bus uses the Controller Area Network

(CAN) protocol to communicate between the IDB controllers. Interface hardware was designed to control

the on-board police equipment. The interface hardware controls the operation of the lights, the siren, and

the muting of the police radio. In the case of the lights and siren, the original system comes with a push

button control head. The interface hardware for the lights and siren is designed to work with or without the

control head. For better voice recognition by the on-board computer, the police radio volume is muted

without exceeding the load rating for the speaker output of the police radio.

1

INTRODUCTION

The Consolidated Advanced Technology for Law Enforcement Program

(CATlab) is a collaborative research and development effort between researchers and

staff at the University of New Hampshire and the New Hampshire Department of

Safety. The work involves integrating embedded mobile computing and wireless

technology into New Hampshire State Police Cruisers. The system will use voice recognition and synthesis

technology, as well as integration with in-car based electronics systems to offer advanced support for NH

State Troopers.

Using voice activation and integrated electronics will make police work conducted from the

cruiser easier, safer, and more complete. Officers will no longer have to look for knobs and buttons or

Figure 1-1 Project 54 Hardware Connectivity

2

reach out for controls, sometimes in the midst of a high-speed pursuit; allowing police officers to take an

"eyes off, hands off" approach to control a wide array of equipment, from flashing lights to background

checks on drivers they may be pursuing.

The equipment to be connected to the system includes the video camera and recorder, radar, global

positioning system (GPS), lights, siren, police radio, and the on-board computer. The on-board computer is

equipped with a keyboard, mouse, printer, touch screen display, a microphone to “hear” the voice

commands, a hard drive containing a copy of the Department of Motor Vehicles (DMV) database, and a

wireless network interface for sending and receiving updated DMV information. The majority of the

equipment that previously had to be easily accessible by the officer in the front of the cruiser can now be

hidden in the trunk of the car or elsewhere. The only items that are visible to the trooper while operating

the cruiser are the display, microphone, radar, and printer. The remainder of the equipment can be mounted

under the rear seat, in the trunk, or in an equipment console.

The backbone of the system is the Intelligent Transportation System Data Bus (IDB). The IDB

bus uses the Controller Area Network (CAN) protocol to communicate between the hardware on-board.

Each piece of equipment that is connected to the system is operated from the IDB bus by the on-board

computer. The IDB controller is responsible for the communication between the IDB bus and the attached

Figure 1-2 IDB Bus Connectivity

3

piece of equipment. If the equipment does not come with an IDB controller interface, an interface must be

designed. The lightbar, the siren, and the muting of the police radio to help with voice recognition all

needed an IDB controller interface designed before they could be integrated into the system.

For Project 54, I designed interfaces for the lightbar, police radio, and siren to allow them to be

controlled by the on-board computer by means of the IDB Bus and IDB controller. These hardware

designs were encompassed by a few overall design parameters. The first design parameter was the use of

off the shelf components. This allows the design to withstand the test of time. Off the shelf parts should be

fairly common, to the point where many people are using them. If the demand for a product is high enough

the product will continue to be made and sold. The second design parameter was to minimize cost. In

using the off the shelf parts the cost of the designs may be minimized because the parts are more common.

Using parts used by other designs within in the project allows for purchasing the components in higher

volumes, further reducing the price. The third design parameter was to keep the designs simple. Simple

designs are easier to build, maintain, and troubleshoot if necessary. Finally, the designs must use the IDB

controller developed for the project by Michael Martin, a senior electrical engineering student at the

University of New Hampshire. The IDB controller will be receiving the commands from the on-board

computer, interpreting them, and issuing them to the attached hardware. The attached hardware will then

control the connected piece of equipment, the lights, siren, or muting the police radio.

The remainder of this document covers the functionality and design requirements of the police

cruiser equipment, followed by the design and operation of the IDB interface hardware developed to

control the police cruiser equipment.

4

CHAPTER I

HARDWARE DESIGN REQUIREMENTS

Hardware Requirements for the Control of the Lightbar

It was decided by Dr. Thomas Miller and myself that the lightbar functions need to be controlled

from either the on-board computer or by the original control head, provided by Whelen Engineering

Company, Inc., without requiring both to be present in the system. This approach allows for the complete

removal of the control head and operation by just the computer without redesigning the circuit.

The design requirements for the lightbar driver include having standard TTL logic inputs for drive

by the IDB controller, a minimum of 5 output channels with outputs capable of supplying a minimum of

250mA at 12 volts. The installation manual for this model lightbar provides only the wiring information.

Beyond the wiring specifications, it is necessary to consult the installation manual for the control head for

the requirements to engage the different functions for the lightbar. The wiring specification designates the

relays as commonly grounded and +12 volts must be applied to an input in order to activate a function of

the lightbar. The +12 volt connections must have a current rating of at least 250mA, according to the

control head installation manual. This information set the design specifications for the circuit to be built.

The circuit must be able to engage five options individually: front flasher lights, rear flasher lights, rear

floodlights, front take down lights, and the wigwag headlights.

Hardware Requirements for the Muting of the Police Radio

It was decided by Dr. Thomas Miller and myself to mute the volume of the police radio when the

push to talk button for the voice activation of the on-board computer is depressed, so the comp uter can

more clearly understand the operator’s commands. The police radio contains a dash mounted 8 ohm 20

watt speaker. The muting level was determined by reducing the volume of the police radio from full

volume to a whisper. The design requirements include having standard TTL logic inputs for drive by the

IDB controller, the ability to mute the police radio from either the steering wheel mounted push to talk

5

button or the touch screen listen button, and not to exceed the 8 ohm load on the radio while reducing the

output volume of the speaker.

Hardware Requirements for the Control of the Siren

It was decided by Dr. Thomas Miller and myself that the siren functions need to be controlled

from either the on-board computer or by the original control head, provided by Whelen Engineering

Company, Inc., without requiring both to be present in the system. This approach allows for the complete

removal of the control head and operation by just the computer without redesigning the circuit.

The hardware design requirements for the siren controller include having standard TTL logic

inputs for drive by the IDB controller, the ability to select the tone code from either the control head or the

IDB bus, and the tone code from the control head has priority over the IDB bus tone code. The original

siren system has three components: the control head, the amplifier, and the siren speaker. The installation

manual provides detailed connection and wiring instructions, but no information on how the siren tones are

generated. Whelen Engineering was not willing to disclose the necessary proprietary information about the

operation of the tone generation and siren system. It was therefore necessary to reverse engineer the

original system, without the assistance of Whelen Engineering, in order to design the siren controller. It

was found that one of the cables connecting the control head to the amplifier, designated the

“communications cable”, contains three wires. Using an oscilloscope, it was determined that these wires

are the serial tone code and voice/PA signal, another serial signal, and ground. This information set the

design specifications for the circuit to be built. The serial tone code wire needs to be interpreted and

prioritized with the on-board computer signal, and an appropriate signal connected and sent to the

amplifier.

6

CHAPTER II

HARDWARE DESIGN OF THE LIGHTBAR DRIVER

Original Hardware Operation

The light bar functions are configured internally using a relay matrix. To activate a function of the

lightbar, turning on the front strobe lights for example, 12 volts must be applied to the attached control line

to close the appropriate relay. The control head accomplishes this through the use of switches. All of the

switches on one side are connected to 12 volts, and the other sides of the switches are to be connected to

the lightbar control lines.

Theory of Operation

The use of switches is the best selection activation by humans, but doesn’t work well for

activation by a computer. The design must meet the following requirements: (1) standard TTL logic input,

(2) capable of supplying a minimum of 250mA at 12 volts.

Figure 2-1 Original Lightbar Wiring Diagram

+12V

LightbarControl Head

+12V

7

Typically, in the automotive industry the chassis of the car is connected to ground, and therefore it

is logical for the relay circuitry in the lightbar to have a common ground and to be activated by applying a

positive voltage. Therefore the design of the lightbar driver became a design of a current source relay

driver with TTL logic inputs and 250mA outputs. The design of the lightbar relay driver began with an

industry search for a current source relay driver. Unfortunately, no current source relay drivers were found

commercially and a custom design was needed. All available relay drivers are designed to sink current, not

source current. It was decided to use a medium power PNP transistor to switch the relays on and off. In

order to meet the TTL logic input requirement, all of the various TTL logic gates were checked to see if

they would have enough output to drive the PNP transistor. Expecting an average gain of 10 from the PNP

transistor would require the driving chip to be able to sink at least 25mA. The TTL logic chips with

Figure 2-2 IDB Controlled Lightbar Wiring Diagra m

+12V

LightbarControl Head

+12V

LightbarController

IDBControllerIDB BUS

8

internal pull-up resistors could sink only 4-8mA and the open collector chips were as high as 20mA. The

current sinking relay drivers satisfied the TTL input requirement and had outputs capable of sinking more

than 100mA per channel. A pull up resistor on the current sinking relay driver will convert it from open

collector to logic levels, in this case 0 and 12 volts due to the automotive application and 12 volt relays.

From this, a proper size current limiting resistor is connected from the relay driver to the base of the

transistor. The emitter of the transistor is connected to 12 volts and the collector is the output. To protect

the circuit a large value resistor is connected from ground to the transistor’s collector, and a diode is

connected from the collector to the output of the circuit.

Hardware Design

Using a current sinking relay driver, the ULN2003A, allows for standard TTL logic to drive a

500mA current sinking output (see data sheet in Appendix A). A small pull-up resistor (4.7k ohms) is

connected to 12 volts from the ULN2003A output. Two ½ watt 5% 680 ohm resistors are connected in

parallel from the ULN2003A output to the base of a 2N4403. The two ½ watt resistors are used because

they are cheaper and more available than a single 1 watt 340 ohm resistor. As a side benefit of using two

Figure 2-3 Schematic for a Single Channel of the Lightbar Driver

+12V

IDBController

IDB BUS

Lightbar

+12V

100K

1N4148

3404.7K

ULN2003A

9

resistors in parallel of equal wattage and tolerance, the wattage rating doubles and the tolerance is reduced

by half. The result is a current limiting base resistor of 1 watt 2.5% 340 ohms. The 2N4403 PNP transistor

has the emitter connected to 12 volts and the collector used as the output. To protect the output, a small

signal diode (1N4148) is connected in series, and the collector of the 2N4403 is connected to ground

through a 100k resistor to insure the correct bias of the diode. This circuit is replicated once for each

lightbar function. Each of the lightbar functions are sequentially connected to a DB9 connector. Pin 9 of

the DB9 connector is used to connect to 12 volts to pull up the relays in the lightbar, the 2N4403 PNP

transistors, and to power the ULN2003A relay driver. For the schematic of a single channel see figure 2-3,

and for the complete schematic see Appendix B.

The printed circuit board for the lightbar driver is designed to fit inside the same enclosure as the

IDB controller. The enclosure, from Serpac Electronic Enclosures, has internal standoffs for circuit boards

and the use of these standoffs reduces the allowable board size and interferes with mounting D-sub

connectors through side of the enclosure. The standoffs that hold the cover on can be used to mount the

circuit board if their height is reduced by the thickness of the circuit board (typically 0.062 inches). The

overall board size is 4.1 inches wide by 3.0 inches high and fits exactly inside the Serpac enclosure.

Although the DB25 connector has a right angle footprint on the circuit board, the DB25 connector must

mounted to the enclosure rather than soldered directly to the circuit board and therefore must be solder cup

style and chassis mounted rather than right angle and board mounted. If the connector is soldered to the

board not enough of the connector will protrude through the side of the enclosure to mate with the

connector from the IDB controller. The use of the DB25 footprint on the circuit board eases the assembly

of the circuit because the connection from the circuit board to the connector is pin for pin.

The first version of the design used parts that were on hand and assembled on a piece of prototype

board. All resistors were ¼ watt and no output protection was implemented. In the second version of the

design, the 340 ohm ¼ watt resistors were changed to two 680 ohm ½ watt resistors in parallel and still

without output protection.

In the third version, the design took its final form. All of the resistors had their final values and

the output protection was imple mented. This version was fabricated by Alberta Printed Circuits. This

version of the printed circuit board had some design errors. The previous design revisions had five

10

channels available to control the lightbar because there are only five channels available from the IDB

controller; the third board design was erroneously designed with six channels. There were only five spaces

for the 680 ohm resistors on the printed circuit board instead of ten spaces. The holes for all of the resistors

and diodes were too small and the DB25 connector was not wired correctly. The D-sub connectors were

too far from the board edge to use right angle connectors soldered directly to the printed circuit board.

In order to use the printed circuit board for the third version of the design a few alterations needed

to be made. The resistor and diode holes were drilled out from 0.028 inches in diameter to 0.042 inches in

diameter and the 680 ohm resistors had to be placed in parallel manually. The extra sixth channel (the

channel closest to the ULN2003A) did not need components. Both of the DB9 and DB25 connectors had

to be chassis mounted and not mounted directly to the printed circuit board, and the DB25 connector had to

be wired as follows:

Table 2-1

Circuit Board Version 3: DB25 Connector Wiring

Printed Circuit Board DB25 Connector DB25 Connection

1 1 GND

2 Not Connected

3 6 RB3

4 3 RB6

6 2 RB7

15 10 RA5

16 4 RB5

The fourth version of the design was done to correct errors in the printed circuit board of the third version.

The geometries of the DB9 and DB25 connectors have been changed and their positions were updated.

There are ten spaces for the 680 ohm resistors, all of the diode and resistor holes have been enlarged, the

sixth channel has been eliminated, and the DB25 connector wiring has been corrected. In addition to the

above changes, the majority of the routing was moved from the top side to the bottom side of the circuit

board.

11

Alternate Designs

Two alternative designs were considered. The first design involved connecting the relay from the

lightbar and current sink relay driver in parallel and using a single pull up resistor. When the lightbar relay

was open, the relay driver would be in the off state and sinking 250mA, only half of its capability. When

the lightbar relay was closed and the lights flashing, the relay driver would be sinking no current. The

problem with the design is that the pull up resistor would need to limit the current to 250mA at 12volts,

requiring a 3 watt pull up resistor for each channel. Though easy to design and implement, because of the

size of the required resistors the design is not cost effective or practical. The second design would use a

current sink relay driver to switch relays to turn the lights on and off. The disadvantage of relays is they

have a limited number of times that they can be switched. Relays can carry much more current than

transistors and would be a feasible alternative if more current needs to be supplied.

48 ohm3 watt

ULN2003A

+12V

LightbarRelay

Figure 2-4 Alternative Design 1

ULN2003A

+12V

LightbarRelay

SPSTRelay

Figure 2-5 Alternative Design 2

12

CHAPTER III

HARDWARE DESIGN OF THE MUTING OF THE POLICE RADIO

Original Hardware Operation

The original police radio is manufactured by Motorola and comes with an external 8 ohm 20 watt

speaker designed to be mounted to the dashboard of the police cruiser. In order to speak to the on-board

computer, a push to talk button must be depressed. There are two push to talk buttons in the system, one on

the computer touch screen and one on the steering wheel. When either of the push to talk buttons are

depressed the police radio needs to be muted so that the voice commands can be better recognized.

Theory of Operation

The system design begins with the design criteria that the radio needs to be muted by either the

steering wheel mounted button or the touch screen button. It would be conceivable to use the push to talk

button to mute the radio directly because the push to talk button is nothing more than a switch.

Unfortunately, this method would not allow the touch screen push to talk button to mute the radio. The

steering wheel mounted push to talk button is connected to its own IDB controller in order to send the listen

command to the on-board computer. The push to talk button on the steering wheel uses only one of the five

available bits of the connected IDB controller. Therefore it’s possible to use the same IDB controller to

control the muting of the police radio and sense the push to talk button. The on-board computer can mute

the police radio because the IDB controller is in charge of muting the radio. When the steering wheel push

Police Radio

Figure 3-1 Original Police Radio Wiring Diagram

13

to talk button is depressed it will not generate any additional network traffic with the control of muting the

police radio in its own function within the IDB controller. The muting function must be callable from both

the IDB bus data interpretation routine and from the routine to sense the steering wheel push to talk button.

The steering wheel mounted push to talk button design has only one design consideration. In

order to minimize the cost and simplify the design, the push to talk button should be normally high because

the cruiser chassis is grounded. One side of the switch can be connected to ground close by and only run

one wire to the IDB controller mounted in the dashboard. When the steering wheel mounted push to talk

button is depressed, the button signal will change from logic 1 to logic 0 and the listen command will be

sent to the on-board computer and the police radio is muted until released. When the push to talk button on

the on-board computer is depressed, then the computer will send a mu te command to the IDB controller

instructing the controller to mute the radio. The radio will remain muted until the computer issues an

unmute command when the push to talk button is released.

The muting circuit maintains the nominal load impedance of 8 ohms, yet produces a volume level

low enough that it is noticeable to the operator if there is any radio traffic, but not audible enough to the

computer to be understood.

Police Radio Mute Box

IDB ControllerIDB BUS

Push toTalk Button

Figure 3-2 Mute Box Implementation Diagram

14

Hardware Design

The basic circuit to mute the police radio is shown in figure 3-3, and the complete circuit is in

Appendix C. The single pole, double throw (SPDT) relay selects where the incoming signal is routed. By

entering directly above the speaker, the police radio will be at full volume. The more than 250 ohms (two

510 ohm resistors in parallel and in series with 8 ohm resistor) is negligible when compared to the 8 ohm

speaker. By entering directly above the 8 ohm resistor, the police radio will be muted by the same

reasoning. The 8 ohm resistor must be of the same wattage as the speaker because it will be dissipating the

same power. The resistors used for the muting must be rated at least 5 watts each in order to dissipate the

power not required to drive the speaker at full volume. The circuit that performs muting is made of all

passive components. The relay and relay driver are the only active components in the circuit. The

connector from the IDB controller has a 5 volt supply from the its regulator. After evaluating the amount

of power required for the IDB controller and the amount of power remaining, it was determined that there

is not enough remaining to operate the relay driver, relay, and IDB controller from the same regulator. This

means a second power source is required. The IDB connector on the radio mute box is used for connection

to the 12 volt power supply for the IDB bus. The relay driver can handle up to 50 volts and the relays are

Figure 3-3 Basic Schematic for the Mute Box

PoliceRadio

IDBControllerIDB BUS

255 ohm10 watt8 ohm

20 watt

+12V

ULN2003A

15

available in 5, 12, and 24 volt versions. Using the 12 volt relay and the 12 volt IDB bus power supply

directly has the advantage of reducing component count by not using a second regulator and capacitors, but

it does use a second connection to the IDB bus.

The printed circuit board for the radio mute box is designed to fit inside the same enclosure as the

IDB controller. The enclosure, from Serpac Electronic Enclosures, has internal standoffs for circuit boards

and the use of these standoffs reduces the allowable board size and interferes with mounting D-sub

connectors through the sides of the enclosure. The standoffs that hold the cover on can be used to mount

the circuit board if their height is reduced by the thickness of the circuit board (typically 0.062 inches). The

overall board size is 4.1 inches wide by 3.0 inches high and fits exactly inside the Serpac enclosure.

Although the DB25 connector has a right angle footprint on the circuit board, the DB25 connector must be

mounted to the enclosure rather than soldered directly to the circuit board and therefore must be solder cup

chassis mounted rather than right angle board mounted. If the connector is soldered to the board not

enough of the connector will protrude through the enclosure to mate with the connector from the IDB

controller. The use of the DB25 footprint on the circuit board eases the assembly of the circuit because the

connection from the circuit board to the connector is pin for pin. There are three 2-wire connection points

on the circuit board. The first 2 are for the police radio input and output. The third connection point is for

the push to talk button. One side of the connection is ground, and the other is to sense the push to talk

button. It is supplied as a 2-wire connection point in the case that the mute box circuit is the most

convenient point to attach to the push to talk button to ground.

The first version of the design had a potentiometer in series with the 5 watt resistors to create a

muted volume control. This potentiometer was removed in the second version. The second version was

fabricated by Alberta Printed Circuits and had only one error to correct to be usable. The input to the relay

driver was connected to pin 6 of the DB25 connector instead of to pin 3. This wiring error was corrected in

the third version of the design. In both versions of the printed circuit board, all routing was done on just the

bottom side using 0.050 inch wide traces.

16

CHAPTER IV

HARDWARE DESIGN OF THE SIREN CONTROLLER

Original Hardware Operation

The original siren system was operated by a control head mounted on the dashboard, connected to

an audio amplifier (via the “communications cable”), which in turn is connected to the siren speaker.

Though the control head was the heart of the system, controlling both the light and siren functions. The

communications cable is the vital link in operating and controlling the siren tones.

Theory of Operation

The original siren system is designed and manufactured by Whelen Engineering Incorporated.

They were contacted for information on the operation of the tone generation and siren systems, but due to

the proprietary nature of the information it could not be released to aid in the design of the siren controller.

The siren system and tone generation would have to be reverse engineered in order to design the siren

controller. The information on the theory of operation of the original siren system was obtained completely

by the reverse engineering of the system. Through the reverse engineering of the original siren system, it

was discovered that the control head sends either a digital serial code for the desired tone or an analog

voice signal to the amplifier and the amplifier is simply a waveform generator with a high power output.

Figure 4-1 Original Siren Wiring Diagram

Control Head Amplifier

Communications Cable

17

The amplifier is connected to an 11 ohm 100 watt siren speaker via a two wire cable and the

control head is connected to the amplifier by means of a 3 wire “communications cable”. The function of

the wires of the communications cable are listed below:

Table 4-1

Pin Out, Color Code, and Function of the Communications Cable Wires

Pin Number Color Function

1 Black Ground

2 Green Unchanging Serial Signal

3 Red (from control head) or

Violet (from amplifier)

Serial Tone Code or PA

voice audio signal

The pin 3 carries the serial tone codes and also carries the PA audio signal. With the control head

and the IDB siren controller connected, the audio amplifier has three sources of input: an audio signal from

the control head, a serial tone code from the control head, and a tone code from the IDB controller. The

serial tone codes from the control head are intercepted, prioritized with the tone code from the IDB

controller, and sent to the audio amplifier by the siren controller. This reduces the set of possible inputs to

just two: audio signal or tone code. If no valid tone code has been received within the last tone code time

period then the siren controller assumes that the microphone button has been pressed and will not be

receiving any valid tone codes and directly connects the control head to the audio amplifier. Thus, in order

to inhibit the PA operation, it is necessary to repetitively send the “no tone” tone code to the amplifier.

In order to allow the on-board computer to control the siren tone, it was necessary to design an

interface circuit, the “siren controller”, to go between the IDB controller and the amplifier (see block

diagram in Figure 4-2). This siren controller must be able to reproduce the same tone codes as provided by

the control head. There are six tone codes available: no tone, wail, yelp, piercer, horn, and manual piercer.

The logic analyzer waveforms listed in Figures D-1 to D-6 of Appendix D show each of the serial tone

codes transmitted from the control head to the amplifier. Looking at figure 4-3 it can be seen that each the

tone code consists of one start bit, one stop bit, and 13 data bits. The code begins at marker ‘t’ and ends

18

approximately 30 milliseconds later with the 5 milliseconds of stop bits. Because of the unusual length of

the code (15 bits overall) the commercially available serial shift registers will not work. This necessitated

the use of the PIC to receive and interpret the codes from the control or IDB controller, and transmit the

correct code to the amplifier. The internal shift register of the PIC is designed to transmit one start bit, one

stop bit, and 8 data bits. This requires the serial receive shift register be implemented in the software of the

PIC. The operation of the shift register is derived from the operation of the hardware shift register of

Microchip’s PIC [MIC18-13] and of Dallas Semiconductor’s DS5000 operating in Mode 1 [DAL138].

Pin 2 of the control head connector carries a serial signal not in synchronization with the serial

tone codes or audio PA signals. Figures 4-4 and 4-5 show this unchanging serial signal (labeled

“UNKNOW” in the figures) at two different times and the changing time relationship to an incoming tone

code (labeled “BITIN”). After careful examination of the signal on pin 2, it is still unknown as to the

purpose of this signal. The siren system will still operate if the control head or the signal on pin 2 is

removed from the system.

Figure 4-2 IDB Controlled Siren Diagram

Control Head Amplifier

Communications Cable

Siren Controller

IDB ControllerIDB BUS

Black

Green

Red

Purple

19

Figure 4-3 Example Serial Tone Code Waveform

20

Figure 4-4 Pin 2 Serial Signal at Time 1

Figure 4-5 Pin 2 Serial Signal at Time 2

21

Hardware Design

The hardware design was approached from several aspects. One aspect was to use inexpensive off

the shelf devices. Another design criteria was to use parts that were already used in other designs in the

project. The microcontroller used is the same as in the IDB controller, the Microchip PIC 16F876. The

switching matrix for connecting the various signals to the amplifier must be designed so that each signal

passes undistorted; relays were the best and simplest choice. The ULN2003 relay driver was used to enable

the PIC to switch the relays. The incoming signal from the control head and outgoing signal to the

amplifier need to be buffered so the PIC does not drive either directly. A 7407 open-collector non-

inverting buffer was used. The open collector feature allows for the current drive to be changed by

changing the value of a pull-up resistor. Based on the design criteria, the block diagram in Figure 4-6 was

generated.

Figure 4-6 Siren Controller Block Diagram

+12V

IDBControllerIDB BUS

AmplifierControlHead

Communications Cable

+5

PIC Microcontroller

5V Regulator

+5

Relay Matrix

22

The communications cable contains three wires. The pin 1 is the system ground, pin 2 carries the

unchanging serial signal (figures 4-4 and 4-5), and pin 3 carries the serial tone codes and voice/PA signals

to the amplifier. The system ground must be connected to the ground of the IDB Bus. In the car this

should happen naturally, but on the bench it may have to be connected manually. The serial signal on pin2

is connected uninterrupted from the control head to the amplifier. Pin 3, carrying the serial tone codes and

voice/PA signals, needs to be cut and connected to the siren controller.

To power the siren controller a connection must be made to the 12 volt power supply from the

IDB bus. The DB25 connector from the IDB controller has a 5 volt supply from its regulator. After

evaluating the amount of power required for the IDB controller and the amount of power remaining, it was

determined that there is not enough power remaining to operate a second board of the same size from the

same regulator. The IDB connector on the siren controller is used for connection to the 12 volt power

supply for the IDB bus. The relays and relay driver are powered directly from the IDB bus power supply

so as not to add additional load to the 5 volt regulator. The relays come in a 12 volt version, and the relay

driver can handle up to 50 volts. The debugging LEDs used in conjunction with the DPST relays are also

powered directly from the 12 volt power supply. For the complete schematic see Appendix D.

The printed circuit board for the siren controller is designed to fit inside the same enclosure as the

IDB controller. The enclosure, from Serpac Electronic Enclosures, has internal standoffs for circuit boards;

the use of these standoffs reduces the allowable board size and interferes with mo unting D-sub connectors

through the sides of the enclosure. The standoffs that hold the cover on can be used to mount the circuit

board if their height is reduced by the thickness of the circuit board (typically 0.062 inches). The overall

board size is 4.1 inches wide by 3.0 inches high and fits exactly inside the Serpac enclosure. Although the

DB25 connector has a right angle footprint on the circuit board, the DB25 connector be must mounted to

the enclosure rather than soldered directly to the circuit board and therefore must be solder cup chassis

mounted rather than right angle board mounted. If the connector is soldered to the board not enough of the

connector will protrude through the enclosure to mate with the connector from the IDB controller. The use

of the DB25 footprint on the circuit board eases the assembly of the circuit because the connection from the

circuit board to the connector is pin for pin.

23

The first version of the board was sent for fabrication by Alberta Printed Circuits and had several

errors. The relays lacked a connection to 12 volts and the all holes for the resistors were too small. Both of

the D-sub connectors were too far from the board edge to use right angle connectors soldered directly to the

printed circuit board. The prototype utilized DPST relays to aid in debugging as in figure 4-13a. One pole

of the relay was used to switch the signal going to the amplifier, and the other pole was used to turn an

LED on and off. The idea was to provide a position for an LED but not to require it in the final design.

This concept allowed for SPST relays to be used in the final design, instead of the more expensive DPST

relays with LEDs and current limiting resistors. Unfortunately, the design was not done properly and in the

first version of the board DPST relays had to be used at all times. If SPST relays were used in this version

then the switched signal on the first pole would be shorted to 5 volts through a 4.7k ohm resistor on the

second pole (see Figure 4-7b). This was corrected in the second version of the board (see figures 4-8a and

4-8b), along with enlarging the resistor hole sizes, and updating the DB9 and DB25 geometries and

placement. In the second version of the board a jumper was added to optionally connect and dis connect the

grounds of the siren control head and amplifier and the IDB Bus. In addition to the above changes, the

majority of the routing was moved from the top side to the bottom side of the circuit board.

24

Figure 4-8a Version 2 Relay Structure

With DPST Relays

DPSTRelay

+12V

ToAmplifier

InputSignal

Figure 4-8b Version 2 Relay Structure

With SPST Relays

SPSTRelay

+12V

ToAmplifier

InputSignal

Figure 4-7a Version 1 Relay Structure

With DPST Relays

DPSTRelay

+5V

ToAmplifier

InputSignal

Figure 4-7b Version 1 Relay Structure

With SPST Relays

SPSTRelay

+5V

ToAmplifier

InputSignal

25

Software Design

The software for the PIC microcontroller is entirely interrupt driven, the main loop does very little.

The interrupt service routine (ISR) performs three major functions. The ISR is responsible for detecting the

falling edge of the start bit from the control head. The ISR is also responsible for determining the incoming

tone code and for sending the selected the tone code to the amplifier.

As mentioned, the main loop of the software does very little.

The main loop counts from 0 to 255 and repeats, inverting an output pin

each time it restarts the loop as shown in Figure 4-9.

Receiving a tone code begins by detecting the falling edge of

the start bit as shown in Figure 4-10. When the falling edge has been

detected, the receive clock (Timer0) starts and runs 10 times faster than

the incoming data rate. The detection of the start bit also clears the

receive buffer to store the incoming tone code, an unsigned integer (16

bit) variable called “received_tone_code”. The incoming signal is

sampled on receive clock counts 4, 5, and 6. When the receive clock

count reaches 10, all samples of the current bit have been made and the

count is reset to sample the next bit.

As outlined in Figure 4-11, once the sampling is complete a majority vote is taken of the three

samples to determine the bit value, 0 or 1. If there are 0 or 1 1’s the bit is a 0, and if there are 2 or 3 1’s

then the bit is a 1. This bit is shifted into the least significant bit (LSB) of received_tone_code. After the

stop bit is received, two additional 1’s are shifted into received_tone_code to look like the 15 bit long codes

that are transmitted. The variable received_tone_code is compared to the list of valid tone codes to

determine which code was received.

A second transmit clock (Timer1), runs at the data rate all of the time to shift out the selected tone

code. The selected tone code comes from either the control head (in the variable received_tone_code) or

from the IDB controller. The next bit of the selected tone code is shifted out each time the transmit clock

times out. When the selected tone code has been shifted out completely, the next tone code is determined

and shifted out as shown in Figure 4-12.

heartbeat=0

Output pinRC0=0

Increment untilheartbeat=255

Invert RC0

heartbeat=255

Figure 4-9Main Loop Flowchart

26

The tone code from the control head, if attached, has priority over the IDB controller tone code.

If the control head is asking for tone 2 and the IDB controller is asking for tone 3, tone 2 will be sent to the

amplifier. If the control head is asking for no tone, and the IDB controller is asking for tone 3, tone 3 will

be sent to the amplifier.

Wait for falling edge ofincoming signal

Wait for Timer0

Restart Timer0

Falling edge detected

Timer0 time out

Incrementtimeout counter

If count=

sample1=incomingsignal4

sample2=incomingsignal5

sample3=incomingsignal6

10

1, 2, 3, 7, 8, 9

SamplingComplete

Figure 4-10Detecting the Start Bit and Bit Sampling

SamplingComplete

IfSample1 +Sample2 +Sample3 =

0 or 1

2 or 3

Received Bit=0

Received Bit=1

Incrementreceived_bit

counterIf count=

1 to 12

13

Restart Timer0to sample next bit

All bits received

Shift Received Bit into LSB ofreceived_tone_code

Figure 4-11Sampling Complete, Determine the Bit Value

27

The extra I/O pins of the microcontroller

were used to indicate various states and counts of the

routines to verify and display proper operation of the

receive and transmit routines. Figure 4-13 shows the

reception of the tone code from the control head.

Each time SEARCH switches state (high to low or low

to high) it indicates that the search has begun for the

falling edge of the start bit. The falling of the start bit

occurs at the time marker ‘t’. At this time, BITIN (the

serial tone code from the control head) has made a

high to low transition, and WORDIN goes high to

show that sampling of the BITIN line will begin, and

timer0 (TMR0) is reset. On each transition of the

TMR0 line the receive sample counter is incremented.

On counts 4, 5, and 6 a sample of BITIN is taken, and

on count 10 the bit value is determined. Each time a

bit value is determined, the NEXT line is toggled and

the bit value is displayed on the ADDBIT trace. At

the conclusion of the reception of the tone code, WORDIN goes low to indicate the sampling has ended and

SEARCH is inverted to show that the search has begun for the next start bit.

Sending the selected waveform is shown in Figure 4-14. The marker ‘t’ is at an irrelevant falling

edge of the BITIN line. The traces BIT1, BIT2, and BIT3 show the tone code selected by the IDB

controller. In this case they are all low and the IDB controller has selected tone 0, while the control head

has selected different code. Due to the priority of the control head over the IDB controller, the tone code

form the control head will be sent to the amplifier. The tone code being sent to the amplifier is shown in

the BITOUT trace. The transmit clock (TMR1 trace) runs at the data rate. Each time the TMR1 trace

toggles, the bit period has ended and the next bit is placed on to the BITOUT line to the amplifier.

get newselected_tone_code

Output pin RB5=MSB ofselected_tone_code

Wait for Timer1

Timer1 timed out

shiftselected_tone_code

left one bit

Reset Timer1

All bits shifted out?

NO

YES

Figure 4-12Transmitting the Tone Code

28

Figure 4-13 Reading Input Waveforms

Figure 4-14 Sending Output Waveforms

29

CHAPTER V

INSTALLING THE HARDWARE

Installing the Lightbar Driver

Installing the lightbar driver is very straightforward. Having mounted the lightbar according to the

manufacturer’s instructions, attach a DB9 male solder cup connector to the control line cable and wire as

listed in Table 5-1. DO NOT EXCEED MORE THAN 250MA CURRENT DRAW PER CHANNEL. The

lightbar driver requires an IDB controller with an address of 0x2b hex. Connect the DB9 male of the

lightbar to the DB9 female on the lightbar driver. Connect the DB25 male of the lightbar driver to the

DB25 female of the IDB controller. Attach the IDB controller to the IDB bus using the DB9 female on the

IDB controller, and do not connect anything to the DB9 male on the IDB controller. To activate the

functions using the IDB Bus and the CAN protocol send the commands listed in Table 5-1.

Table 5-1: Lightbar Wiring and Command List

Function DB9 Pin

Number

On Command

(hex)

Off Command

(hex)

IDB Controller

I/O Line

Front Strobe Lights 1 0x01 0x81 RB7

Rear Strobe Lights 2 0x02 0x82 RB6

Rear Flood Lights 3 0x03 0x83 RB5

Take Down Lights 4 0x04 0x84 RB3

Wig Wags 5 0x05 0x85 RA5

None 6

None 7

None 8

+12 Volts

(from lightbar or

lightbar power source)

9 - - -

30

Figure 5-1 shows the critical test points that are available on the lightbar driver printed circuit

board. The lightbar driver does not contain any timing signals or timing restrictions, allowing it to be

debugged using only voltmeter. If the board is not working, the first thing to check is power. 12 volts

comes from the lightbar power source on pin 9 of the DB9 connector, and ground is provided through the

IDB controller and is available on pin 1 of the DB25 connector. Pin 13 of the DB25 connector allows for

the 5 volt regulator of the IDB controller to be checked. Although 5 volts is on pin 13, the lightbar driver

does not use it. Beyond these simple test points, refer to the schematic in Appendix B for more detailed

information on testing the circuit.

ToLightbar

IDB Controller Connection

+12 Volts

Figure 5-1Lightbar Critical Test and Troubleshooting Points

Ground

31

Installing the Radio Mute Box

The radio mute box has five connectors. The DB25 male is connected to the DB25 female of the

IDB controller, with an address of 0x2f hex. Connect DB9 male connectors of both the IDB controller and

the radio mute box to the IDB Bus. The IDB Bus connection for the radio mute box is for 12 volt power

only (pin3 is ground and pin 9 is 12 volts). The three remaining connectors are for connecting to the police

radio and the push to talk button. The longer two pin female connector with red and black wires is for

connecting the push to talk button. The red wire is pulled up to 5 volts through a 4.7k ohm resistor in the

box, and the black wire is ground. Use 18-24 gauge wire to connect to the push to talk button to provide

enough wire for the pins to crimp to. The other two connectors (one male and one female) are for

connecting inline to the police radio, connect the radio to the center connector and the speaker to the

remaining connector.

Refer to Figure 5-2 for a list of test points to troubleshoot the radio mute box. 12 volts and ground

are provided by the IDB Bus connection on the DB9 connector and the IDB controller on the DB25

connector provides 5 volts and ground. The circuit can almost entirely be debugged using a voltmeter and

an ohmmeter. Use the ohmmeter to verify the resistances of the power resistors and the continuity of the

relay and the push to talk button. Using a voltmeter verify that the red wire of the push to talk button is

normally 5 volts and goes to ground when depressed. Beyond these critical test points refer to the

schematic in Appendix C for more test points and information.

IDB BusConnection

IDB Controller Connection

+12 Volts

Figure 5-2Radio Mute Box Critical Test and Troubleshooting Points

Common (Green)

Speaker Output (Red)

Common (Green)

Radio Input (Red)

Ground (Black)

Push to TalkButton Input (Red)

+5 VoltsGround

32

Installing the Siren Controller

To install the siren controller, connect the DB25 male of the siren controller to the DB25 female of

the IDB controller. Set the IDB controller to an address of 0x31 hex. Connect the DB9 male connectors of

both the IDB controller and the siren controller to the IDB Bus. The IDB Bus connection for the siren

controller is for 12 volt power only (pin3 is ground and pin 9 is 12 volts). The two remaining connectors

are for connecting to the communications cable of the siren system.

The siren controller has two jumpers, one for connecting the grounds together (J6) and one for

setting the control head presence (J5) as shown in Figure 5-3. If it is desired that the grounds not be

connected, then open circuit jumper J6, the jumper nearest the three pin connectors. If the control head is

being used then remove the jumper J5, the jumper nearest the PIC microcontroller and DB25 connector. If

the control head is not being used, then close the jumper J5. By closing jumper J5 it tells the

microcontroller to that there are no incoming signals from the control head and to listen only to the IDB

controller for the tone codes. This is done because if the microcontroller does not detect a valid code from

the control head then it assumes that the PA microphone is being used, which resembles the control head

not being present.

Also in Figure 5-3 are shown the critical test points to check if the siren controller is not working

properly. The DB9 connector supplies 12 volts on pin 9 to the 5 volt regulator, relays, and the relay driver;

and supplies ground on pin 3. The 5 volts supplied by the IDB controller on pin 13 of the DB25 connector

is not used by the siren controller due to the power consumed by the IDB controller from its regulator.

Check these test points first using a voltmeter. Using an ohmmeter verify the continuity of the ground

connections and the serial signal on pin 2 of the control head and amplifier connectors. If the control head

is not present, verify that jumper J5 is closed. If the control head is present, verify that jumper J5 is open.

If problems are suspected in the relay matrix or selecting the correct signal, the SPST relays used in

production can be replaced with a DPST relays. In addition to the DPST relays, 4.7K resistors and LEDs

can be added to the circuit to provide a visual indication of which relays are active. Do not use SPST

relays and the resistors and LEDs at the same time. The resistors and LEDs will distort the signal due to

the connections provided to 12 volts and ground. Beyond these test points refer to the schematic and

documentation of Appendix D for more information.

33

IDB BusConnection

IDB Controller Connection

+12 Volts

Ground

Figure 5-3Siren Controller Critical Test and Troubleshooting Points

Serial Signal (Green)In from Control Head (Violet)

Ground (Black)

Out to Amplifier (Red)

Ground (Black)Serial Signal (Green)

Control Head Connector(J4)

Amplifier Connector(J3)

GroundConnectionJumper (J6)

Control HeadPresence

Jumper (J5)

+5 Volts

34

CHAPTER VI

SUMMARY AND RECOMMENDATIONS

Summary

In short, the goal of the designs was to enable three standard police cruiser issued items to be

controlled from an on-board computer. This was accomplis hed by designing interfaces to connect an IDB

controller to the police issue hardware. The IDB controllers are connected to an IDB bus and communicate

with the on-board computer using the CAN protocol.

The designs success was measured by their overall cost and their ability to be driven by the IDB

controller designed for Project 54. Additionally, the use of off the shelf parts, using parts used in other

Project 54 designs, and the overall simplicity of the designs were secondary design requirements. In the

end all the designs were able to be driven by the IDB controller for the project and the majority of the parts

used are used in at least one other design. The costs for a single unit if just enough parts are purchased to

build one unit are Lightbar: $27, Radio Mute Box: $30, Siren Controller: $55. Typically the simplicity of

design is measured by the square inches of printed circuit board material required. In the case of these

designs, all three boards are exactly the same size (4.1 by 3.0 inches or 12.3 square inches) so as to fit into

the same enclosure as used by the IDB controller.

The design process for the lightbar driver first required studying the functionality and interface of

the control head and the lightbar. It was easily determined fro m the installation manuals for the control

head and lightbar that the control of the lightbar was accomplished by applying a positive voltage to a bank

of commonly ground relays. At this point the design was simplified to designing a current source relay

driver with TTL inputs and outputs capable of supplying 250mA at 12 volts. It took four versions to

finalize the lightbar driver design; two prototype hand-built versions and a prototype printed circuit board,

and the fourth version is the final design. If the lightbar driver, IDB controller, or on-board computer fails,

and the control head is present, the officer will still be able to control the lights. If the control head is not

present, then control of the lights in the event of a failure will be lost. The most likely part of the design to

fail is the 2N4403 PNP transistor. The transistor is the least over rated part in the design. The resistors and

35

the relay driver are at no more than 40% of their capacity but the transistors are driven at a level near 60%

without heat sinks or elevated temperatures due to the automobile environment.

The design process for the radio mute box is much the same as the lightbar driver. The design

started by looking at what was physically available to work with and then designing a circuit to mute the

radio. To start the design, there was the IDB controller and a police radio with an external speaker.

Because the speaker was external, accessing the wires was connecting to the speaker was easy. A circuit

was designed with five connectors; one for power, one for the IDB controller, one for the push to talk

button, one for speaker in, and one for speaker out. The resistor network design was chose and

implemented. Extra holes were made in the printed circuit board to allow for changing the resistors if it is

necessary to change the muted volume, any value can be used so long as the final resistance does not

exceed the output rating of the police radio. The most likely failure of the radio mute box will be the loss

of the ability to mute or unmute the radio. If the radio mute box fails to mute the radio then the speech

recognition of the on-board computer will be impaired, but can be recovered if the officer turns the volume

down on the police radio manually. If the radio mute fails to unmute the radio, then the officer will need to

turn the volume up on the radio and it will still be audible but at a lower level.

The design process for the siren controller was more extensive. Because of the proprietary nature

of the system the manufacturer was not able to provide specifications on the operation of the tone code

generation and the siren system. The first step was to reverse engineer the system to find out how it

worked. In the end, it was determined that there was just one link between the control head and the

amplifier. The communications cable contained three wires: ground, an unchanging serial signal, and the

tone code wire. By intercepting the tone code wire, interpreting the signal, and recreating it. It was

possible to be able to control the siren tones from two different sources. The majority of the design work

went into designing a 15 bit serial shift register. This was accomplished using a PIC microcontroller

because the shift registers on the market are only 8 bits long. With the tone codes determined by using a

logic analyzer and the shift register implemented in software, the circuit design was complete. The printed

circuit took two revisions to complete. The first revision had a wiring error, a layout error, and a design

error, all of which were corrected in the second version. The siren controller works by intercepting the

signal from the control head, interpreting it, and reproducing it. There are a couple of failure mechanisms

36

that need to be considered. If the control head is not present, then any failure of the on-board computer,

IDB controller, or siren controller will cause the operation of the siren to be lost. If the control head is

present and the on-board computer or IDB controller fails, then system will be able to function. If power is

lost to the siren controller or the siren controller fails, then the operation of the siren system will be lost.

The last scenario may be able to be avoided by changing the audio relay so that without power the direct

through path is still available.

The cooperation of the designers in the project allowed for gathering part order together to

increase quantity and save time and money ordering parts. No parts were order incorrectly, and through the

use of the parts from other designs prototypes were rapidly developed which allowed for more time perfect

the designs rather than waiting for parts to arrive. Unfortunately, it is not known how the original siren

system works because of the unwillingness of the manufacturer to disclose the operation of it to use. The

siren system had to reverse engineered, which cost valuable time and money, but was necessary to build the

siren controller. The use of Mentor Graphics for the printed circuit board layout slowed the design process

tremendously. The lack of experience, design review, and verified libraries caused all three of the designs

to be fabricated twice in order to get a correct and successful design. I recommend that verified libraries be

developed and a nomenclature for the parts and geometries documented so that the Mentor Graphics system

may be easier to use for printed circuit board layout. Mentor Graphics uses design specific libraries, which

makes updating the same geometry in several designs diff icult. I realize that Mentor Graphics is very

capable in many areas, maybe capable but not easy enough to be used to get right though the entire design

process. It was brought to my attention that MicroSim has a layout tool available, and two other software

packages are also available Protel and Orcad on the market. I suggest the next layout be tried in MicroSim

and see how well the layout tool works. I have used Orcad only for schematic capture but I know they

have a layout tool available. I have also used Protel, the version Protel 99SE comes complete with

schematic capture, mixed signal simulator, PLD compiler, and printed circuit board layout. The

geometeries available in the generic library have worked for me every time I have used them without

modifying any of them. It is PC based and as capable Mentor Graphics schematic capture, simulation, and

printed circuit board layout.

37

Recommendations for the Lightbar Driver

The present design of the lightbar driver works without many design compromises. If any

additional channels are needed, the DB9 connector allows for up to 8 output channels. The IDB controllers

have five lines without anything connected to them, and are all used in the current design. Two additional

lines are available if the RS-232 serial port driver chip is removed from the IDB controller board, but this

may require changing the IDB controller’s program. Should the printed circuit board need to be

redesigned, I suggest changing the DB9 connector’s gender from male to female. As the board is designed,

it looks very similar to an IDB controller and may get inadvertently connected to the IDB bus rather than to

the lightbar.

Recommendations for the Radio Mute Box

The present design of the radio mute box also works without many design compromises. The

design involves using five connectors. The DB25 connector attaches to the IDB controller, and a pair of

the two pin connectors are used to attach to the police radio and speaker. The push to talk button connector

is a free hanging two pin connector similar to the radio connectors. This connector may not be the best

choice in the long run. A chassis or panel mounted connector may be better for durability and assembly.

The DB9 connector is used to connect to the IDB bus to get a 12 volt power supply to power the

relay and relay driver. Only the push to talk button is connected to the 5 volt supply from the IDB

controller on the DB25 connector in this design. There is not enough power remaining to drive the relay

driver and relay after powering the IDB controller. If the IDB controller design is modified, I suggest

bringing the 12 volt supply, instead of the 5 volt supply, to the DB25 connector. This design would also

have to be modified to supply 5 volts to the push to talk button by adding a 5 volt regulator to the board.

There would not be much cost savings, but the assembly of the radio mute box and installation into the

cruiser would be simplified.

38

Recommendations for the Siren Controller

The present design of the siren controller uses a PIC microcontroller and four connectors. Due to

the serial signals the PIC is used to process, I do not think that it can be removed. The PIC that is used has

28 pins and is rather expensive. It was used in the design because it was the same as the IDB controller and

would simplify development and troubleshooting. The PIC used has 22 input/output lines. Of these 22

lines, only 12 are used to run the siren controller board and the remaining 10 are used for debugging

purposes. A smaller PIC microcontroller could be designed in to reduce cost, but the program may need to

be updated for the new chip.

The four connectors used may be able to be reduced. The DB25 connector attaches to the IDB

controller, and the pair of three pin connectors are used to connect to the control head and amplifier of the

siren system. The DB9 connector is used to connect to the IDB bus to get a 12 volt power supply to power

the relays, relay driver, and the 5 volt regulator to power the remaining chips. The DB25 connector has a

regulated 5 volt supply from the IDB controller. There is not enough power to drive the relay and relay

driver after powering the IDB controller. If the IDB controller design is modified, I suggest bringing the 12

volt supply, instead of the 5 volt supply, to the DB25 connector. This will eliminate the need for the DB9

connector and a second connection to the IDB bus. The two 3 pin connectors are for connecting to the

control head and amplifier. The amplifier will always be used in the system and the connector from the

siren controller will not be able to be removed. The use of the control head is optional. If the control head

is not used, then the connector does not have to be installed on the siren controller.

To avoid the loss of the siren system with the control head present, it would be beneficial to

change the relay matrix to provide a straight through path in the event that power is lost to the IDB bus or

the siren controller fails. The audio signal relay (KRB2) provides a straight through path if the PA

microphone is being used. If the audio relay was changed from a SPST relay to a SPDT relay, it could be

wired in to provide a straight through path by default from the control head to the amplifier. The relay

would be activated to connect the siren controller’s microcontroller to the amplifier to send the tone code

requested by the IDB controller.

39

LIST OF REFERENCES

Allegro MicroSystems, “High-Voltage, High-Current Darlington Arrays.” 1998.

Dallas Semiconductor. “High-Speed Microcontroller User Guide.” 1999.

Earle, Sarah M. “Call them state (of the art) police.” Concord Monitor. 24 August 2000.

Ford, Royal. “System outfits police cruisers with high-tech features.” The Boston Globe. 10 March 2001.

Hoffman, Jill. “Calling Car 54.” Foster’s Daily Democrat. 1 September 2000: 1D.

Markuns, Chris. “UNH develops talking police car.” The Eagle Tribune. 1 January 2001.

Martin, Michael E. “Intelligent Transportation System Data Bus Controller.” Senior Project Report.

Durham, NH. May 2001.

MicroChip Technology Inc. “PIC micro Mid-Range MCU Family Reference Manual.” 1997.

Mostoller, Danielle. “Car Talk.” UNH Magazine. Winter 2001: 10.

Welcome to CATLab! Consolidated Advanced Technologies For Law Enforcement Program. 2000.

http://www.catlab.unh.edu 11 April 2001.

APPENDICES

41

APPENDIX A

ALLEGRO MICROSYSTEMS ULN2003A DATA SHEET

42

43

44

45

46

47

48

APPENDIX B

LIGHTBAR DRIVER

Complete Schematic

49

Bill of Materials

Description Qty Manufacturer Part Number Vendor Part Number IC Socket 16 pin

1 Mill-Max 110-99-316-41-001 Digikey ED3116-ND

Diode 1N4148

5 Diodes Inc. Digikey 1N4148DICT-ND

Transistor 2N4403 PNP

5 Fairchild Semiconductor

2N4403 Digikey 2N4403-ND

Chassis

1 Serpac SR-031B Digikey SR031B-ND

DB25 Solder cup male

1 AIM 40-9725M Radio Shack 910-4777

DB9 Right angle male

1 Leoco DE-09PLURL2 Radio Shack 910-1543

Plastic retaining clip for DB9

2 Norcomp Inc 163-001-000-000 Digikey 163-01P-ND

ULN2003A Relay driver

1 TI ULN2003AN Digikey 296-1979-5-ND

Hex Nut, 4-40 2 Building Fasteners

Digikey H142-ND

Screw Slotted Panhead 4-40 x1/4

2 Building Fasteners

Digikey H216-ND

Resistor 100k ohm 1/4 watt

5 Radio Shack 900-0266

Resistor 4.7k ohm 1/4 watt

5 Radio Shack 900-0395

Resistor 680 ohm 1/2 watt

10 Digikey 680H-ND

Printed Circuit Board

1

50

Printed Circuit Board – Top Layer

Printed Circuit Board – Bottom Layer

51

Printed Circuit Board - Silkscreen

52

APPENDIX C

RADIO MUTE BOX

Complete Schematic

53

Bill of Materials

Description Qty Manufacturer Part Number Vendor Part Number IC Socket 14 pin

1 Mill-Max 110-99-314-41-001 Digikey ED3114-ND

IC Socket 16 pin

1 Mill-Max 110-99-316-41-001 Digikey ED3116-ND

Pin, free hanging, 2 circuits

1 AMP 1-480319-0 Digikey A1410-ND

Socket, free hanging, 2 circuits

1 AMP 1-480318-0 Digikey A1411-ND

24-18 AWG Tin Pin

2 AMP 60618-1 Digikey A1422-ND

24-18 AWG Tin Socket

2 AMP 60617-1 Digikey A1423-ND

Chassis

1 Serpac SR-031B Digikey SR031B-ND

DB25 Solder cup male

1 AIM 40-9725M Radio Shack 910-4777

DB9 Right angle male

1 Leoco DE-09PLURL2 Radio Shack 910-1543

Plastic retaining clip for DB9

2 Norcomp Inc 163-001-000-000 Digikey 163-01P-ND

Relay SPDT 12v dip w/diode

1 Hamlin HE721C1210 Digikey HE115-ND

ULN2003A Relay driver

1 TI ULN2003AN Digikey 296-1979-5-ND

Hex Nut, 4-40 2 Building Fasteners

Digikey H142-ND

Screw Slotted Panhead 4-40 x1/4

2 Building Fasteners

Digikey H216-ND

Resistor 510 ohm 5 watt

2 Radio Shack 90-961

Resistor 8 ohm 20 watt

1 Radio Shack 271-120

Resistor 4.7k ohm 1/4 watt

1 Radio Shack 900-0395

Printed Circuit Board

1

54

Parts below are for connecting the Push to Talk Button: Socket, free hanging, 2 circuits

1 AMP 1-480318-0 Digikey A1411-ND

24-18 AWG Tin Socket

2 AMP 60617-1 Digikey A1423-ND

Pin, free hanging, 2 circuits

1 AMP 1-480319-0 Digikey A1410-ND

24-18 AWG Tin Pin

2 AMP 60618-1 Digikey A1422-ND

55

Printed Circuit Board – Top Layer

Printed Circuit Board – Bottom Layer

56

Printed Circuit Board - Silkscreen

57

APPENDIX D

SIREN CONTROLLER

Complete Schematic

58

Bill of Materials

Description Qty Manufacturer Part Number Vendor Part Number Capacitor 1uF 35VDC Tantalum

3 Panasonic ECS-F1VE105K Digikey P2059-ND

Capacitor 10uF 35VDC Tantalum

2 Panasonic ECS-F1VE106K Digikey P2065-ND

IC Socket 8 pin

1 Mill-Max 110-99-308-41-001

Digikey ED3108-ND

IC Socket 14 pin

4 Mill-Max 110-99-314-41-001

Digikey ED3114-ND

IC Socket 16 pin

1 Mill-Max 110-99-316-41-001

Digikey ED3116-ND

Oscillator 16Mhz

1 Epson Electronics

SG-531P 16.000MC

Digikey SE1211-ND

IC Socket 28 pin

1 Mill-Max 110-99-328-41-001

Digikey ED3128-ND

2 pin header

2 Mill-Max 800-10-002-10-001

Digikey ED7202-ND

2 pin shunt

2 3M 929955-06 Digikey 929955-06-ND

Pin, free hanging, 3 circuits

1 AMP 1-480305-0 Digikey A1400-ND

24-18 AWG Tin Pin

3 AMP 60618-1 Digikey A1422-ND

Socket, free hanging, 3 circuits

1 AMP 1-480303-0 Digikey A1429-ND

24-18 AWG Tin Socket

3 AMP 60617-1 Digikey A1423-ND

Voltage Regulator TO-92 Package 5 Volt

1 National Semiconductor

LM78L05ACZ Digikey LM78L05ACZ-ND

Chassis

1 Serpac SR-031B Digikey SR031B-ND

DB25 Solder cup male

1 AIM 40-9725M Radio Shack 910-4777

59

DB9 Right angle male

1 Leoco DE-09PLURL2 Radio Shack 910-1543

Plastic retaining clip for DB9

2 Norcomp Inc 163-001-000-000 Digikey 163-01P-ND

Relay SPST 12v dip w/diode

3 Hamlin HE721A1210 Digikey HE103-ND

PIC 16F876-20I/SP

1 Microchip 16F876-20I/SP Digikey PIC16F876-20I/SP-ND

SN7407N

1 TI SN7407N Digikey 296-1436-5-ND

ULN2003A Relay driver

1 TI ULN2003AN Digikey 296-1979-5-ND

Hex Nut, 4-40

2 Building Fasteners

Digikey H142-ND

Screw Slotted Panhead 4-40 x 1/4

2 Building Fasteners

Digikey H216-ND

Resistor 1.0k ohm 1/4 watt

2 Radio Shack 900-0218

Resistor 4.7k ohm 1/4 watt

5 Radio Shack 900-0395

Printed Circuit Board

1

Use these parts for debugging (instead of SPST Relays): Relay DPST 12v dip w/diode

3 Hamlin HE722A1210 Digikey HE109-ND

Resistor 4.7k ohm 1/4 watt

4 Digikey 4.7kQBK-ND

LED

4 QT Optoelectronics

HLMP-4700QT Digikey HLMP-4700QT-ND

Optional Device for 16Mhz Oscillator 16Mhz oscillator programmed

1 Epson Electronics

SG-8002DC-PWT 16.000 MHZ

Digikey SG-8002DC-PTC-ND 16.0000MHZ

60

Printed Circuit Board – Top Layer

Printed Circuit Board – Bottom Layer

61

Printed Circuit Board – Silkscreen

62

Serial Tone Code Waveforms

Figure D-2 Wail Waveform

Figure D-1 No Tone Waveform

63

Figure D-3 Yelp Waveform

Figure D-4 Piercer Waveform

64

Figure D-5 Horn Waveform

Figure D-6 Manual Piercer Waveform

65

Source Code – SIREN.H

#include <pic.h> #define TRUE 1 #define FALSE 0 #define bitset(var,bitno) ((var) |=1 <<(bitno)) // macro to set a bit #define bitclr(var,bitno) ((var) &=~(1 <<(bitno))) // macro to clear a bit #define num_waveforms 6 #define num_send_bits 15 // last two bits sent are 1's #define num_recv_bits num_send_bits-2 // receive 2 bits less than sent to allow time for interpretation of new signal #define XTAL 20 // crystal frequency in MHz #define PERIOD0 120 // period in Usec #define SCALE0 8 // prescaler for timer0 #define PRELOAD0 -1*PERIOD0*XTAL/SCALE0/3 #define PERIOD1 1250 // period in Usec (1250) #define SCALE1 1 // prescaler for timer1 (1/2/4/8 ONLY) #define PRELOAD1 (signed int) -1*PERIOD1*XTAL/SCALE1/3 static volatile unsigned int TMR1 @ 0x0E; void define_waveform(void); void setup_timer0_prescaler(void); void setup_timer1_prescaler(void); void Set_IO_Pins(void); void get_tone_code(void); void interrupt interrupt_service_routine(void); static bank3 unsigned int waveform[num_waveforms*2]; unsigned char selection; unsigned char no_signal_count; unsigned char skip_edge; unsigned char sample_count; unsigned int selected_waveform; unsigned int incoming_tone_code, received_tone_code; unsigned int bit_count; unsigned int received_bits; unsigned int x; static bit last_bit; static bit search_beat; static bit sample1, sample2, sample3; static bit timer0_beat; static bit timer1_beat; static bit intpin_beat; static bit recv_bit_beat; static bit new_bit;

66

Source Code – SIREN.C

// Port A Bits 0-4 for address (IDB/digital code tone) // Port A Bit 5 Waveform Selected 1:IDB 0:Whelen Controller // Port B Bit 0 Interrupt Pin for Serial Input // Port B Bit 1 Tone Code to Amplifier // Port B Bit 2 Whelen Microphone to Amplifier // Port B Bit 4 Project54 Microphone to Amplifier // Port B Bit 5 Output Waveform // Port B Bits 3,6,7 for ICD // Port C Bit 0 Chip Heartbeat // Port C Bit 1 Timer0 Interrupt Heartbeat // Port C Bit 2 Timer1 Interrupt Heartbeat // Port C Bit 3 Start of Output Waveform (overlaps with bit0 of waveform) // Port C Bit 4 Searching for Matching Waveform // Port C Bit 5 Reading Incoming Word // Port C Bit 6 (RS232) read next bit here // Port C Bit 7 (RS232) next bit added to incoming_tone_code #include <pic.h> #include "siren.h" main() { unsigned int heartbeat; static bit heart_output; Set_IO_Pins(); define_waveform(); intpin_beat=0; timer0_beat=0; timer1_beat=0; recv_bit_beat=0; incoming_tone_code=0; received_tone_code=0; received_bits=99; sample_count=0; sample1=0; sample2=0; sample3=0; no_signal_count=0; last_bit=1; skip_edge=FALSE; get_tone_code(); bitclr (PORTA,5); // set Port A Bit 5 with 0 bitclr (PORTB,1); // set Port B Bit 1 with 0 bitclr (PORTB,2); // set Port B Bit 2 with 0 bitclr (PORTB,4); // set Port B Bit 4 with 0 bitclr (PORTB,5); // set Port B Bit 5 with 0

67

bitclr (PORTC,0); // set Port C Bit 0 with 0 bitclr (PORTC,1); // set Port C Bit 1 with 0 bitclr (PORTC,2); // set Port C Bit 2 with 0 bitclr (PORTC,3); // set Port C Bit 3 with 0 bitclr (PORTC,4); // set Port C Bit 4 with 0 bitclr (PORTC,5); // set Port C Bit 5 with 0 bitclr (PORTC,6); // set Port C Bit 6 with 0 bitclr (PORTC,7); // set Port C Bit 7 with 0 PSA=0; // assign prescaler to timer0 not to watchdog T0CS=0; // select internal clock for timer0 T0IF=0; // clear timer0 interrupt setup_timer0_prescaler(); TMR0+=PRELOAD0; // preload timer0 TMR1CS=0; // select internal clock for timer1 TMR1IF=0; // clear timer1 interrupt setup_timer1_prescaler(); TMR1+=PRELOAD1; // preload timer1 TMR1ON=1; // timer1 on INTEDG=0; // int pin interrupt on falling edge INTF=0; // clear int pin interrupt T0IE=1; // disable timer0 interrupt TMR1IE=1; // enable timer1 interrupt INTE=1; // enable int pin interrupt GIE=1; // enable global interrupts search_beat=0; heartbeat=0; heart_output=1; while (1) // main loop { heartbeat++; if (heartbeat==1) { RC0=heart_output=!heart_output; } else if (heartbeat==255) { heartbeat=0; } } } #pragma interrupt_level 1 void interrupt interrupt_service_routine() @ 0x10 { if (INTF & INTE) // RB0 has seen a 1 to 0 transistion and interrupt is enabled { INTF=0; // clear interrupt flag if (!skip_edge) // skip edge to search for correct first edge for synhronization { INTE=0; // disable interrupt pin

68

T0IF=0; // clear timer0 interrupt flag TMR0+=PRELOAD0; // preload timer0 incoming_tone_code=0; // clear receiving counters received_bits=0; sample_count=0; sample1=sample2=sample3=0; RC5=1; } else { skip_edge--; } } if (T0IF & T0IE) // Incoming Timer { T0IF=0; // clear timer0 interrupt TMR0 += PRELOAD0; RC1=timer0_beat=!timer0_beat; sample_count++; switch (sample_count) { case (4) : // take first sample at count 4 sample1=RB0; break; case (5) : // take second sample at count 5 sample2=RB0; break; case (6) : // take third sample at count 6 sample3=RB0; RC6=recv_bit_beat=!recv_bit_beat; incoming_tone_code=incoming_tone_code<<1; if ((sample1+sample2+sample3)>=2) { incoming_tone_code=incoming_tone_code|0x0001; new_bit=1; } else { new_bit=0; } RC7=new_bit; if ((RA3==1)&&(new_bit==last_bit)) // no incoming signal present { no_signal_count++; } else { no_signal_count=0; last_bit=new_bit; } break; case (10) : // done taking samples - increment received bit count received_bits++; sample_count=0; break;

69

} switch (received_bits) { case (0) : case (1) : // first 2 bit should both be zeroes - if they are not restart receiving if (incoming_tone_code!=0) { INTF=0; // clear int pin interrupt INTE=1; // enable int pin interrupt received_bits=99; RC5=0; skip_edge=1; } break; case (2) : case (3) : case (4) : case (5) : case (6) : case (7) : case (8) : case (9) : case (10) : case (11) : case (12) : break; case (13) : if (incoming_tone_code & 0x0001) // no framing error - valid stop bit { // added 2 ones to end of received word to match with sending waveforms incoming_tone_code=(incoming_tone_code<<1)|0x0001; incoming_tone_code=(incoming_tone_code<<1)|0x0001; received_tone_code=incoming_tone_code; x=0; while ((received_tone_code!=waveform[x])&&(x<num_waveforms)) { x++; RC4=search_beat=!search_beat; } received_tone_code=x; if (x>=num_waveforms) // did not match waveform { skip_edge=2; } } else // framing error - invalid stop bit { received_tone_code=0; skip_edge=1; } INTF=0; // clear int pin interrupt INTE=1; // enable int pin interrupt received_bits=99; RC5=0; break; case (14) : case (15) :

70

default : break; } } if (TMR1IF & TMR1IE) // Output Timer { TMR1IF=0; // clear timer1 interrupt flag TMR1+=PRELOAD1; RC2=timer1_beat=!timer1_beat; bit_count++; if (bit_count>=num_send_bits) // out of bits? { bit_count=0; get_tone_code(); } if (bit_count) { RC3=0; } else { RC3=1; } selected_waveform=selected_waveform<<1; if (selected_waveform & 0x8000) // set Port B Bit 5 with next bit { RB5=1; } else { RB5=0; } } } void Set_IO_Pins() { ADCON1=0x06; bitset(TRISA,0); // address pins set as inputs bitset(TRISA,1); bitset(TRISA,2); bitset(TRISA,3); bitset(TRISA,4); bitclr(TRISA,5); // pin set as output bitset(TRISB,0); // pin set as input bitclr(TRISB,1); // pin set as output bitclr(TRISB,2); // pin set as output bitclr(TRISB,4); // pin set as output bitclr(TRISB,5); // pin set as output bitclr(TRISC,0); // pin set as output bitclr(TRISC,1); // pin set as output bitclr(TRISC,2); // pin set as output bitclr(TRISC,3); // pin set as output bitclr(TRISC,4); // pin set as output bitclr(TRISC,5); // pin set as output bitclr(TRISC,6); // pin set as output bitclr(TRISC,7); // pin set as output } void define_waveform()

71

{ // waveforms definitions waveform[0]=0b001010101000111; waveform[1]=0b000110101000111; waveform[2]=0b001001101000111; waveform[3]=0b000101101000111; waveform[4]=0b001010100100111; waveform[5]=0b001010011000111; } void get_tone_code() { if ((received_tone_code>0)&&(received_tone_code<=num_waveforms)) // use valid controller code { RB1=1; RB2=0; RB4=0; selection=(unsigned char) received_tone_code; received_tone_code=0; RA5=0; } else // use IDB tone code { if (no_signal_count>=(num_send_bits/2)) // controller microphone in use { RB1=0; RB2=1; no_signal_count=0; selection=0; RA5=0; } else // controller mic not in use - use IDB tone code { RB2=0; RA5=1; switch (PORTA&0x07) // switch (RA0+RA1*2+RA2*4) { case (0) : // tone 1 RB4=0; RB1=1; selection=0; break; case (1) : // tone 2 RB4=0; RB1=1; selection=1; break; case (2) : // tone 3 RB4=0; RB1=1; selection=2; break; case (3) : // tone 4 RB4=0; RB1=1;

72

selection=3; break; case (4) : // tone 5 RB4=0; RB1=1; selection=4; break; case (5) : // tone 6 RB4=0; RB1=1; selection=5; break; case (6) : // PC microphone in use RB1=0; RB4=1; selection=0; break; default : // invalid selection - default to no tone RB4=0; RB1=1; selection=0; break; } } } selected_waveform=waveform[selection]; } void setup_timer1_prescaler() { switch (SCALE1) { case (1) : T1CKPS1=0; T1CKPS0=0; break; case (2) : T1CKPS1=0; T1CKPS0=1; break; case (4) : T1CKPS1=1; T1CKPS0=0; break; case (8) : T1CKPS1=1; T1CKPS0=1; break; default : // default to prescale of 1 T1CKPS1=0; T1CKPS0=0; break; } } void setup_timer0_prescaler()

73

{ if (PSA==0) // prescaler assigned to timer0 { switch (SCALE0) { case (2) : PS2=0; PS1=0; PS0=0; break; case (4) : PS2=0; PS1=0; PS0=1; break; case (8) : PS2=0; PS1=1; PS0=0; break; case (16) : PS2=0; PS1=1; PS0=1; break; case (32) : PS2=1; PS1=0; PS0=0; break; case (64) : PS2=1; PS1=0; PS0=1; break; case (128) : PS2=1; PS1=1; PS0=0; break; case (256) : PS2=1; PS1=1; PS0=1; break; default : // default to prescale of 2 PS2=0; PS1=0; PS0=0; break; } } else if (PSA==1) // prescaler assigned to watchdog { switch (SCALE0) {

74

case (1) : PS2=0; PS1=0; PS0=0; break; case (2) : PS2=0; PS1=0; PS0=1; break; case (4) : PS2=0; PS1=1; PS0=0; break; case (8) : PS2=0; PS1=1; PS0=1; break; case (16) : PS2=1; PS1=0; PS0=0; break; case (32) : PS2=1; PS1=0; PS0=1; break; case (64) : PS2=1; PS1=1; PS0=0; break; case (128) : PS2=1; PS1=1; PS0=1; break; default : // default to prescale of 1 PS2=0; PS1=0; PS0=0; break; } } }

75

APPENDIX E

DALLAS SEMICONDUCTOR SERIAL SHIFT REGISTER OPERATION

76

77

78

79

80

81

82

83

84

85

86

87

88

APPENDIX F

MICROCHIP PIC SERIAL SHIFT REGISTER OPERATION

89