CHAPTER TWO LITERATURE REVIEW 2.1 SENSORS/MOTION SENSORS Motion sensors are types of electronic security device that senses movement and usually triggers an alarm. Many types of motion sensors can sense motion in total darkness, without an intruder becoming aware that an alarm has been triggered. Motion sensors are an important part of most burglar alarm systems. They help alert security personnel, especially in situations where no obvious break-in has occurred. For instance, if an intruder steals a key to gain access to a protected site or hides within the site during normal business hours, the intruder’s entrance or presence could go unnoticed. A motion sensor will detect the intruder’s movements as soon as he or she walks or otherwise moves within the area protected by the detector. Motion sensors usually protect indoor areas, where conditions can be more closely controlled. Sensors for use in homes usually detect movement in spaces about 11 m × 11 m (35 ft × 35 ft) in area. Sensors for large warehouses can protect areas with dimensions as large as 24 m × 37 m (80 ft × 120 ft). Buildings with valuable or important assets, such as museums, also use motion sensors to detect breakins at vulnerable points. Such points include walls, doors, windows, skylights, and even air ducts. Special motion sensors can protect the inside of exhibit cases where items such as diamonds are displayed. Others can be focused to a narrow area of coverage, somewhat like a curtain, that is projected in front of a painting to detect even the slightest touch. Motion sensor systems use a variety of methods to detect movement. Each method has it advantages and disadvantages. Some of the methods are discussed below. 2.1.1 PASSIVE INFRARED SENSOR
A Passive Infrared sensor (PIR sensor) is an electronic device that measures infrared (IR) light radiating from objects in its field of view. PIR sensors are often used in the construction of PIR-based motion detectors. Apparent motion is detected when an infrared source with one temperature, such as a human, passes in front of an infrared source with another temperature, such as a wall [http://www.gadgetshack.com/motionsensor.html] All objects emit what is known as black body radiation. It is usually infrared radiation that is invisible to the human eye but can be detected by electronic devices designed for such a purpose. The term passive in this instance means that the PIR device does not emit an infrared beam but merely passively accepts incoming infrared radiation. “Infra” meaning below our ability to detect it visually, and “Red” because this color represents the lowest energy level that our eyes can sense before it becomes invisible. Thus, infrared means below the energy level of the color red, and applies to many sources of invisible energy. http://steveslockandsafe.com/venice-locksmith-home-security-technicians-notebook/ Infrared radiation enters through the front of the sensor, known as the sensor face. At the core of a PIR sensor is a solid state sensor or set of sensors, made from an approximately 1/4 inch square of natural or artificial pyroelectric materials, usually in the form of a thin film, out of gallium nitride (GaN), caesium nitrate (CsNO3), polyvinyl fluorides, derivatives of phenylpyrazine, and cobalt phthalocyanine. Lithium tantalate (LiTaO3) is a crystal exhibiting both piezoelectric and pyroelectric properties. ]. The sensor is often manufactured as part of an integrated circuit and may consist of one (1), two (2) or four (4) 'pixels' of equal areas of the pyroelectric material. Pairs of the sensor pixels may be wired as opposite inputs to a differential amplifier. In such a configuration, the PIR measurements cancel each other so that the average temperature of the field of view is removed from the electrical signal; an increase of IR energy across the entire sensor is self-cancelling and will not trigger the device. This allows the device to resist false indications of change in the event of being exposed to flashes of light or field-
wide illumination. (Continuous bright light could still saturate the sensor materials and render the sensor unable to register further information.) At the same time, this differential arrangement minimizes common-mode interference, allowing the device to resist triggering due to nearby electric fields. However, a differential pair of sensors cannot measure temperature in that configuration and therefore this configuration is specialized for motion detectors. In a PIR-based motion detector (usually called a PID, for Passive Infrared Detector), the PIR sensor is typically mounted on a printed circuit board containing the necessary electronics required to interpret the signals from the pyroelectric sensor chip. The complete assembly is contained within a housing mounted in a location where the sensor can view the area to be monitored. Infrared energy is able to reach the pyroelectric sensor through the window because the plastic used is transparent to infrared radiation (but only translucent to visible light). This plastic sheet also prevents the intrusion of dust and/or insects from obscuring the sensor's field of view, and in the case of insects, from generating false alarms. A few mechanisms have been used to focus the distant infrared energy onto the sensor surface. The window may have multiple Fresnel lenses molded into it. Alternatively, some PIDs are manufactured with internal plastic, segmented parabolic mirrors to focus the infrared energy. Where mirrors are used, the plastic window cover has no Fresnel lenses molded into it. This filtering window may be used to limit the wavelengths to 8-14 microns which is closest to the infrared radiation emitted by humans (9.4 microns being the strongest). The PID can be thought of as a kind of infrared camera that remembers the amount of infrared energy focused on its surface. Once power is applied to the PID, the electronics in the PID shortly settle into a quiescent state and energize a small relay. This relay controls a set of electrical contacts that are usually connected to the detection input of a burglar alarm control panel. If the amount of infrared energy
focused on the pyroelectric sensor changes within a configured time period, the device will switch the state of the alarm relay. The alarm relay is typically a "normally closed (NC)" relay, also known as a "Form B" relay. A person entering a monitored area is detected when the infrared energy emitted from the intruder's body is focused by a Fresnel lens or a mirror segment and overlaps a section on the chip that had previously been looking at some much cooler part of the protected area. That portion of the chip is now much warmer than when the intruder wasn't there. As the intruder moves, so does the hot spot on the surface of the chip. This moving hot spot causes the electronics connected to the chip to de-energize the relay, operating its contacts, thereby activating the detection input on the alarm control panel. Conversely, if an intruder were to try to defeat a PID, perhaps by holding some sort of thermal shield between himself and the PID, a corresponding 'cold' spot moving across the face of the chip will also cause the relay to de-energize — unless the thermal shield has the same temperature as the objects behind it. 2.1.2 ULTRASONIC SENSORS Ultrasonic sensors (also known as transceivers when they both send and receive) work on a principle similar to radar or sonar which evaluate attributes of a target by interpreting the echoes from radio or sound waves respectively. Ultrasonic sensors generate high frequency sound waves and evaluate the echo which is received back by the sensor. Sensors calculate the time interval between sending the signal and receiving the echo to determine the distance to an object. This technology can be used for measuring: wind speed and direction (anemometer), fullness of a tank and speed through air or water. For measuring speed or direction a device uses multiple detectors and calculates the speed from the relative distances to particulates in the air or water. To measure the amount of liquid in a tank, the sensor measures the distance to the surface of the fluid. Further
applications include: humidifiers, sonar, medical ultrasonography, burglar alarms and non-destructive testing. Systems typically use a transducer which generates sound waves in the ultrasonic range, above 20,000 hertz, by turning electrical energy into sound, then upon receiving the echo turn the sound waves into electrical energy which can be measured and displayed. Some older burglar alarm systems use ultrasound (sound of very high frequency) to detect motion. They are called ultrasonic motion detectors. In such a detector a transmitter sends out sound of a frequency that is too high for the human ear to hear. A receiver picks up the sound waves reflected from the room or area under protection. The motion of someone or something in the space between the receiver and transmitter will cause a change, or shift, in the frequency of the sound. A circuit in the device detects any unusual shift in the frequency. A small shift, such as that produced by an insect or rodent, is ignored. When a larger shift, such as one produced by a moving person, is detected, the device triggers the alarm. Ultrasonic detectors are extremely sensitive, and can sometimes be triggered by loud noises or air gusts from an open vent. The frequency shift discussed above is also known as the Doppler Effect, which results from the behavior of sound waves when they are compressed by a moving object. Ultrasonic motion detectors use the Doppler Effect to detect movement. The detector’s circuitry compares the frequency of the sound that is emitted by the transmitter when no motion is present to the frequency that results when motion occurs. When no motion is present, the sound is emitted and bounces back in an even, steady pattern. When motion occurs, the sound waves are disturbed and the circuit detects the shift. [Microsoft ® Encarta ®2009. © 1993-2008 Microsoft Corporation. All rights reserved.] 2.2 BURGLAR ALARM SYSTEMS
Burglar (or intrusion), alarms are electronic alarms designed to alert the user to a specific danger. Sensors are connected to a control unit via low-voltage wiring or a narrowband RF signal which is used to interact with a response device. The most common security sensors are used to indicate the opening of a door or window or detect motion via passive infrared (PIR). New construction systems are predominately hardwired for economy. Retrofit installations often use wireless systems for a faster, more economical installation. Some systems serve a single purpose of burglar or fire protection. Combination systems provide both fire and intrusion protection. Systems range from small, selfcontained noisemakers, to complicated, multi-zoned systems with color-coded computer monitor outputs. Many of these concepts also apply to portable alarms for protecting cars, trucks or other vehicles and their contents (i.e., "car alarms"). Burglar alarms (or perimeter security systems, perimeter detection systems, Perimeter protection, intrusion detection systems and many more terms for the same thing) are divided to two main fields: home burglar alarms and industrial burglar and perimeter intrusion detection. 2.2.1 HISTORY OF BURGLAR ALARMS When one mentions burglar alarms it's not unreasonable to think of high tech devices developed in the silicon age. The truth is, the concept of an alarm system is one that was invented long before that. For thousands of years man has used animals, more notably the dog, to guard and alert him of any one trying to tamper or steel his valuables. In the middle Ages large gongs were used to warn a population of impending doom or large bonfires lit to warn of imminent invasion. As important as these developments were, it was not until 1852 that the first electro-mechanical alarm system was invented. Edwin Holmes was an American Inventor from Boston Massachusetts; the alarm he devised was simplistic but effective. A solenoid struck a gong when a trip wire was disturbed. Although his alarm system is nothing compared to today's offerings it was positively received in its day.
These early alarm systems continued to make use of simple electrical circuits and relays. A typical installation would see wire wound along windowsills and around doorframes coupled with conductive lead foil and mechanical or magnetic switches laced with thin wire. The security conscious had to wait until the next century for further alarm system advances, which heralded the advent of the transistor and the integrated circuit. This technology allowed smaller units integrated with microwave and ultrasonic motion sensors along with features such as entrance and exit delays to be introduced. With the level of technical sophistication increasing, so did the applications. Now it was possible to use alarms to monitor industrial processes such as steel production or to monitor natural events such as volcanoes and earthquakes. Today, alarm systems have advanced even further. The rapid and expanded use of the Internet has revolutionized alarm systems immensely, as alarm systems have now become intelligent. It is now possible for them to sort problems out themselves, by identifying triggers and minimizing false alarms. They even have the ability to measure weight, size and other environmental factors. Some also have self-diagnostic capabilities and can detect internal circuitry problems, allowing them to functioning correctly. 2.2.2 PRINCIPLE OF BURGLAR ALARMS All alarms systems consist of four main component areas: - Detection Devices, to detect if an intrusion has occurred - Warning Devices, bells, sirens and remote monitoring - Control Panel, to control the various states of the system
- Power Supplies, including backup batteries DETECTION DEVICES Detection devices do exactly as the name implies, these are the senses of the system and detect intrusion by a number of different means. One of the most common detection devices is the contact switch which detects the opening of windows, doors, etc. Numerous different types of contacts are available for different applications such as roller shutters requiring large heavy duty types or domestic doors requiring neat flush fitting types. From a burglars point of view it is some times more convenient to smash their way through a door or window than to open it and some even less desirable methods have been employed for gaining access to a premises. Other types of detection are used where this is a risk. Devices such as lead foil tape can be used for glass sections or closed circuit wiring for semi-solid structures such as doors, walls, etc. These last two types are relatively old forms of detection and although they facilitate a very inexpensive installation they have the disadvantage in that they must be replaced after an attack has occurred. A more modern device for detecting forced entry is the vibration sensor (or inertia sensor). Primarily it has the advantage, in that it can be easily installed and, coupled with the relevant analyzer it can differentiate between different types of vibrations. This makes it very suitable for different structures e.g.; solid walls, glass, wood, etc. In some cases it is not always cost effective to cover every entry point so units such as motion detectors can be used and in fact these detectors are used quite extensively in modern domestic and commercial systems. A motion detector, as the name implies, detects the motion of an intruder within a certain area. The maximum range of these detectors is about 35 meters. WARNING DEVICES
These are devices that are used to alert the owner of the house or facility that the alarm has been installed in. Some of the devices used include Bells, Sirens & remote monitoring. CONTROL PANEL This is the heart and local brain of the system. It receives the first notification that an alarm condition has occurred and then decides what action has to be taken. With simpler panels this usually means activating the warning devices. With microprocessor type panels this action could be considerably more complex such as interrogating the detection device to verify the condition, recording events in the memory or ignoring the device until it activates again. Control panels display conditions by means of lights or LED’s flight emitting diodes on the front of the panel e.g., clear, fault, mains on, etc. For more sophisticated panels this is sometimes effected by means of an alphanumeric display. A series of words and numbers will be produced on a screen such as, zone one open, tamper zone three, etc. A key switch or keypad is provided to switch the system on or off. Again with more complex panels the keypad can be used to perform functions like interrogating the memory, inhibiting a zone, testing the warning devices and programming the system to react in the required manner to different situations. POWER SUPPLIES Power for the alarm system is derived from the 240V AC mains supply. It is converted to 12V DC by the power supply unit and it is this voltage that is used for the System should a mains failure occur then standby batteries, housed inside/the control panel, will take over and power the system. When mains returns these batteries will automatically recharge. 2.2.3 TYPES OF BURGLAR ALARM
There are three main types of burglar alarm system and these are hardwired, wireless and selfcontained. Hardwired alarm systems are often referred to as the more traditional type of security system. These systems usually consist of a main control panel, bell box or siren and a number of sensor devices which detect an intrusion. Essentially all components are wired together using multi-core cable. The cabling provides power to the device and detection of the device being triggered into an alarm condition as well as the identifying of tampering of the sensor device. One advantage of this system is that it is considered more permanent than a wireless system and sometimes more reliable and not so susceptible to false alarms. One disadvantage is that it is recommended having the system installed by a professional alarm installer and this will come at an additional cost - both for labor and materials. On the other hand a wireless alarm system is very straightforward to install. Virtually no additional materials are involved so if you are not looking to spend a fortune on a home security system then a wireless system is for you. These days they are so much more reliable than they once were and false alerts are a thing of the past. They are fantastic for rented accommodation too as they can be easily removed when you leave your rented property. Adding an additional sensor or two at a later time is a breeze and there is no need to employ a tradesman to do this. The only slight disadvantage is that you will have a change all of the batteries in the wireless sensors on a regular basis but it is a small price to pay for the flexibility and versatility of a wireless alarm system. A self-contained alarm system is a single unit often shaped like an everyday object such as a VCR or PIR motion detector. These devices are limited in features and functionality but offer great flexibility if portability is a requirement such as a short term stay in a property or even your garden shed, where there is no power available. Most self-contained alarm systems are powered by batteries so are great for outdoor use or vehicles such as motor homes or caravans.
2.2.4 INDOOR/OUTDOOR ALARM TYPES INDOOR These types of sensors are designed for indoor use. Outdoor use would not be advised due to false alarm vulnerability and weather durability. Passive infrared detectors The passive infrared detector (PIR) is one of the most common detectors found in household and small business environments because it offers affordable and reliable functionality. The term passive means the detector is able to function without the need to generate and radiate its own energy (unlike ultrasonic and microwave volumetric intrusion detectors that are “active” in operation). PIRs are able to distinguish if an infrared emitting object is present by first learning the ambient temperature of the monitored space and then detecting a change in the temperature caused by the presence of an object. Using the principle of differentiation, which is a check of presence or nonpresence, PIRs verify if an intruder or object is actually there. Creating individual zones of detection where each zone comprises one or more layers can achieve differentiation. Between the zones there are areas of no sensitivity (dead zones) that are used by the sensor for comparison. Ultrasonic detectors Using frequencies between 25 kHz and 75 kHz, these active detectors transmit ultrasonic sound waves that are inaudible to humans. The Doppler shift principle is the underlying method of operation, in which a change in frequency is detected due to object motion. This is caused when a moving object changes the frequency of sound waves around it. Two conditions must occur to successfully detect a Doppler shift event: * There must be motion of an object either towards or away from the receiver.
* The motion of the object must cause a change in the ultrasonic frequency to the receiver relative to the transmitting frequency. The ultrasonic detector operates by the transmitter emitting an ultrasonic signal into the area to be protected. The sound waves are reflected by solid objects (such as the surrounding floor, walls and ceiling) and then detected by the receiver. Because ultrasonic waves are transmitted through air, then hard-surfaced objects tend to reflect most of the ultrasonic energy, while soft surfaces tend to absorb most energy. When the surfaces are stationary, the frequency of the waves detected by the receiver will be equal to the transmitted frequency. However, a change in frequency will occur as a result of the Doppler principle, when a person or object is moving towards or away from the detector. Such an event initiates an alarm signal. This technology is considered obsolete by many alarm professionals, and is not actively installed. Microwave detectors This device emits microwaves from a transmitter and detects any reflected microwaves or reduction in beam intensity using a receiver. The transmitter and receiver are usually combined inside a single housing (monostatic) for indoor applications, and separate housings (bistatic) for outdoor applications. To reduce false alarms this type of detector is usually combined with a passive infra red detector or "Dualtec" alarm. By generating energy in the microwave region of the electromagnetic spectrum, detector operates as an active volumetric device that responds to: * A Doppler shift frequency change. * A frequency phase shift.
* A motion causing reduction in received energy. Glass break detectors The glass break detector may be used for internal perimeter building protection. When glass breaks it generates sound in a wide band of frequencies. These can range from infrasonic, which is below 20 hertz (Hz) and can not be heard by the human ear, through the audio band from 20 Hz to 20 kHz which humans can hear, right up to ultrasonic, which is above 20 kHz and again cannot be heard. Glass break acoustic detectors are mounted in close proximity to the glass panes and listen for sound frequencies associated with glass breaking. Seismic glass break detectors are different in that they are installed on the glass pane. When glass breaks it produces specific shock frequencies which travel through the glass and often through the window frame and the surrounding walls and ceiling. Typically, the most intense frequencies generated are between 3 and 5 kHz, depending on the type of glass and the presence of a plastic interlayer. Seismic glass break detectors “feel” these shock frequencies and in turn generate an alarm condition. Photo-electric beams Photoelectric beam systems detect the presence of an intruder by transmitting visible or infra red light beams across an area, where these beams maybe obstructed. To improve the detection surface area, the beams are often employed in stacks of two or more. However, if an intruder is aware of the technology’s presence, it can be avoided. The technology can be an effective long-range detection system, if installed in stacks of three or more where the transmitters and receivers are staggered to create a fence-like barrier. Systems are available for both internal and external applications. To prevent a clandestine attack using a secondary light source being used to hold the detector in a ‘sealed’ condition whilst an intruder passes through, most systems use and detect a modulated light source.
OUTDOOR These types of sensors would be found most of the time mounted on fences or installed on the perimeter of the protected area. Vibration (shaker) or inertia sensors These devices are mounted on barriers and are used primarily to detect an attack on the structure itself. The technology relies on an unstable mechanical configuration that forms part of the electrical circuit. When movement or vibration occurs, the unstable portion of the circuit moves and breaks the current flow, which produces an alarm. The technology of the devices varies and can be sensitive to different levels of vibration. The medium transmitting the vibration must be correctly selected for the specific sensor as they are best suited to different types of structures and configurations. A rather new and unproven type of sensors use piezo-electric components rather than mechanical circuits, which can be tuned to be extremely sensitive to vibration. * Pros: Very reliable sensors, low false alarm rate and middle place in the price range. * Cons: Must be fence mounted. The rather high price deters many customers, but its effectiveness offsets its high price. Piezo-electric sensors are a new technology with an unproven record as opposed to the mechanical sensor which in some cases has a field record in excess of 20 years. Passive magnetic field detection This buried security system is based on the Magnetic Anomaly Detection principle of operation. The system uses an electromagnetic field generator powered by two wires running in parallel. Both wires run along the perimeter and are usually installed about 5 inches apart on top of a wall or about
12"/30cm below ground. The wires are connected to a signal processor which analyzes any change in the magnetic field. This kind of buried security system sensor cable could be buried on the top of almost any kind of wall to provide a regular wall detection ability or be buried in the ground. * Pros: Very low false alarm rate, can be put on top of any wall, very high chance of detecting real burglars. * Cons: Cannot be installed near high voltage lines, radars, or airports. E-field This proximity system can be installed on building perimeters, fences, and walls. It also has the ability to be installed free standing on dedicated poles. The system uses an electromagnetic field generator powering one wire, with another sensing wire running parallel to it. Both wires run along the perimeter and are usually installed about 800 millimetres apart. The sensing wire is connected to a signal processor that analyses: * Amplitude change (mass of intruder), * Rate change (movement of intruder), * Preset disturbance time (time the intruder is in the pattern). These items define the characteristics of an intruder and when all three are detected simultaneously, an alarm signal is generated. The barrier can provide protection from the ground to about 4 metres of altitude. It is usually configured in zones of about 200 metre lengths depending on the number of sensor wires installed.
* Pros: concealed as a buried form. * Cons: expensive, short zones which mean more electronics (more money), high rate of false alarms as it cannot distinguish a cat from a human. In reality it doesn't work that well, as extreme weather causes false alarms. Microwave barriers The operation of a microwave barrier is very simple. This type of device produces an electromagnetic beam using high frequency waves that pass from the transmitter to the receiver, creating an invisible but sensitive wall of protection. When the receiver detects a difference of condition within the beam (and hence a possible intrusion), the system begins a detailed analysis of the situation. If the system considers the signal a real intrusion, it provides an alarm signal that can be treated in analog or digital form. * Pros: Low cost, easy to install, invisible perimeter barrier, unknown perimeter limits to the intruder. * Cons: Extremely sensitive to weather as rain, snow and fog for example would cause the sensors to stop working, need sterile perimeter line because trees, bushes or anything that blocks the beam would cause false alarm or lack of detection.
Micro phonic systems Micro phonic based systems vary in design but each is generally based on the detection of an intruder attempting to cut or climb over a chain wire fence. Usually the micro phonic detection systems are installed as sensor cables attached to rigid chain wire fences, however some specialized versions of these systems can also be installed as buried systems underground. Depending on the version selected,
it can be sensitive to different levels of noise or vibration. The system is based on coaxial or electromagnetic sensor cable with the controller having the ability to differentiate between signals from the cable or chain wire being cut, an intruder climbing the fence, or bad weather conditions. The systems are designed to detect and analyze incoming electronic signals received from the sensor cable, and then to generate alarms from signals which exceed preset conditions. The systems have adjustable electronics to permit installers to change the sensitivity of the alarm detectors to the suit specific environmental conditions. The tuning of the system is usually accomplished during commissioning of the detection devices. * Pros: Very cheap, very simple configuration, easy to install. * Cons: Some systems have a high rate of false alarms because some of these sensors might be too sensitive. Although systems using DSP (Digital Signal Processing) will largely eliminated false alarms on some cases. Taut wire fence systems A taut wire perimeter security system is basically an independent screen of tensioned tripwires usually mounted on a fence or wall. Alternatively, the screen can be made so thick that there is no need for a supporting chainwire fence. These systems are designed to detect any physical attempt to penetrate the barrier. Taut wire systems can operate with a variety of switches or detectors that sense movement at each end of the tensioned wires. These switches or detectors can be a simple mechanical contact, static force transducer or an electronic strain gauge. Unwanted alarms caused by animals and birds can be avoided by adjusting the sensors to ignore objects that exert small amounts of pressure on the wires. This type of system is vulnerable to intruders digging under the fence. A concrete footing directly below the fence is installed to prevent this type of attack.
* Pros: low rate of false alarms, very reliable sensors and high rate of detection. * Cons: Very expensive, complicated to install and old technology. Fibre optic cable A fibre-optic cable can be used to detect intruders by measuring the difference in the amount of light sent through the fibre core. If the cable is disturbed, light will ‘leak’ out and the receiver unit will detect a difference in the amount of light received. The cable can be attached directly to a chain wire fence or bonded into a barbed steel tape that is used to protect the tops of walls and fences. This type of barbed tape provides a good physical deterrent as well as giving an immediate alarm if the tape is cut or severely distorted. Other type’s works on the detection of change in polarization which is caused by fiber position change. * Pros: Very similar to the Micro phonic system, very simple configuration, easy to install. Can detect for distances of several km on a single processor. * Cons: High rate of false alarm or no alarms at all for systems using light that leaks out of the optical fiber. The polarization changing system is much more sensitive but false alarms depend on the alarm processing. H-field This system employs an electro-magnetic field disturbance principle based on two unshielded (or ‘leaky’) coaxial cables buried about 10–15 cm deep and located at about 1 metre apart. The transmitter emits continuous Radio Frequency (RF) energy along one cable and the energy is received by the other cable. When the change in field strength weakens due to the presence of an object and reaches a pre-set lower threshold, an alarm condition is generated. The system is unobtrusive when it has been installed
correctly, however care must be taken to ensure the surrounding soil offers good drainage in order to reduce nuisance alarms. * Pros: concealed as a buried form, low rate of false alarms. * Cons: can be affected by RF noise, high rate of false alarms, hard to install. 2.3 MICROCONTROLLERS A microcontroller (sometimes abbreviated μC, uC or MCU) is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals. Program memory in the form of NOR flash or OTP ROM is also often included on chip, as well as a typically small amount of RAM. Microcontrollers are designed for embedded applications, in contrast to the microprocessors used in personal computers or other general purpose applications. Microcontrollers are used in automatically controlled products and devices, such as automobile engine control systems, implantable medical devices, remote controls, office machines, appliances, power tools, and toys. By reducing the size and cost compared to a design that uses a separate microprocessor, memory, and input/output devices, microcontrollers make it economical to digitally control even more devices and processes. Mixed signal microcontrollers are common, integrating analog components needed to control non-digital electronic systems. Some microcontrollers may use four-bit words and operate at clock rate frequencies as low as 4 kHz, for low power consumption (milliwatts or microwatts). They will generally have the ability to retain functionality while waiting for an event such as a button press or other interrupt; power consumption while sleeping (CPU clock and most peripherals off) may be just nanowatts, making many of them well suited for long lasting battery applications. Other microcontrollers may serve performance-critical roles,
where they may need to act more like a digital signal processor (DSP), with higher clock speeds and power consumption. 2.3.1 8051 MICROCONTROLLER The Intel MCS-51 is a Harvard architecture, single chip microcontroller (μC) series which was developed by Intel in 1980 for use in embedded systems. Intel's original versions were popular in the 1980s and early 1990s, but has today[update] largely been superseded by a vast range of faster and/or functionally enhanced 8051-compatible devices manufactured by more than 20 independent manufacturers including Atmel, Infineon Technologies (formerly Siemens AG), Maxim Integrated Products (via its Dallas Semiconductor subsidiary), NXP (formerly Philips Semiconductor), Nuvoton (formerly Winbond), ST Microelectronics, Silicon Laboratories (formerly Cygnal), Texas Instruments and Cypress Semiconductor. Intel's original MCS-51 family was developed using NMOS technology, but later versions, identified by a letter C in their name (e.g., 80C51) used CMOS technology and were less power-hungry than their NMOS predecessors. This made them more suitable for battery-powered devices. Important features and applications INTEL R8751HIt provides many functions (CPU, RAM, ROM, I/O, interrupt logic, timer, etc.) in a single package ■8-bit ALU, Accumulator and 8-bit Registers; hence it is an 8-bit microcontroller ■8-bit data bus – It can access 8 bits of data in one operation ■16-bit address bus – It can access 216 memory locations – 64 KB (65536 locations) each of RAM and ROM ■On-chip RAM – 128 bytes (data memory)
■On-chip ROM – 4 kByte (program memory) ■Four byte bi-directional input/output port ■UART (serial port) ■Two 16-bit Counter/timers ■Two-level interrupt priority ■Power saving mode (on some derivatives) A particularly useful feature of the 8051 core is the inclusion of a boolean processing engine which allows bit-level boolean logic operations to be carried out directly and efficiently on internal registers and RAM. This feature helped cement the 8051's popularity in industrial control applications. Another valued feature is that it has four separate register sets, which can be used to greatly reduce interrupt latency compared to the more common method of storing interrupt context on a stack. The MCS-51 UARTs make it simple to use the chip as a serial communications interface. External pins can be configured to connect to internal shift registers in a variety of ways, and the internal timers can also be used, allowing serial communications in a number of modes, both synchronous and asynchronous. Some modes allow communications with no external components. A mode compatible with an RS-485 multi-point communications environment is achievable, but the 8051's real strength is fitting in with existing ad-hoc protocols (e.g., when controlling serial-controlled devices). Once a UART, and a timer if necessary, have been configured, the programmer needs only to write a simple interrupt routine to refill the send shift register whenever the last bit is shifted out by the UART and/or empty the full receive shift register (copy the data somewhere else). The main program then performs serial reads and writes simply by reading and writing 8-bit data to stacks.
MCS-51 based microcontrollers typically include one or two UARTs, two or three timers, 128 or 256 bytes of internal data RAM (16 bytes of which are bit-addressable), up to 128 bytes of I/O, 512 bytes to 64 kB of internal program memory, and sometimes a quantity of extended data RAM (ERAM) located in the external data space. The original 8051 core ran at 12 clock cycles per machine cycle, with most instructions executing in one or two machine cycles. With a 12 MHz clock frequency, the 8051 could thus execute 1 million one-cycle instructions per second or 500,000 two-cycle instructions per second. Enhanced 8051 cores are now commonly used which run at six, four, two, or even one clock per machine cycle, and have clock frequencies of up to 100 MHz, and are thus capable of an even greater number of instructions per second. All SILabs, some Dallas and a few Atmel devices have single cycle cores. Common features included in modern 8051 based microcontrollers include built-in reset timers with brown-out detection, on-chip oscillators, self-programmable Flash ROM program memory, bootloader code in ROM, EEPROM non-volatile data storage, I²C, SPI, and USB host interfaces, CAN or LIN bus, PWM generators, analog comparators, A/D and D/A converters, RTCs, extra counters and timers, in-circuit debugging facilities, more interrupt sources, and extra power saving modes. Memory Architecture The MCS-51 has four distinct types of memory – internal RAM, special function registers, program memory, and external data memory. Internal RAM (IRAM) is located from address 0 to address 0xFF. IRAM from 0x00 to 0x7F can be accessed directly, and the bytes from 0x20 to 0x2F are also bit-addressable. IRAM from 0x80 to 0xFF must be accessed indirectly, using the @R0 or @R1 syntax, with the address to access loaded in R0 or R1.
Special function registers (SFR) are located from address 0x80 to 0xFF, and are accessed directly using the same instructions as for the lower half of IRAM. Some of the SFR's are also bit-addressable. Program memory (PMEM, though less common in usage than IRAM and XRAM) is located starting at address 0. It may be on- or off-chip, depending on the particular model of chip being used. Program memory is read-only, though some variants of the 8051 use on-chip flash memory and provide a method of re-programming the memory in-system or in-application. Aside from storing code, program memory can also store tables of constants that can be accessed by MOVC A, @DPTR, using the 16-bit special function register DPTR. External data memory (XRAM) also starts at address 0. It can also be on- or off-chip; what makes it "external" is that it must be accessed using the MOVX (Move eXternal) instruction. Many variants of the 8051 include the standard 256 bytes of IRAM plus a few KB of XRAM on the chip. If more XRAM is required by an application, the internal XRAM can be disabled, and all MOVX instructions will fetch from the external bus. 3.3. MICROCONTROLLER PROGRAMMING 3.3.1 ASSEMBLY LANGUAGE An assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other integrated circuits. It implements a symbolic representation of the binary machine codes and other constants needed to program a given CPU architecture. This representation is usually defined by the hardware manufacturer, and is based on mnemonics that symbolize processing steps (instructions), processor registers, memory locations, and other language features. An assembly language is thus specific to a certain physical (or virtual) computer architecture. This is in contrast to most high-level programming languages, which are ideally portable.
A utility program called an assembler is used to translate assembly language statements into the target computer's machine code. The assembler performs a more or less isomorphic translation (a one-to-one mapping) from mnemonic statements into machine instructions and data. This is in contrast with highlevel languages, in which a single statement generally results in many machine instructions. Many sophisticated assemblers offer additional mechanisms to facilitate program development, control the assembly process, and aid debugging. In particular, most modern assemblers include a macro facility (described below), and are called macro assemblers
Key concepts Assembler Typically a modern assembler creates object code by translating assembly instruction mnemonics into opcodes, and by resolving symbolic names for memory locations and other entities. The use of symbolic references is a key feature of assemblers, saving tedious calculations and manual address updates after program modifications. Most assemblers also include macro facilities for performing textual substitution—e.g., to generate common short sequences of instructions as inline, instead of called subroutines, or even generate entire programs or program suites. Assemblers are generally simpler to write than compilers for high-level languages, and have been available since the 1950s. Modern assemblers, especially for RISC based architectures, such as MIPS, Sun SPARC, and HP PA-RISC, as well as x86(-64), optimize instruction scheduling to exploit the CPU pipeline efficiently. There are two types of assemblers based on how many passes through the source are needed to produce the executable program.
-
One-pass assemblers go through the source code once and assume that all symbols will be defined before any instruction that references them.
-
Two-pass assemblers create a table with all symbols and their values in the first pass, then use the table in a second pass to generate code. The assembler must at least be able to determine the length of each instruction on the first pass so that the addresses of symbols can be calculated.
The advantage of a one-pass assembler is speed, which is not as important as it once was with advances in computer speed and abilities. The advantage of the two-pass assembler is that symbols can be defined anywhere in program source code. This lets programs be defined in more logical and meaningful ways, making two-pass assembler programs easier to read and maintain. -More sophisticated high-level assemblers provide language abstractions such as: -Advanced control structures -High-level procedure/function declarations and invocations -High-level abstract data types, including structures/records, unions, classes, and sets -Sophisticated macro processing (although available on ordinary assemblers since late 1960s for IBM/360, amongst other machines) -Object-oriented programming features such as encapsulation, polymorphism, inheritance, interfaces Assembly language
A program written in assembly language consists of a series of instructions - mnemonics that correspond to a stream of executable instructions, when translated by an assembler, that can be loaded into memory and executed. For example, an x86/IA-32 processor can execute the following binary instruction ('MOV') as expressed in machine language: Hexadecimal: B0 61
(Binary: 10110000 01100001)
The equivalent assembly language representation is easier to remember (example in Intel syntax, more mnemonic): MOV AL, 61h This instruction means: Move (really a copy) the hexadecimal value '61' into the processor register named "AL". (The h-suffix means hexadecimal; 61h = 97 in decimal) The mnemonic "mov" represents the opcode 10110000 which actually copies the value in the second operand into the register indicated by the first operand. The mnemonic was chosen by the designer of the instruction set to abbreviate "move", making it easier for programmers to remember. Typical of an assembly language statement, a comma-separated list of arguments or parameters follows the opcode. The mnemonic "mov" may refer to a family of numeric opcodes that do the same thing, but imply different registers. The opcode 10110000 specifically copies an 8-bit value into the register AL. The opcode 10100001 is also denoted by the mnemonic "mov", but instead copies a 16-bit value into the register AX, and gets it by reading from system memory (the second operand says where) instead of copying the value of the operand itself.
Transforming assembly into machine language is performed by an assembler, and the (partial) reverse by a disassembler. Unlike high-level languages, there is usually a one-to-one correspondence between simple assembly statements and machine language instructions. However, in some cases, an assembler may provide pseudo instructions (essentially macros) which expand into several machine language instructions to provide commonly needed functionality. For example, for a machine that lacks a "branch if greater or equal" instruction, an assembler may provide a pseudo instruction that expands to the machine's "set if less than" and "branch if zero (on the result of the set instruction)". Most full-featured assemblers also provide a rich macro language (discussed below) which is used by vendors and programmers to generate more complex code and data sequences. Each computer architecture and processor architecture usually has its own machine language. On this level, each instruction is simple enough to be executed using a relatively small number of electronic circuits. Computers differ by the number and type of operations they support. For example, a new 64-bit machine would have different circuitry from a 32-bit machine. They may also have different sizes and numbers of registers, and different representations of data types in storage. While most generalpurpose computers are able to carry out essentially the same functionality, the ways they do so differ; the corresponding assembly languages reflect these differences. Multiple sets of mnemonics or assembly-language syntax may exist for a single instruction set, typically instantiated in different assembler programs. In these cases, the most popular one is usually that supplied by the manufacturer and used in its documentation.
Use of assembly language Historical perspective Assembly languages were first developed in the 1950s, when they were referred to as second generation programming languages. They eliminated much of the error-prone and time-consuming firstgeneration programming needed with the earliest computers, freeing programmers from tedium such as remembering numeric codes and calculating addresses. They were once widely used for all sorts of programming. However, by the 1980s (1990s on microcomputers), their use had largely been supplanted by high-level languages[citation needed], in the search for improved programming productivity. Today, although assembly language is almost always handled and generated by compilers, it is still used for direct hardware manipulation, access to specialized processor instructions, or to address critical performance issues. Typical uses are device drivers, low-level embedded systems, and real-time systems. Historically, a large number of programs have been written entirely in assembly language. Operating systems were almost exclusively written in assembly language until the widespread acceptance of C in the 1970s and early 1980s. Many commercial applications were written in assembly language as well, including a large amount of the IBM mainframe software written by large corporations. COBOL and FORTRAN eventually displaced much of this work, although a number of large organizations retained assembly-language application infrastructures well into the 90s. Most early microcomputers relied on hand-coded assembly language, including most operating systems and large applications. This was because these systems had severe resource constraints, imposed idiosyncratic memory and display architectures, and provided limited, buggy system services. Perhaps more important was the lack of first-class high-level language compilers suitable for microcomputer use.
A psychological factor may have also played a role: the first generation of microcomputer programmers retained a hobbyist, "wires and pliers" attitude. In a more commercial context, the biggest reasons for using assembly language were minimal bloat (size), minimal overhead, greater speed, and reliability. Typical examples of large assembly language programs from this time are IBM PC DOS operating systems and early applications such as the spreadsheet program Lotus 1-2-3, and almost all popular games for the Atari 800 family of home computers. Even into the 1990s, most console video games were written in assembly, including most games for the Mega Drive/Genesis and the Super Nintendo Entertainment System. According to some industry insiders, the assembly language was the best computer language to use to get the best performance out of the Sega Saturn, a console that was notoriously challenging to develop and program games for. The popular arcade game NBA Jam (1993) is another example. On the Commodore 64, Amiga, Atari ST, as well as ZX Spectrum home computers, assembler has long been the primary development language. This was in large part because BASIC dialects on these systems offered insufficient execution speed, as well as insufficient facilities to take full advantage of the available hardware on these systems. Some systems, most notably Amiga, even have IDEs with highly advanced debugging and macro facilities, such as the freeware ASM-One assembler, comparable to that of Microsoft Visual Studio facilities (ASM-One predates Microsoft Visual Studio). The Assembler for the VIC-20 was written by Don French and published by French Silk. At 1639 bytes in length, its author believes it is the smallest symbolic assembler ever written. The assembler supported the usual symbolic addressing and the definition of character strings or hex strings. It also allowed address expressions which could be combined with addition, subtraction, multiplication, division, logical AND, logical OR, and exponentiation operators. Current usage
There have always been debates over the usefulness and performance of assembly language relative to high-level languages. Assembly language has specific niche uses where it is important; see below. But in general, modern optimizing compilers are claimed to render high-level languages into code that can run as fast as hand-written assembly, despite the counter-examples that can be found. The complexity of modern processors and memory sub-system makes effective optimization increasingly difficult for compilers, as well as assembly programmers. Moreover, and to the dismay of efficiency lovers, increasing processor performance has meant that most CPUs sit idle most of the time, with delays caused by predictable bottlenecks such as I/O operations and paging. This has made raw code execution speed a non-issue for many programmers. There are some situations in which practitioners might choose to use assembly language, such as when: -A stand-alone binary executable is required, i.e. one that must execute without recourse to the runtime components or libraries associated with a high-level language; this is perhaps the most common situation. These are embedded programs that store only a small amount of memory and the device is intended to do single purpose tasks. Such examples consist of telephones, automobile fuel and ignition systems, air-conditioning control systems, security systems, and sensors. -Interacting directly with the hardware, for example in device drivers and interrupt handlers. -Using processor-specific instructions not exploited by or available to the compiler. A common example is the bitwise rotation instruction at the core of many encryption algorithms. -Creating vectorized functions for programs in higher-level languages such as C. In the higher-level language this is sometimes aided by compiler intrinsic functions which map directly to SIMD mnemonics, but nevertheless result in a one-to-one assembly conversion specific for the given vector processor.
-Extreme optimization is required, e.g., in an inner loop in a processor-intensive algorithm. Game programmers take advantage of the abilities of hardware features in systems, enabling games to run faster. Also large scientific simulations require highly optimized algorithms, e.g. linear algebra with BLAS or discrete cosine transformation (e.g. SIMD assembly version from x264[16]) -A system with severe resource constraints (e.g., an embedded system) must be hand-coded to maximize the use of limited resources; but this is becoming less common as processor price decreases and performance improves. -No high-level language exists, on a new or specialized processor, e.g. writing real-time programs that need precise timing and responses, such as simulations, flight navigation systems, and medical equipment. For example, in a fly-by-wire system, telemetry must be interpreted and acted upon within strict time constraints. Such systems must eliminate sources of unpredictable delays, which may be created by (some) interpreted languages, automatic garbage collection, paging operations, or preemptive multitasking. However, some higher-level languages incorporate run-time components and operating system interfaces that can introduce such delays. Choosing assembly or lower-level languages for such systems gives programmers greater visibility and control over processing details. -Complete control over the environment is required, in extremely high security situations where nothing can be taken for granted. -Writing computer viruses, boot loaders, certain device drivers, or other items very close to the hardware or low-level operating system. -Writing instruction set simulators for monitoring, tracing and debugging where additional overhead is kept to a minimum.
-Reverse-engineering existing binaries that may or may not have originally been written in a highlevel language, for example when cracking copy protection of proprietary software. -Reverse engineering and modifying video games (also termed ROM hacking), which is possible via several methods. The most widely employed is altering program code at the assembly language level. -Writing self modifying code, to which assembly language lends itself well. -Writing games and other software for graphing calculators. -Writing compiler software that generates assembly code, and the writers should therefore be expert assembly language programmers themselves. -Writing cryptographic algorithms that must always take strictly the same time to execute, preventing timing attacks. Nevertheless, assembly language is still taught in most computer science and electronic engineering programs. Although few programmers today regularly work with assembly language as a tool, the underlying concepts remain very important. Such fundamental topics as binary arithmetic, memory allocation, stack processing, character set encoding, interrupt processing, and compiler design would be hard to study in detail without a grasp of how a computer operates at the hardware level. Since a computer's behavior is fundamentally defined by its instruction set, the logical way to learn such concepts is to study an assembly language. Most modern computers have similar instruction sets. Therefore, studying a single assembly language is sufficient to learn: i) the basic concepts; ii) to recognize situations where the use of assembly language might be appropriate; and iii) to see how efficient executable code can be created from high-level languages. Typical applications
Hard-coded assembly language is typically used in a system's boot ROM (BIOS on IBM-compatible PC systems). This low-level code is used, among other things, to initialize and test the system hardware prior to booting the OS, and is stored in ROM. Once a certain level of hardware initialization has taken place, execution transfers to other code, typically written in higher level languages; but the code running immediately after power is applied is usually written in assembly language. The same is true of most boot loaders. Many compilers render high-level languages into assembly first before fully compiling, allowing the assembly code to be viewed for debugging and optimization purposes. Relatively low-level languages, such as C, often provide special syntax to embed assembly language directly in the source code. Programs using such facilities, such as the Linux kernel, can then construct abstractions using different assembly language on each hardware platform. The system's portable code can then use these processor-specific components through a uniform interface. Assembly language is also valuable in reverse engineering, since many programs are distributed only in machine code form, and machine code is usually easy to translate into assembly language and carefully examine in this form, but very difficult to translate into a higher-level language. Tools such as the Interactive Disassembler make extensive use of disassembly for such a purpose. One niche that makes use of assembly language is the demoscene. Certain competitions require contestants to restrict their creations to a very small size (e.g. 256B, 1KB, 4KB or 64 KB), and assembly language is the language of choice to achieve this goal.[19] When resources, especially CPU processingconstrained systems, like the earlier Amiga models, and the Commodore 64, are a concern, assembler coding is a must. Optimized assembler code is written "by hand" and instructions are sequenced manually by programmers in an attempt to minimize the number of CPU cycles used. The CPU constraints are so great that every CPU cycle counts. However, using such methods has enabled systems
like the Commodore 64 to produce real-time 3D graphics with advanced effects, a feat which might be considered unlikely or even impossible for a system with a 0.99MHz processor. 3.3.2 C PROGRAMMING LANGUAGE & ITS BENEFITS C is a general-purpose computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. Although C was designed for implementing system software, it is also widely used for developing portable application software. C is one of the most popular programming languages of all time and there are very few computer architectures for which a C compiler does not exist. C has greatly influenced many other popular programming languages, most notably C++, which began as an extension to C. Design C is an imperative (procedural) systems implementation language. It was designed to be compiled using a relatively straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal run-time support. C was therefore useful for many applications that had formerly been coded in assembly language. Despite its low-level capabilities, the language was designed to encourage cross-platform programming. A standards-compliant and portably written C program can be compiled for a very wide variety of computer platforms and operating systems with little or no change to its source code. The language has become available on a very wide range of platforms, from embedded microcontrollers to supercomputers. Minimalism
C's design is tied to its intended use as a portable systems implementation language. It provides simple, direct access to any addressable object (for example, memory-mapped device control registers), and its source-code expressions can be translated in a straightforward manner to primitive machine operations in the executable code. Some early C compilers were comfortably implemented (as a few distinct passes communicating via intermediate files) on PDP-11 processors having only 16 address bits; however, C99 assumes a 512 KB minimum compilation platform. Target platforms for C programs range from 8-bit microcontrollers to supercomputers. Characteristics Like most imperative languages in the ALGOL tradition, C has facilities for structured programming and allows lexical variable scope and recursion, while a static type system prevents many unintended operations. In C, all executable code is contained within functions. Function parameters are always passed by value. Pass-by-reference is simulated in C by explicitly passing pointer values. Heterogeneous aggregate data types (struct) allow related data elements to be combined and manipulated as a unit. C program source text is free-format, using the semicolon as a statement terminator.
C also exhibits the following more specific characteristics: •Variables may be hidden in nested blocks •Partially weak typing; for instance, characters can be used as integers •Low-level access to computer memory by converting machine addresses to typed pointers •Function and data pointers supporting ad hoc run-time polymorphism •array indexing as a secondary notion, defined in terms of pointer arithmetic
•A preprocessor for macro definition, source code file inclusion, and conditional compilation •Complex functionality such as I/O, string manipulation, and mathematical functions consistently delegated to library routines •A relatively small set of reserved keywords •A large number of compound operators, such as +=, -=, *=, ++ etc.
C's lexical structure resembles B more than ALGOL. For example: •{ ... } rather than begin ... end •= is used for assignment (copying), like Fortran, rather than ALGOL's := •== is used to test for equality (rather than .EQ. in Fortran, or = in BASIC and ALGOL) •Logical "and" and "or" are represented with && and ||, which don't evaluate the right operand if the result can be determined from the left alone (short-circuit evaluation), and are semantically distinct from the bit-wise operators & and | BENEFITS OF C PROGRAMMING C is often used for "system programming", including implementing operating systems and embedded system applications, due to a combination of desirable characteristics such as code portability and efficiency, ability to access specific hardware addresses, ability to pun types to match externally imposed data access requirements, and low runtime demand on system resources. C can also be used for website programming using CGI as a "gateway" for information between the Web application, the
server, and the browser. Some reasons for choosing C over interpreted languages are its speed, stability, and near-universal availability. One consequence of C's wide acceptance and efficiency is that compilers, libraries, and interpreters of other programming languages are often implemented in C. The primary implementations of Python (CPython), Perl 5, and PHP are all written in C. Due to its thin layer of abstraction and low overhead, C allows efficient implementations of algorithms and data structures, which is useful for programs that perform a lot of computations. For example, the GNU Multi-Precision Library, the GNU Scientific Library, Mathematica and MATLAB are completely or partially written in C. C is sometimes used as an intermediate language by implementations of other languages. This approach may be used for portability or convenience; by using C as an intermediate language, it is not necessary to develop machine-specific code generators. Some languages and compilers which have used C this way are BitC, C++, Eiffel, Gambit, GHC, Squeak, and Vala. However, C was designed as a programming language, not as a compiler target language, and is thus less than ideal for use as an intermediate language. This has led to development of C-based intermediate languages such as C--. C has also been widely used to implement end-user applications, but much of that development has shifted to newer languages. C can be used to write codes for a large number of platforms – everything from microcontrollers to the most advanced scientific systems can be written in C.