BACKGROUND OF THE INVENTION 
     The field of the invention is systems for detecting and indicating estrus in animals, and more particularly, systems for electronically indicating estrus in dairy cows. 
     In my U.S. Pat. No. 4,247,758 I describe an electronic system for detecting estrus in animals. This system includes a transponder unit which is carried by the animal and which transmits a signal to a transceiver unit that indicates both the identity of the animal and its activity. The transceiver unit is positioned at a location which is frequented by the animal and it may be connected to a computer which analyzes the activity data and generates a report which indicates those animals that are in estrus. 
     Although my prior system operates quite satisfactorily, it is best suited for use on relatively large farms where many animals are involved and the fully automatic identification and estrous detection system is needed. The cost of this system cannot, however, be justified for many small farms, even though the need for accurate estrous detection may be just as great. 
     SUMMARY OF THE INVENTION 
     The present invention relates to a self-contained device which is carried by the animal and which provides a visual indication when the animal is in estrus. More particularly, it includes a motion detector for sensing significant animal movements, means for continuously maintaining a reference count which is indicative of the animal&#39;s average activity over a prior time period, means for counting the current activity of the animal, and means for providing a visual indication of estrus when the current detected activity exceeds a preset multiple of the reference activity. 
     A general object of the invention is to provide an economical means for automatically detecting estrus in animals. All of the circuitry is contained in a small housing in the form of a tag which is attached to the animal. No external computers or electronic apparatus are required. 
     Another object of the invention is to provide an estrous detection system which is easy to use. When applied to cows for example, the tag is strapped to a leg of the animal and reset by passing a magnet across the surface of the housing. The tag automatically monitors acitivity and when estrus is detected, a light is energized on the tag to notify the farmer. The tag may then be transferred to another animal and reset to monitor its activity. 
     Another object of the invention is to provide additional information for use in experimental and test applications. By employing a microprocessor in the tag to perform the necessary calculations, electronic communication can be added at nominal cost. The activity of the animal may then be accumulated over short time intervals and stored in a table to provide an activity profile of the animal over a long time interval. This activity data may be read from the tag using the communication routine programmed into the microprocessor. 
     Another object of the invention is to provide an estrous detection tag which is easy to manufacture. By employing a programmable microprocessor, the tag can be easily adapted to different applications merely by making slight program changes or changes to the parameters employed by the program. In addition, test and diagnostic features can easily be added at nominal cost. 
     Another object of the invention is to provide an estrous detection tag which has an extended useful life. The microprocessor and associated gates employ CMOS technology which consumes minimal power from the battery contained in the tag. In addition, the microprocessor is programmed to revert to a wait state in which it consumes even less power during intervals when no processing is required. 
     The foregoing and other objects and advantages of the invention will appear from the following description. In the description, reference is made to the accompanying drawings which form a part hereof, and in which there is shown by way of illustration a preferred embodiment of the invention. Such embodiment does not necessarily represent the full scope of the invention, however, and reference is made therefore to the claims herein for interpreting the scope of the invention. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 is a perspective view with parts cut away of a tag which incorporates the present invention; 
     FIG. 2 is an electrical schematic diagram of the tag of FIG. 1; 
     FIGS. 3A-3D are flow charts of the programs which are executed by the microprocessor in FIG. 2; and 
     FIG. 4 is a memory map which illustrates the data structures employed by the programs of FIG. 3. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENT 
     Referring particularly to FIG. 1, the tag 1 of the present invention includes a circuit board 2 which is enclosed in a molded plastic housing 3. The housing 3 is attached to a flexible strap, or belt 4 which may be attached around an appendage on the animal being monitored. In the case of dairy cows, the strap 4 is designed to attach securely to the hind leg of the cow. The interior of the housing 3 is completely filled with a potting compound to retain the circuit 2 and the electrical components. 
     Referring particularly to FIG. 2, the circuitry on the circuit board 2 is structured about an 8-bit microprocessor 5 which is driven by a 32.768 kHz clock circuit 6. Power is provided to the microprocessor 5 and the remaining circuit elements by a 1.7 ampere-hour lithium battery 7 which provides 3.7 volts at a terminal VDD. The model MC146805E2 microprocessor 5 is employed and it is manufactured by Motorola Inc. using CMOS technology. It draws very little current, and in addition, the microprocessor 5 may be placed into a &#34;wait&#34; state in which it draws approximately 40 microwatts of power. This feature is employed in the preferred embodiment to obtain a battery life of from three to four years. 
     Referring particularly to FIGS. 1 and 2, the microprocessor 5 has an 8-bit I/O port B which can be configured to input or output data under program control. Four leads of this B port (PB0-PB3) are configured as outputs and are connected to respective driver transistors 8-12. The transistors 8-12 provide amplification which enables the outputs PB0-PB3 to energize respective light emitting diodes (LED) 13-16. The LEDs 13-16 extend through the housing 3 where they may be easily seen and provide a visual indication of the extent of the animal&#39;s activity. The LED 13 provides a means for outputting more extensive data as will be described in more detail below. 
     The leads PB4-PB7 of the B port are configured to input data to the microprocessor 5 during production and testing of the tag 1. Lead PB4 is driven low by an external source to place the system in a &#34;test&#34; mode and lead PB5 is driven low by an external source when data is to be entered into the microprocessor. The serial data string is applied to lead PB7 and the microprocessor 5 is programmed to read this input data each time a negative voltage transition occurs in a clock signal which is applied to input lead PB6. 
     Referring particularly to FIG. 2, the microprocessor 5 is reset each time its reset terminal (R) is pulled to a logic low voltage. This is accomplished by a normally open reed switch 17 which connects to circuit ground. When a magnet is brought near the tag 1, its magnetic field closes the contacts in the reed switch 17 to perform the reset function. It is contemplated that the user will perform this reset function whenever one of the LEDs 14-16 is energized. As will be explained in more detail below, when a reset occurs the microprocessor 5 is vectored to a reset program which is executed to initialize the system and to perform a number of other functions. 
     The activity of the animal to which the tag 1 is attached is detected by a mercury switch 18. One lead of the switch 18 is connected to circuit ground and the other lead connects to the clock input of a D-type flip-flop 19. The flip-flop 19 has its D input connected to a logic high voltage, and it operates as a latch which generates a logic low voltage at its Q output each time the mercury switch 18 closes. The latch 19 connects to an IRQ interrupt lead on the microprocessor 5, and with each mercury switch closure, the microprocessor 5 is vectored to an IRQ interrupt program. As shown in FIGS. 3D and 4. the IRQ interrupt program contains instructions indicated by process block 20 which increment an activity number counter 21. In addition, instructions indicated by process block 22 are executed to reset the latch 19 through the microprocessor&#39;s output port PA7. 
     Referring again to FIG. 2, the microprocessor 5 contains sufficient on-chip memory to store data for normal applications of the tag 1. However, it is contemplated that the tag 1 will also be used in experimental programs in which the activity of the animal may be recorded over extended periods of time. Accordingly, provision is made for the addition of an external random access memory (RAM) 23 which may store additional activity data. A 2K×8 CMOS RAM manufactured by Hitachi as the HM6116LP-4 is employed in the preferred embodiment. The RAM 23 is connected to an 8-bit data bus 24 which is driven by a bidirectional, multiplexed address/data port (leads B0-B7) on the microprocessor 5. These same leads B0-B7 serve to generate the lower eight bits of an address when a microprocessor address strobe terminal (AS) is at a logic high voltage, and this address data is stored in a latch 25 for application to the RAM 23. The three most significant address bits are generated at microprocessor address leads (A8-A10) which are connected directly to the RAM 23 by bus 26. The RAM 23 is enabled by a NAND gate 27 when a data strobe lead (DS) on the microprocessor 5 goes high, and data is then written to an addressed RAM location when a microprocessor read/write lead (R/W) goes to a logic low voltage. Data is read from an addressed location in the RAM 23 when the R/W lead goes high and an inverter gate 28 drives the output enable lead (OE) on the RAM 23 to a logic low voltage. 
     The microprocessor 5 executes stored program instructions to perform a number of functions. The assembly language listings of these stored programs are provided in Appendix A and flow charts of these programs are illustrated in FIGS. 3A-3D. As indicated above, two versions of the tag 1 are contemplated. The first version is for normal applications in which an animal activity profile over a sixty hour period is stored in the tag and employed to detect estrus. When estrus is detected one of the LED indicators 14-16 is energized. The second version of the tag is for experimental use. This second version stores a much longer animal activity profile and it provides a number of communicating features which will be described in more detail below. In the following description, the second version of the tag is illustrated, and asterisks denote those portions of the programs which may be deleted to form the first version of the tag. 
     Referring particularly to FIGS. 3A and 4, each time a magnet is brought near the tag 1 the read switch 17 is closed and a reset program is executed. As indicated by process block 30, this program initializes the microprocessor&#39;s A and B ports, as well as a pointer to an activity table 31. The status of microprocessor input lead PB5 is then tested, as indicated by decision block 33, to determine if data is to be input into the system. If so, a loop which includes decision block 34 and process block 35 is entered and data is input through microprocessor input lead PB7 and stored in its internal RAM. Such data is entered during manufacture of the tag and may include a serial number and date which uniquely identifies the tag, as well as key parameters which customize the tag to the particular animals being monitored. Under normal operating conditions, however, the reset program branches at decision block 33 and no input data is received. 
     Referring still to FIG. 3A, the reset program outputs the animal&#39;s activity profile data from the activity table 31, as indicated by process block 36. This is accomplished by writing the data serially to the output lead PB0 which drives the LED 13. The LED 13 is thus energized to indicate a logic &#34;0&#34; and is deenergized to indicate a logic &#34;1&#34;. An instrument (not shown in the drawings) may be coupled to the tag 1 to read this serial data which is output through the LED 13. In addition to the activity table data, other data such as diagnostic information may be output, or as indicated by process block 37, the much larger animal activity profile stored in the data base table 32 may also be output. In any case, each of the LEDs 13-16 is then momentarily energized as indicated by process block 38 to insure that they work properly, and further initialization is performed as indicated at process block 39. A &#34;rate number &#34; 40 is then reset to zero as indicated at process block 41, and a WAIT instruction is then executed to place the microprocessor 5 in its low-power wait state. In this wait state the microprocessor&#39;s internal timer continues to operate and the microprocessor 5 is responsive to the IRQ interrupt, timer interrupt and a reset interrupt. After a timer interrupt or an IRQ interrupt is serviced, however, the system returns at 42 and is again placed in the low-power wait state. 
     As indicated above, the IRQ interrupt occurs each time the mercury switch 18 closes. The IRQ interrupt service routine (FIG. 3D) merely increments the activity number counter 21 and resets the latch 19 before returning to the wait state. This event occurs each time the animal moves sufficiently to bring the mercury bead in the switch 18 into contact with its internal leads. The number of such movements are accumulated in the two-byte activity counter 21. 
     Referring to FIG. 3B, the internal timer in the microprocessor 5 is initialized to generate a timer interrupt every 2.5 seconds. As indicated by decision blocks 45-47, when this interrupt occurs the system is vectored to the timer interrupt service routine which examines the current value of the rate number 40. As will become apparent from the description below, the rate number is indicative of the activity of the animal over a recent time period as compared to the activity of the animal over a longer reference period. When the rate number is less than two, as determined at decision block 45, the animal&#39;s current activity is not noteworthy. Otherwise, one of the LEDs 14-16 is energized, as indicated by process blocks 49-51, to provide a visual indication that noteworthy activity is occurring. The appropriate LED is energized for 50 milliseconds, as indicated by process blocks 53 and 54, but because the timer interrupt occurs every 2.5 seconds, the energized LED blinks continuously. Only one of the LEDs 14-16 is energized at any time, and by observing which LED is illuminated, the relative increase in animal activity can be easily determined. Although the absolute activity which indicates estrus will vary from animal to animal, it has been found that a significant relative increase in animal activity is an accurate indication of estrus. 
     Every hour the rate number is recalculated to provide an updated indication of animal activity. Referring particularly to FIGS. 3B and 3C, the state of input lead PB4 is tested at decision block 56 to determine if the tag is undergoing testing. If not, a time counter 57 is incremented as indicated at process block 58 and the value of this counter 57 is then checked to determine if an hour has elapsed. If not, the system branches at decision block 59, the internal timer is reset at process block 60, and the system returns to the wait mode for another 2.5 seconds. If a one hour &#34;sample&#34; period has elapsed, the time counter 57 is reset at process block 61 and a new rate number is calculated. It should be apparent that the test mode of operation merely bypasses the one hour time requirement for recalculation of the rate number, and this feature merely enables the tag to be quickly tested. 
     Referring particularly to FIG. 3C, before calculating a new rate number the animal activity profiles are updated with the most current activity number. As indicated by process block 62, the contents of the activity counter 21 is first stored in the activity data base table 32. The same number is then divided by sixteen, as indicated by process block 63, to form a single byte result which is stored at process block 64 in the activity table 31. The activity counter 21 is then reset to zero at process block 65 to begin accumulating activity counts for the next hour. 
     As indicated at process block 66, the activity counts for the twelve most recent hours are then read from the activity table 31 and added together to provide a current activity value which is stored at &#34;SUM&#34;. The value of the forty-eight least recent activity numbers are then read from the activity table 31 at process block 67 and added together to form a reference activity number which is stored at &#34;TOTAL&#34;. The ratio of the current activity to the reference activity is then calculated at process block 68 to form the current rate number. If the calculated current rate is greater than the value stored as the rate number 40, the system branches at decision block 69 and updates the rate number 40 at process block 70. In either case, the internal timer is then reset at process block 71 and the system returns to the wait mode for another 2.5 seconds. 
     In the preferred embodiment the reference activity is calculated over a forty-eight hour period and the current activity is calculated over the most recent twelve hour period. These time periods can, of course, be easily changed to accommodate the activity patterns of various animals and breeds. Indeed, one of the purposes of the data base table option in the tag 1 is to store activity data over a much longer time period. This activity profile data can then be read out as described above, and studied to determine the optimal values of the &#34;reference&#34; and &#34;current&#34; time periods. The optimal values of these key parameters may be entered into the production tags which are to be employed on that particular animal breed. 
     Although the use of a microprocessor offers many advantages, it is also possible to construct a circuit which will emulate the functions described above. This and many other variations from the preferred embodiment described herein are possible without departing from the spirit of the invention. ##SPC1##
A tag suitable for attachment to an animal includes a programmed microprocessor which monitors the activity of the animal. Activity is measured by counting the closures of a mercury switch, and when the current activity exceeds a reference activity by a preset amount, a light emitting diode is energized. Four light emitting diodes are provided to indicate four separate levels of activity.