OCCUPANCY SENSOR AND METHOD OF OPERATING SAME

Abstract: An occupancy sensor that provides improved performance by the inclusion of a microprocessor that controls the sensing transducers and processes the received signal to optimize desired detection performance. The occupancy sensor includes a quadrature detection technique and automatic sensitivity adjustment that reduce false detection caused by air flow, hallway traffic and other noise sources. A fault detection method executed periodically detects fault conditions in the sensor or sensing area caused by component failure or obstructions in front of the sensor. Transmitter power is varied depending on the size of the desired coverage area. Since various ambient parameters such as line voltage, light level, and temperature may be easily and usefully monitored, the microprocesor may use these variables to make intelligent decisions in controlling electrical loads, such as building lighting and ventilation.

Description: DESCRIPTION OCCUPANCY SENSOR AND METHOD OF OPERATING SAME BACKGROUND OF THE INVENTION The present invention relates to occupancy sensors. An occupancy sensor is designed to detect the presence of a person(s) in a room, usually in order to determine whether various electrically powered loads in that room (for example, lights, ventilation, and the like) should be turned on or not. This is of particular advantage to institutions that have visitors who are not directly responsible for paying for the electricity they consume, since these people often do not exercise diligence in regularly turning off electrically powered loads, such as lights, ventilation, and the like, when they leave a room. Occupancy sensors may therefore conserve a great deal of energy. This has led many businesses to purchase them voluntarily; it has also resulted in laws in certain states mandating the use of occupancy sensors in large areas as an environmental conservation measure. The two most prevalent types of occupancy sensors are passive infrared and active ultrasonic devices. A passive infrared ("PIR") sensor will turn on the load whenever it detects a moving or newly apparent heat source. An active ultrasonic sensor emits vibrations at frequencies of 25 kHz or higher and listens to the return echoes; if it detects a significant Doppler shift, indicating the presence of a moving body, then it turns the load on. Either detector will turn the load back off after a certain interval of no motion sensed, usually three to sixty minutes as determined by the user. The motion sensitivity of the device is usually also set by the user. Each of these sensors is not without disadvantage. PIR sensors may not be able to sense motion behind a barrier within a room, such as a modesty wall in a restroom. In addition, PIR sensors may be susceptible to "dead spots" in certain rooms, within which they are less sensitive to heat sources. Ultrasonic sensors do not share these handicaps, since the sonic energy they emit will fill the room. However, they may be susceptible to false triggering from several sources. For example, an ultrasonic sensor placed on the wall next to a door may send some sonic energy into the corridor outside the room, and motion within the corridor may make the sensor react as though there were motion in the room resulting in a sensing error. In addition, air motion from wind and ventilation may trip an ultrasonic sensor by mistake. This difficulty is often exacerbated by the user setting the sensitivity of the ultrasonic sensor too high which can increase susceptibility to false tripping. SUMMARY OF THE INVENTION The present invention avoids the above-noted discrepancies in prior approaches by providing a method and apparatus for controlling an electrical load based upon occupancy of a space. The invention generates an occupancy signal that is indicative of motion within a space. Then, the occupancy signal is digitized, for example, by an analog-to-digital converter, to produce a digitized occupancy signal having digital values indicative of a magnitude of the occupancy signal at controllable sampling intervals. Then, the occupancy signal is processed, for example, by a programmed microprocessor, to provide an indication of motion within the space. Finally, the electrical load is automatically energized and de-energized as a function of the indication of motion within the space. The electrical load may be controlled by a relay, silicon controlled rectifier or triac, or similar controllable switching device. Another feature of the invention is the energization of the load substantially contemporaneous with the zero-crossing of an A/C source used to power the load. The load may be, for example, a lighting device or a ventilation system, such as a heating and/or air conditioning system. The occupancy signal may be generated either actively or passively. An example of the active generation of the occupancy signal is the transmitting of ultrasonic energy into the space, and the subsequent detecting of ultrasonic energy reflected from the space. Alternatively, or in combination with active generation of the occupancy signal, the occupancy signal may be generated passively, for example, by a passive infrared detector that detects heat sources within the space. Another feature of the invention is the detection of environmental conditions within the space, for example, ambient light and temperature. When generating the occupancy signal through the use of ultrasonic means, a feature of the invention is the transmission of ultrasonic energy pulses into the space at controlled time intervals, subsequently detecting the ultrasonic pulses reflected from the space to produce the occupancy signal, and sampling the occupancy signal as a function of the controlled time intervals. The sampling may occur at integer multiples of the controlled time intervals, and the sampling may occur at time intervals that are synchronized with the transmission of the ultrasonic energy pulses. Yet another feature of the invention is the sampling of the occupancy signal in quadrature synchronized with the transmitting of the ultrasonic energy pulses, thus permitting the assessment of a Doppler shift between the transmitted ultrasonic energy pulses and the quadrature samples. The assessment of this Doppler shift permits discrimination of the type of motion within the space, for example, toward or away from the sensor, which allows processing of the occupancy signal based upon a direction of detected motion. Other features of the invention include the automatic adjustment of sensitivity in processing the occupancy signal as a function of the shape or configuration of the space being sensed, or as a function of the history of the occupancy signal. Thus, occupancy sensing may be made more or less sensitive to detection of motion within the space, depending upon the shape or configuration of the space, or depending upon the historical movement of people within the space. Yet other features of the invention includes automatically self testing the sensor to ensure proper operation, and the dithering of the occupancy signal, prior to digitization, in order to minimize the deleterious effects of noise on the occupancy signal. These, and other features and advantages of the present invention, will become apparent to those of ordinary skill in this technology, with reference to the following figures and detailed description. BRIEF DESCRIPTION OF THE DRAWINGS FIG. 1 is a global block diagram of the device of the present invention. FIG. 2 is a more detailed block diagram of the device of FIG. 1. FIG. 3 is a schematic diagram of the occupancy- sensing hardware in an ultrasonic sensor usable in the device of FIG. 1 and FIG. 2, including manual sensitivity and timer adjustments. FIG. 4 is a schematic diagram of the occupancy- sensing hardware in a PIR sensor usable in the device of FIG. 1 and FIG. 2, including manual sensitivity and timer adjustments. FIG. 5 is a schematic diagram of the hardware in a dual-technology (i.e., ultrasonic and PIR) sensor usable in the device of FIG. 1 and FIG. 2, including manual sensitivity and timer adjustments. FIG. 6 is a schematic diagram of a relay driver circuit for a sensor with an internal relay for switching power on and off to the lighting load usable in the device of FIG. 1 and FIG. 2. FIG. 7 is a schematic diagram of a silicon controlled rectifier (SCR) driver circuit for a sensor with an internal SCR for switching power on and off to the load usable in the device of FIG. 1 and FIG. 2. FIG. 8 is a schematic diagram of a triac driver circuit for a sensor which lacks an internal relay for switching power on and off to the lighting load usable in the device of FIG. 1 and FIG. 2. FIG. 9 is a schematic diagram of a temperature- activated overload detection circuit usable in the device of FIG. 1 and FIG. 2. FIG. 10 is a schematic diagram of a light-level sensing circuit usable in the device of FIG. 1 and FIG. 2. FIG. 11 is a schematic diagram of the circuitry to recognize the presence of a self-test signal echo usable in the device of FIG. 1 and FIG. 2. FIG. 12 is an illustration of a small variation in a large carrier echo in accordance with the present invention. FIG. 13 is a schematic of a circuit which provides synchronous peak detection for use in the device of FIG. 1 and FIG. 2. FIG. 14 is a timeline of events during synchronous peak detection in accordance with the present invention. FIG. 15 is a global flowchart of the operation of the device of FIG. 1 and FIG. 2 in accordance with the method of the present invention. FIG. 16 is a flowchart of the initialization procedure of the present invention. FIG. 17 is a flowchart of the method which configures the sensor in accordance with the present invention. FIG. 18A and FIG. 18B are a flowchart of the method that sets up the sensor self-test in accordance with the present invention. FIG. 19A and FIG. 19B are a flowchart of the method that takes a quadrature sampling of the signal received by the sensor in accordance with the present invention. FIG. 20 is a flowchart of the bandpass filter method in accordance with the present invention. FIG. 21 is a schematic of the equivalent circuit of the bandpass filter of FIG. 20 in accordance with the present invention. FIG. 22 is a flowchart of the method that detects the presence or absence of AC power to the load in accordance with the present invention. FIG. 23A, FIG. 23B, and FIG. 23C are a flowchart of the method that determines whether the space is occupied or not in accordance with the present invention. FIG. 24 is a flowchart of the method that updates the sensitivity based upon the user's adjustments and the activity within the space in accordance with the present invention. FIG. 25 is a flowchart of the automatic gain setback method in accordance with the present invention. FIG. 26 is a flowchart of the method that accomplishes zero-cross switching and automatic timer adjustment in accordance with the present invention. FIG. 27 is a flowchart of the interrupt-driven transmitter driver routine in accordance with the present invention. FIG. 28 is a depiction of the bandpass filter response in accordance with the present invention. FIG. 29 is a diagram of a sensor testing for a complete signal path in accordance with the present invention. FIG. 30 is a picture of the receiver signal during self-test in accordance with the present invention. FIG. 31 is a timeline depicting the sensor adjusting its sensitivity downward in accordance with the present invention. FIG. 32 is a timeline depicting the sensor adjusting its sensitivity upward in accordance with the present invention. DETAILED DESCRIPTION The overall sensor system of the present invention is illustrated in FIG. 1. The first stage is the intelligence signal receiver 10, the output of which undergoes amplification and some elementary analog signal processing in the amplifier 11. The modified signal is then fed to the central element of the system, the digital signal processor (DSP) and system control 12, which includes a microprocessor and its ancillary hardware. This stage then affects the environment via its controlled outputs 13, for example, signals to turn the load on and off, an output ultrasonic signal if applicable, a status indicator, etc. FIG. 2 is a more detailed breakdown of the components of the generalized system shown in FIG. 1. In addition to the receiver 10 and the analog amplifier 11, there are several subsystems within the sensor. The microprocessor 14 is the heart of the system, providing both signal filtering and algorithmic control of the controlled output 13. The microprocessor selected should be fast in order to drive ultrasonic transducers; it should also have some provision for software-configurable interrupts. In addition, if microprocessor 14 has internal analog-to-digital conversion, this makes for a more compact printed circuit board layout. Some exemplary commercial products usable as microprocessor 14 for this application include the Oki MSM65524, the SGS- Thomson ST6210, the Zilog Z86A20, and the Microchip PIC16C71, PIC16C73, and PIC16C74, however, other commercially available microprocessors would also be acceptable. Further, although the illustrated microprocessor incorporates an analog-to-digital converter, it will be understood that separate components may be used for the microprocessor and analog-to-digital converter. The self-test filter 24 gives the microprocessor 14 another look at the output of the amplifier 11 to determine if the self-test signal is present in the echoes. There are several optional inputs to the system in addition to the receiver 10. For example, the user may set the motion sensitivity of the sensor with the sensitivity adjust 21. He may also vary the delay between the time the sensor last sees motion and the time the load goes off by manipulating the timer adjust 22. Other inputs measure various environmental factors, including the light level interface 18 and the overload detector 17. The oscillator 23 provides the microprocessor 14 with a timer reference, while the 60 Hertz detect 16 ensures that the sensor can react quickly in the event of a loss of power. The sensor controls several outputs, including the optional transmitters 20 in the case of an ultrasonic or a dual-technology sensor, the controlled outputs 13 to turn the load on and off, and the status indicators 19 to inform the user when the sensor detects motion, a fault condition, etc. The power supply 15, that provides the microprocessor 14 and other components with a steady DC voltage, and the user selectable software settings 25, which select optional features with which the sensor is endowed, are passive with regard to detecting motion or controlling a load. The hardware required for an intelligent ultrasonic occupancy sensor to detect motion is preferred in FIG. 3. The ultrasonic receiver 30 will produce a voltage that varies with the sound pressure incident upon it, and the resulting signal is applied to a preamplifier/high-pass filter including components 31, 32, 33, and 34. The output of the preamplifier/high-pass filter is then fed through a clipping amplifier/filter, which is composed of components 35, 36, 37, 38, 39, 40, and 41. This filter has a feedback impedance of the same value as the resistor 37 for signals that are not large enough to bias the diodes 38 or 39, and a feedback impedance of the resistor 37 in parallel with the resistor 40 for large signals that venture high or low enough to bias one of diodes 38 or 39. This reduces the gain for large signals and confers a certain amount of environmental noise immunity upon the sensor, as well as preventing saturation of the preamplifier. The output of the clipping amplifier goes through a simple low-pass noise-filtering stage including resistor 42A and capacitor 43, and the result is dithered via an output from the microprocessor 14 through the resistor 42B. Dithering is the addition of a square wave to an input signal which is to undergo analog-to-digital (henceforth A/D) conversion. The dither signal's peak- to-peak magnitude is ideally half of the resolution of the A/D converter. This reduces the effect of noise on the lowest bit of the converter, which may be important if the A/D resolution is eight bits or less. This dithered output is applied to an A/D converter channel on the microprocessor 14. This signal will henceforth be referred to as the "occupancy signal." The microprocessor 14 also drives the transmitters 26 and 27 using interrupts built into the microcontroller hardware. Transmitters 26, 27 and receiver 30 should have a fairly high Q in order that they put out energy at only one frequency of interest; even a small frequency component a few Hertz from the frequency of transmission could appear to the sensor as a Doppler shift and hence may register as motion. For similar reasons, transducers 26, 27 should not change their frequency of operation substantially with temperature or humidity. Exemplary commercially available components for transmitters 26, 27 and receiver 30 are presented in Table I, for three different transmission frequencies (25 kHz, 32 kHz and 40 kHz) . However, other commercial components and other transmission frequencies would also be acceptable. TABLE I Transmitter 26. 27 Receiver 30 25 kHz Nippon T25-16 Nippon R25-16 Nippon T25-18 Nippon R25-18 Nippon T25-24 Nippon R25-24 S-Square 250ST/160 S-Square 250SR/160 Matsushita RCB25K5 32 kHz Nippon T32-16 Nippon R32-16 Nippon T32-18 Nippon R32-18 S-Square 328ST/160 S-Square 328SR/160 S-Square 328ST/180 S-Square 328ST/180 40 kHz Murata MA40B5S Murata MA40B5R Murata MA40S3S Murata MA40E7R Nippon T40-16 Murata MA40S3R Nippon R40-16 The potentiometers 28 and 29 represent a simple way for the user to control the timeout and sensitivity settings of the sensor; the voltage from each is applied to a separate A/D channel on the microprocessor 14, and the microprocessor reads each voltage and translates this into a time period or a multiplier for the occupancy signal, respectively. Another method of controlling these settings would be through a remote control device, with settings on the control for sensitivity and timeout period. The remote could communicate with the sensor either via radio waves (which would mandate a radio receiver within the sensor) or using sonic output and the sensor's existing receiver 30. FIG. 4 is the circuit which an intelligent infrared sensor uses to detect occupancy. The PIR detector 46, which is essentially an FET biased by resistors 44, 45, and 47, varies its output as a heat source moves through the space. This disturbance causes the high-pass amplifier including components 48, 49, 50, and 51 to change its output. The resulting output is filtered by the capacitor 52 and the resistor 53 to eliminate electromagnetic noise and dithered by resistor 53A, and this voltage (also known as the "occupancy signal" for a PIR detector) is applied to another A/D channel in the microprocessor 14. The potentiometers 28 and 29 once again represent timer and sensitivity adjustments similar to those of FIG. 3. FIG. 5 is the schematic diagram of a dual-technology intelligent sensor that combines PIR sensing with ultrasonic sensing. It is essentially a combination of FIG. 3 and FIG. 4. FIG. 6 is a schematic diagram of the driver circuit for a latching relay to turn the load on and off. The microprocessor 14 dedicates a digital TTL output to the control circuit. When microprocessor 14 sends out a brief pulse through the resistor 54, this biases the transistor 57 so that current may flow through the relay coil 56 and allow it to latch. The load 58 may then draw current from the AC power source 59. A sensor that controls the load this way will have two of these circuits, one for setting the latching relay to turn the load on, and the other for resetting it to turn off the load. The diode 55 dissipates the energy in the inductor 56 when the relay is turned off, which prevents a voltage spike from damaging the transistor 57. Although a latching relay is contemplated in FIG. 6, it will be understood that a non-latching relay could be used that is powered continuously when load 58 is to be powered. Another scheme for controlling a load is illustrated in FIG. 7. When the microprocessor 14 sets the appropriate TTL output to high through the resistor 60, the silicon controlled rectifier (SCR) 61 will conduct, allowing the load 58 to draw power whenever the AC voltage from the power source 59 is positive with respect to ground. When the output of microprocessor 14 is low, the SCR 61 will not conduct, and the load will not draw power. The SCR method of switching may be preferable to a relay in instances where a low-powered AC load is being controlled that can efficiently operate off of half-wave rectified AC current. An SCR may be more reliable than a relay for this application. FIG. 8 shows a third way to drive a load, this time through a triac. When the microprocessor 14 sends out a TTL high signal through the resistor 62, the optotriac 63 conducts, charging up the capacitor 65 through the resistor 64 to the point where the diac 66 will conduct, biasing the triac 68, whereupon triac 68 will conduct current in either direction from the AC power source 59 through the load 58. A triac lasts longer in use than a relay and can conduct AC current unlike an SCR. The overload protection circuit of FIG. 9 uses a thermistor 69 to determine when the sensor is overheating due to an overload condition. The thermistor 69 and the resistor 68 form a voltage divider; as the temperature rises, the impedance of the thermistor 69 goes up while that of the resistor 68 remains fairly constant, and hence the voltage into the microcontroller 14 also rises. When the A/D input to the microprocessor 14 from thermistor 69 reaches a certain threshold voltage, the microprocessor 14 can then shut the system down, preventing the overload from damaging the sensor. The temperature reading may also be used to control electrical loads such as a building's air conditioning and heating systems. FIG. 10 is a circuit for sensing the light level in a room. Its operation is similar to that of the overload protection circuit of FIG. 9, in that the resistor 71 and the photoresistor 70 act as a voltage divider. When the photoresistor 70 is exposed to light, its impedance decreases, driving down the input voltage to the A/D input to the microprocessor 14. When the lights are off and the sensor senses motion, the sensor can check the ambient light level through use of the circuit of FIG. 10. If it is bright enough in the room that the lights are unnecessary, the sensor can elect not to switch the lights on. FIG. 11 shows the independent signal-processing hardware to detect the self-test signal. The receiver 30 and the first-stage high-pass amplifier including components 31, 32, 33, and 34 are the same as those in FIG. 3. The next stage is a peak detector including components 72, 73, and 74. The output of the peak detector is applied to the bandpass amplifier comprising components 75, 76, 77, 78, and 79 that functions to smooth out the jagged output of the peak detector. This result is noise-filtered by the resistor 80 and the capacitor 81 and dithered by the resistor 80A, and is then fed to one of the A/D channels on the microprocessor 14. The output of this peak detector circuit may be used for purposes other than self-test. For example, it may be used in parallel with or as an alternative to the quadrature detection strategy outlined in FIG. 19A and FIG. 19B. The main advantage of peak detection over simple quadrature sampling of the return echo is that a peak detector can more easily detect small changes in a large carrier. Consider the carrier 82 of FIG. 12, which is very close to the saturation threshold 83. This situation can occur in a small room with walls which reflect sound energy very efficiently. The small increase in the carrier 82 at time 84 is likely to be difficult to detect, as it is such a small fraction of the carrier amplitude; increasing the carrier amplification, on the other hand, would only cause the carrier 82 to reach the saturation threshold 83, at which point no change in its magnitude could be detected. A peak detector, however, can simply cut out the DC level of the peak amplitude of the carrier 82 and amplify the small change at time 84, making it very noticeable. A synchronous peak detection circuit is depicted in FIG. 13. The microprocessor 14 drives the transmitters 26, 27 with a waveform of much less than 50% duty cycle, which will both conserve energy output to the transmitters 26, 27 and will provide a very short switching pulse to the transistor 85 through the resistor 86. This transistor, along with the resistor 87 and capacitor 88, will provide the running peak level of the signal from the receiver 30 at the sampling times, which are synchronized to the transmitter outputs. The components 36 through 41 form the same nonlinear amplifier as depicted in FIG. 3, and the components 75 though 81 form the same bandpass amplifier as described in FIG. 11. The advantages of synchronous peak detection over ordinary peak detection are illustrated in FIG. 14. At time 237, the carrier 238 increases in frequency but maintains a constant amplitude (an unrealistic incident, but one which illustrates the principle simply) . An ordinary peak detector would not change its output level in this example, although the Doppler shift at time 237 clearly indicates motion. However, the synchronous detector samples the waveform at times 239, 237, 240, and 89, and its output 90 clearly reflects the change in frequency at time 240. FIG. 15 is a global flowchart of the method of the present invention. In practice, the flowchart of FIG. 15 (and FIG. 16-FIG. 27) is coded into appropriate form and loaded into the program memory of microprocessor 14 to cause microprocessor 14 and its associated circuitry to perform the method of the present invention. An exemplary coded program is included in the Appendix. Upon startup, the sensor goes through an initialization 91. It then enters the main loop, around which it circulates until the watchdog timer expires. At the start of the main loop, the sensor determines the room size and performs some elementary configuration 92. It then performs a self-test to determine that the signal path is complete 93. Next, the sensor takes two quadrature samples from the receiver 94, and runs the occupancy signal through the bandpass filter 95. The sensor then checks to see if it still has AC power 96, and then processes the output of the bandpass filter to determine if it has seen motion 97. The sensor updates its sensitivity to reflect changes in the user-controlled setting or automatic adjustments 98. Finally, the sensor will go into automatic gain setback 99 if it is time to do so, and if it is just now turning the lights on, it will perform zero-cross switching and automatic timer adjustment 100. It then goes back to the beginning of the main loop. The main loop is subject to periodic interruption in order to drive the ultrasonic transmitter. The interrupt routine is described below with reference to FIG. 27. The initialization phase 91 is expanded in FIG. 16. The sensor first sets its default occupancy 101; for example, assuming that the room is occupied on power-up and turn the lights on. The sensor then sets the watchdog timer 102 to time out in a predetermined period of typically 72 milliseconds, although other periods would also be acceptable. This determines the delay between the power shutting off and the sensor resetting itself. If the sensor's most recent startup was the result of a power failure 103, it then sets the relay 56 again 104 (also see FIG. 6) , just in case the power supply had not turned on quickly enough at startup to trigger the relay 56 on the first time. The sensor flashes the status indicator 105 to indicate that it is resetting. If the startup is due to a momentary power failure and the sensor's registers are preserved intact 106, the program then skips initializing them 107. The last initialization task is to enable interrupts for the transmitter drivers 108; this allows the microprocessor to drive the transmitters at the same time as it performs its other tasks (also see FIG. 27 and supporting text) . FIG. 17 expands upon the steps required to configure the sensor (step 92 of FIG, 15) . Most microprocessors require the program to configure the status of the analog input pins 109 and any bidirectional digital input/output pins 110. In addition, the sensor checks the size and configuration of the space every so often (for example, every five hours, as determined by the conditional 111) by sending a brief sonic ping 112 and then listening to the echoes for 60 milliseconds 113. If all of the echoes return within 20 milliseconds 114, then the room is quite small and the transmitters are putting out too much signal for such a small space, so the sensor reduces their power by 20 dB 115. The average return echo time also gives some indication of the room size, so the program varies the scale factor of the occupancy signal based upon the average echo delay 116. The flowchart in FIG. 18A and FIG. 18B shows the steps of the self-test routine (step 93 of FIG. 15) . If a predetermined time (for example, 17 minutes, as determined in the conditional 117) have passed since the last self-test, the sensor initiates a new self-test 118. If a self-test is in progress 119, the sensor will turn off its transmitter for 200 microseconds every 64 milliseconds 120 and make the receiver go deaf until eight milliseconds later 121; if the return echo does not exhibit a brief drop in signal strength 122, then the sensor declares a failure 123. If a failure has been declared 124, either just now or previously, then the sensor blinks the status indicator rapidly to indicate that there is something wrong 125. If it has been four seconds since self-test began 126 and a failure is declared 127, then the sensor turns off its error signal to an external lighting device to indicate a problem 134 and sets its self-test count to four 135; this means that the sensor must pass self-test four consecutive times following a failure in order to pass. If no failure has been declared, the program decrements the self-test count 128. If the self-test failure count is zero 129, then the sensor has passed and comes out of self-test 130, turns on its transmitter and receiver 131, reinstates its error-detection signal 132, and clears its filters 133. FIG. 19A and FIG. 19B outline the process of quadrature detection (step 94 of FIG. 15) . If the receiver is enabled 136, the sensor takes its first sample of the occupancy signal and stores it in the register AD-^ 137; if it is off, RD^ gets the value zero 138. Register TEMP-^ gets a high-pass value of AD-, plus a dither to diminish the effects of noise on the lowest- order bit of the digitizer 139. The sensor then determines the next value of AD 1Lp , the low-pass version of D- ^ , using separate filters for ordinary operation 141 and for self-test 142, as determined in the conditional 140. These same operations are then performed on the second sample of the occupancy signal in steps 143, 144, 145, 146, 147, 148 and 149. This second sampling is timed to be approximately 90 degrees from the previous sample, and is stored in the register AD 2 . The bandpass filter of FIG. 20 simulates an LC series circuit driven by an AC current source (step 95 of FIG. 15) . The register I L1 represents the current through the inductor; the register V C1 represents the voltage across the capacitor, and is the output of the bandpass filter. The coefficients b^ and b 2 are the gain of the input signal, the analog of which is the current source in the LC model, and are used as amplification factors for the input values (AD 1 -AD 1Lp ) 150 and (AD 2 - AD2τ ) 151, respectively. Note that for synchronous peak detection, there is no second quadrature sample, and hence These amplified values are then clipped in the software to prevent saturation of the filters 152. The coefficients a 1 and a 3 , as introduced in steps 154 and 157 respectively, determine the frequency characteristics of the bandpass filter, while the coefficient a 2 used in step 155 determines the filter's Q. These values can be altered for different applications (ceiling, stairwell, wall-mounted and corridor applications, for example) , either by programming them into the microprocessor 14 or by using jumpers to select the application and hence the values to be used. Step 156 calculates the damping of V C1 in step 157. The mathematical operation of the bandpass filter is described below in more detail with reference to FIG. 21 and FIG. 28. The digital bandpass filter described above may be dynamically altered during sensor operation, unlike an analog filter with fixed values. This can be useful for several reasons: as an alternative to automatic gain setback (described in FIG. 24) , by altering the filter parameters to see only full-body motion rather than the cruder expedient of simply lowering the sensitivity; or to make the sensor function as both a load controller and as a security sensor, the latter of which would utilize a more demanding motion detection method to make certain that the sensor was not creating a false alarm. FIG. 21 is the equivalent circuit of the bandpass filter described in FIG. 20. The two inputs to the filter are depicted as the current source 158 and the voltage source 159. The output variables I L1 and V C1 are represented by the current 160 and the voltage 161 respectively. The value of the inductor 162 is t/a l7 where t is the time between samples; the value of the capacitor 163 is t/a 3 ; and the value of the damping resistor 164 is l/a 2 a 3 . The sensor uses the watchdog timer and a digital input to the microprocessor 14 to reset itself when the power fails; the specific method is shown in FIG. 22 (step 96 of FIG. 15) . The voltage from the AC power to the load is sampled by the 60 Hertz detect stage 16, which reduces the line voltage by a large factor so as to permit its introduction into a TTL input. If the AC power is still active, then this digital input will oscillate at 60 Hertz; if not, then it will remain in one state or another. The program reads the transformer voltage once per pass through the main loop 165. Every time the digital input changes state 166, the program clears the watchdog timer 167. If AC power is absent for more than a predetermined period, for example 72 milliseconds, the watchdog timer will time out and reset the sensor. FIG. 23A, FIG. 23B, and FIG. 23C describe the manner in which the sensor determines occupancy (step 97 of FIG. 15) . The program takes the absolute value of VC 1 , the output of the bandpass filter (FIG. 20) , and puts it into a two-byte variable AVC1 168. If the space has been occupied for more than a predetermined time (for example, 16 seconds, as determined in the conditional 169) , the upper-order byte of AVC1 is decreased by one bit 170 and its lower-order byte is then increased by 128 172; otherwise its lower-order byte is increased by 32 173, as determined in the conditional 171. This means that AVCl goes down slightly when the space has been occupied for sixteen seconds, which decreases the incidence of repeated false tripping of the sensor. The register BPAVE gets the running average of AVCl times SSGAIN, the current sensitivity 174, and is then clipped 175 to aid in reducing false tripping from wind noise. If AVCl multiplied by the sensitivity SSGAIN is greater than or equal to the threshold, which is usually defined with respect to BPAVE as determined in the conditional 176, then the sensor has detected motion. If the sensor is a dual-technology unit, it then checks the PIR detector output to see if it too exceeds a threshold 177; if so, then motion has been detected. (Note that a PIR-only sensor would skip all of the ultrasonic filtering steps 136 through 157 and 168 through 176 and simply use the conditional 177 as the criterion for motion detection.) The program resets the occupancy timer and turns on the status indicator 178. If the sensor has a relay and it has been at least two seconds since it was pulsed on, then the sensor pulses it again 179; if the relay gets stuck in the off position for some reason, this will turn it back on again. A sensor which is operating in parallel with an array of other sensors could send its occupancy status to a central control station, rather than switching on the load by itself. If the motion is major (i.e., the motion is passing immediately by it, as determined by the conditional 180) , then the program resets the auto-adjust timer 181. Finally, the filter registers are cleared 182. If the sensor does not detect motion 176, then it checks to see if the status indicator has been on long enough 183; if so, it is cleared 184. If the lights are off 185 and a fraction of the threshold is less than or equal to AVCl times ONGAIN (the gain with the lights on) 186, then the auto-adjust timer is reset 187. A similar routine can be used to reset an independent auto-adjust timer for a PIR element, since a heat source passing near an infrared sensor would also yield a large signature. The mechanism of automatic sensitivity adjustment is discussed in greater detail with reference to FIG. 31 and FIG. 32. The sensor reads the timer adjust setting 188. If the lights are on 189, then the auto-adjust timer is set to time out in half again the timeout period of the occupancy timer 190. If the timer adjust is set below one minute 191, then the status indicator is enabled 192. This feature is provided for sensors to be installed in public areas; the indicator is still there for the installer, who usually sets the timeout to minimum during installation, but is disabled during ordinary use so that capricious individuals will not be attracted by the blinking LED and tamper with the device. If the occupancy timer has expired 193, then the room is declared to be unoccupied and the sensor turns the lights off 194. The sensor updates its sensitivity value as shown in FIG. 24 (step 98 of FIG. 15) . First the sensor reads the setting of the sensitivity adjust 195. If this setting has changed since the last pass through the main loop 198 or if the program is going through the main loop for the first time 196, the sensor sets the sensitivity value to that which the user selects 197. If neither of these events has occurred and the auto-adjust timer has expired 199, then it is time to alter the sensitivity setting. If the load is still powered when the auto-adjust timer expires 200, then the load has been on for over 150% of the timeout setting without any major entry motion into the room, since the auto-adjust timer is reset when such motion occurs 181. In any space that is only supposed to be occupied briefly, such as a restroom, this probably means that the sensor is erroneously detecting room motion based on hall motion, and it is time to reduce the sensitivity greatly 202. If the room is considered to be unoccupied, and no ambient noise or hallway traffic has made the occupancy signal rise to even a fraction of the threshold level (which would reset the auto-adjust timer 187) , then it is time to increase the sensitivity slightly 201. This means that the sensor will decrease its sensitivity rapidly to a point where it will not erroneously detect motion, and will then increase the sensitivity slowly and conservatively. If the sensitivity has been changed, either through a user setting or through automatic adjustment, then the auto- adjust timer is reset 203. Automatic gain setback (AGS) is a simple way of reducing hall-traffic false triggering, as shown in FIG. 25 (step 99 of FIG. 15) . If a room has been unoccupied for several seconds 204, then it is not likely that the sensor has mistakenly turned the lights off; if there was someone still in the space, then he would probably have made some motion to activate the sensor and turn the lights back on. Since the lights have remained off, no such motion has taken place, and so the program swaps the values of TEMP-L and TEMP 2 205, the input variables to the bandpass filter. This reverses the directional bias of the sensor so that it is now more sensitive to motion going away from it, which is useful because subsequent entry motion will be directed away from a sensor mounted near the entrance; the reversed bias permits rapid detection of entry motion. The sensor also reduces the sensitivity to a fixed fraction of ONGAIN 206, a register which stores the pre-AGS sensitivity level. This makes it possible to reduce the sensitivity of the sensor while not losing any adjustments to its gain made through automatic sensitivity adjustment. FIG. 26 presents the zero-cross switching and automatic timer adjustment routines, both of which may occur when the sensor has just detected occupancy in a previously unoccupied space (step 100 of FIG. 15) . Zero- cross switching is important to protect the relay from inrush current for reasons explained previously; it accomplishes this end by turning the relay on so that the contacts close at approximately the same time as the AC voltage to the load crosses zero. If the lights have been off and the sensor detects occupancy 207, the program waits until the 60 Hertz detect voltage 16 has gone low and then high 208. It then waits for a short period which is tuned to the pick time of the relay and the period of the line voltage 209. Automatic timer adjustment occurs when the sensor detects motion within a few seconds of declaring the room unoccupied and turning the lights off 210. In such an event, what has probably happened is that the timer was too short and the sensor turned the lights off while the room was still occupied. The surprised occupant would then make some motion to turn the lights back on. The sensor will therefore increase the lights-on timeout period slightly in order to prevent a recurrence of the incident 211. Finally, the sensor sets the relays to the desired state 212. The interrupt-driven transmitter drivers of FIG. 27 are invoked whenever the software generates an appropriate interrupt; it does this at the transmitter frequency. These interrupts may occur at any point in the program, so that the transmitters may be driven at an integer multiple of the sampling frequency. It would be better to sample at the transmitter frequency or higher, but that is impractical for even the fastest microcontrollers currently on the market. The interrupt routine first dumps the contents of the accumulator and any important registers (e.g., the status register) into memory 213 in order to preserve their contents. If the program is ready to sample the ultrasonic occupancy signal 214, then the sensor samples it 215. The program then reverses the voltage on each of the transmitters 216 in order to drive them. The contents of the accumulators and registers are then restored 217 so that the program can continue functioning where it left off. The interrupt routine then returns control to the main program 218 (FIG. 15) . The bandpass filter described in FIG. 20 is a simple real-time digital filter. The input variables to the filter are AD.^ and AD 2 , the quadrature samples of the received signal, and AD 1Lp and AD j ^ p , the low-pass versions of AD^ ^ and AD 2 respectively: AD 1Lp = 1/2 z -1 AD 1Lp + 1/2 AD 1 AD 2LP = - 1 -/ 2 Z_1AD 2LP + 1/ ' 2 ^2 The z-transform equations for the two output variables are: V C1 = z"lv Cl (1'a 2 a 3 ) ~ a 3 [I Ll " b 2 (AD 2- AD 2LP ) ] J L1 - z_ll L l + a l tV Cl " b 1 ( AD 1 -AD 1Lp )] Typical values for the coefficients are: b ι ■ = 8 b 2 = 16 a ι - 1/2 a 2 = 1/8 a 3 = 3/8 however, other values may be used without departing from the scope of the invention. The output of such a filter is depicted in FIG. 28. Note that the gains for Doppler shifts indicative of motion going toward 220 and away 221 from the sensor differ, resulting in a directional bias. This is a useful property for reasons previously described. Air conditioning noise tends to be of a lower frequency than legitimate motion and it is at its worst when it is blowing toward the sensor, so the gain in the region 219 in the filter's frequency response should be lower than that in the regions 220 or 221. The gain at the frequency of transmission 222 must be as close to zero as possible, since a reflection at that frequency indicates no Doppler shift and hence no motion. As mentioned above with reference to FIG. 20, it may be desirable on occasion to reverse the directional bias of the bandpass filter. This can be done by varying the filter parameters a 2 and a 3 . Self-test is illustrated in FIG. 29. The ultrasonic sensor 223 located within a room must have a complete signal path 224 in order to function properly; if none of the output signal ever reaches the receiver, then it cannot detect a Doppler shift in a nonexistent echo and the sensor will fail. Therefore, at intervals, a sensor can briefly cease to transmit sound and then listen to the echo for a short decrease or increase in the echo intensity as illustrated in FIG. 30. If the signal drop 225 is not perceived within a few tens of milliseconds, then the signal path must be incomplete, either due to malfunction of the transmitter circuitry, blocking of the receiver aperture, or receiver circuit failure. Automatic sensitivity adjustment is useful primarily in environments in which one can make certain assumptions about the occupancy pattern of the controlled space; otherwise the sensor cannot distinguish when it should reduce or increase the sensitivity. The particular scheme depicted in FIG. 24 assumes two conditions which are true of, for example, restrooms and other small non- office spaces: • Occupancy is brief, usually no longer than ten minutes, and in no case greater than 150% of the user- determined timeout period. • The sensor is mounted next to the door, so that entry motion yields a large signature. Since the sensor may be installed in a room of almost any size and configuration, there should be some established level of return signal that acts as an entry motion threshold: any entry motion in any room will yield that level of signal or higher, while any hall traffic in any room will not yield such a high signal level. This is most likely to occur within a sensor mounted near the doorway. The sensor can therefore safely adjust the sensitivity down if the lights have been on for over 150% of the timeout period with no entry motion. Consider the exemplary occupancy pattern of FIG. 31, where the sensitivity 226 is initially so high that the sensor is false-tripping on hallway traffic. Since the timeout period is set in this case to 15 minutes, the sensor waits 22.5 minutes before reducing the sensitivity to a lower level at time 227. In this example, the threshold of motion detection 228 yielded by this sensitivity level is still too high, so the sensor reduces the sensitivity 226 still further at time 229. The threshold of detection 228 is now high enough that the sensor disregards hall traffic. The entry motion at time 230 is sufficient to keep the lights on, but since it equals the minimum level 231 at which the sensor regards the signal as entry motion, the auto-adjust timer is reset (see, 181 in FIG. 23B) . Finally, the sensor times out at time 232, and the lights go off, disregarding further hall traffic. The sensor may be much more conservative in increasing its sensitivity, since a period of inactivity over a weekend or a holiday should not be allowed to increase the sensitivity to the point where it is prone to false tripping. FIG. 32 illustrates a scheme by which this can be done. The program establishes a threshold of background noise 233, in this case a fraction of the threshold of motion detection 234. If the sensor operates for several hours and never sees an occupancy signal exceeding this threshold, then it is safe to increase the sensitivity 235 slightly, as the sensor does at time 236. However, this lowers the threshold of background noise 233 to the point where the occupancy signal 237 does exceed it occasionally; the program therefore resets the auto-adjust timer so frequently that it never expires, and the sensitivity 235 is raised no further.

Claims: CLAIMS : 1. A method of controlling an electrical load as a function of occupancy of a space, comprising: generating an occupancy signal indicative of motion within said space by detecting infrared energy within said space; digitizing said occupancy signal to produce a series of digital samples indicative of a magnitude of said occupancy signal at controllable sampling intervals; processing said series of digital samples to determine occupancy of said space and to produce a signal indicative of occupancy of said space; and automatically energizing and de-energizing an electrical load as a function of said signal indicative of occupancy. 2. The method of claim 1, said generating step further comprising: transmitting ultrasonic energy into said space; and subsequently detecting ultrasonic energy reflected from said space to produce said occupancy signal. 3. The method of claim 1, said processing step comprising, processing said series of digital samples as a function of an occupancy pattern of said space. 4. The method of claim 3, said processing step comprising, adjusting a sensitivity of the determination of occupancy of said space. 5. The method of claim 4, said processing step comprising, automatically adjusting said sensitivity as a function of a history of said occupancy signal. 6. The method of claim 4, said processing step further comprising, adjusting said sensitivity as a function of user settable parameters. 7. The method of claim 4, said processing step comprising, automatically adjusting said sensitivity as a function of a size of said space. 8. The method of claim 1, said processing step comprising, analyzing said series of digital samples to determine a direction of motion within said space. 9. The method of claim 1, further comprising: dithering said occupancy signal prior to said digitizing step. 10. The method of claim 1, said automatically energizing and de-energizing step comprising: sensing a zero-crossing of an alternating current source supplying said load; and energizing said load substantially contemporaneous with said zero-crossing. 11. The method of claim 2, further comprising: automatically initiating a self-test procedure, including: interrupting the transmission of ultrasonic energy into said space for a predetermined time; subsequently detecting ultrasonic energy reflected from said space to produce a test signal; and analyzing an operation of said step of generating said occupancy signal as a function of said test signal. 12. The method of claim l, further comprising: detecting a peak value of said occupancy signal; and processing said peak value to determine occupancy of said space. 13. The method of claim 2, further comprising: detecting a peak value of said ultrasonic energy reflected from said space substantially synchronous with said transmitting of said ultrasonic energy into said space. 14. The method of claim 1, said automatically energizing and de-energizing step comprising: energizing said load substantially contemporaneous with the production of said signal indicative of occupancy; and de-energizing said load after a controllable de- energization time. 15. The method of claim 14, further comprising: adjusting said controllable de-energization time as a function of a history of said occupancy signal. 16. The method of claim 1, further comprising: sensing an environmental condition of said space. 17. The method of claim 16, said sensing step comprising sensing an ambient light within said space. 18. The load controller of claim 16, said sensing step comprising sensing an ambient temperature within said space.

Inventors: HARDIN CHARLES C, MYRON DOUGLAS D, STEPHENS MICHAEL A, WILLIAMS ERROL R, WOYTEK TIMOTHY W, HARDIN, CHARLES, C., MYRON, DOUGLAS, D., STEPHENS, MICHAEL, A., WILLIAMS, ERROL, R., WOYTEK, TIMOTHY, W.
Applicants: MYTECH CORP, MYTECH CORPORATION
Application year: 1996
Main classification: H05B37
IPC codes: G01V1, G01V8, G01V11, G08B29, H05B37