AU2002256410A1 - Sensor output analog processing-a-microcontroller-based insect monitoring system - Google Patents

Sensor output analog processing-a-microcontroller-based insect monitoring system

Info

Publication number
AU2002256410A1
AU2002256410A1 AU2002256410A AU2002256410A AU2002256410A1 AU 2002256410 A1 AU2002256410 A1 AU 2002256410A1 AU 2002256410 A AU2002256410 A AU 2002256410A AU 2002256410 A AU2002256410 A AU 2002256410A AU 2002256410 A1 AU2002256410 A1 AU 2002256410A1
Authority
AU
Australia
Prior art keywords
com
goto
reg
insect
movwf
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Abandoned
Application number
AU2002256410A
Inventor
R. David Crompton
Dennis Shuman
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
OPI SYSTEMS Inc
US Department of Agriculture USDA
Original Assignee
OPI SYSTEMS Inc
US Department of Agriculture USDA
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by OPI SYSTEMS Inc, US Department of Agriculture USDA filed Critical OPI SYSTEMS Inc
Publication of AU2002256410A1 publication Critical patent/AU2002256410A1/en
Abandoned legal-status Critical Current

Links

Description

SENSOR OUTPUT ANALOG PROCESSING-A MICROCONTROLLER-BASED INSECT MONITORING SYSTEM
BACKGROUND OP THE INVENTION Field of the Invention
This invention generally relates to an apparatus and a process for monitoring and/or providing a quantitative and/or qualitative indication of insect infestations in stored products .
Description of the Related Art
Protection of stored agricultural commodities from insect infestations and the direct loss caused by insects are costly. Insect infestations in stored agricultural commodities result in annual losses of millions of dollars. Early detection of infestation problems is necessary to initiate timely control measures and eliminate unnecessary ""scheduled" insect treatments. Routine use of insecticides to protect stored products may have constraints .
The standard practice for detecting and quantifying infestation in stored grain is visual inspection of samples for adult insects. Insects are usually separated from grain samples with hand or inclined sieves. A traditional method of obtaining samples uses a long, hollow multi-compartment grain trier inserted into the commodity. Its gates are then opened and closed to acquire samples at different depths and, after withdrawal, the samples are removed for inspection (Bauwin et al., In: Storage of Cereal Grains and Their Products; 2nd edition, ED: CM. Christensen, 115-157, 1974; St. Paul, MN. :American Association of Cereal Chemists) . Other methods can get beyond the limitation of only sampling close to the grain' s surface. A vacuum probe can extract larger samples from deeper with a grain mass and a grain mass can be turned enabling a pelican sampler to catch samples from the moving grain stream (Noyes et al., In: Management of Grain, Bulk Commodities, and Bagged Products, Circular E-912, 71-79, Cooperative Extension Service, Oklahoma State University, 1991) . None of these sampling techniques provide continuous and thorough monitoring. Low insect populations are difficult to detect in small samples and a much greater proportion of the grain needs to be sampled to accurately estimate insect population size (Hagstrum et al., IN: Management of Grain, Bulk Commodities, and Bagged Products, Circular E-912, 65-69, Cooperative Extension Service, Oklahoma State University, 1991) . Additionally, theses sampling methods are expensive and labor intensive and therefore not repeated very often even though an infestation can grow from undetectable to damaging levels in two weeks. Another method, employed in some large grain elevators, is temperature sensing cables distributed throughout the storage volume. This system is only sensitive to very high insect populations. Furthermore, both moisture and mold growth can elevate temperature levels.
White et al., (Journal of the Kansas Entomological Society, Volume 63(4), 506-525,1990) and Reed et al. (Journal of Economic Entomology, Volume 84(4), 1381-1387, 1991) both disclose passive grain probe traps that have been developed. The probes are vertical perforated tubes that insects crawl into and then drop through to be trapped in a reservoir at the lower end. Probes are left in the grain for prolonged periods, allowing them to continuously capture insects and thus detect very low insect populations. However, the information is only available after the labor intensive process of inserting the trap into the grain, waiting, withdrawing the trap, and then inspecting the trap contents. The difficulty of insertion and withdrawal increases with the distance from the surface due to the resistance of the grain.
United States Patent No. 5,005,416 discloses an automated, continuous monitoring electronic grain probe trap with a bottom reservoir fitted with a detector that senses the movements of trapped insects. The number of insects caught in the trap is estimated based on the amount of vibration detected. However, temperature, species, time in the trap, the amount of food, and other insects in the trap are all factors which can affect the trapped insects' vibration producing activity. Vibration detection may also be prone to error from ambient noise.
Hagstrum et al . (Proceedings 6th International Working Conference on Stored-Product Protection, Canberra, Australia, Volume 1, 403-405, 1994) disclose a computer-based acoustic system that provides for automated monitoring by detecting insect generated sounds. Piezoelectric transducers, mounted on vertical cables installed in grain bins, sense the feeding and movement sounds of nearby insects. The acoustic sensor outputs are sequentially connected to electronic components that count and relay to a computer, the number of signal peaks crossing a threshold level during each sensor's observation interval.
United States Patent No. 5,646,404 (herein incorporated by reference) discloses an electronic grain probe insect counter (EGPIC) which provides real-time monitoring of insects using infrared beam technology to detect insects as they fall through modified grain probe traps. When an insect falls through the trap, it partially masks an infrared beam. Whenever one of the traps infrared-beam sensor output signals exceeds a precise detector threshold level (this level being set to specify the minimum detectable insect size) , the resulting quantitative insect detection or count is recorded and time-stamped to provide an ongoing indication of infestation levels in stored- products. The real-time data acquired by an EGPIC system are used to display the numbers of insects that have been counted within specific commodity regions and time periods. If the rate of insect counts are below a known threshold (based on factors such as economics, tolerance, environmental parameters, etc.), no control action is necessary. However, if the rate is above that threshold, the appropriate response may be a function of the species being counted. This is because the relationship between insect counts and population density is a function of species. Therefore, the appropriate first response may be to go into the commodity storage and identify the species at those probe sites that are getting the high insect counts. Then, with that species information, a decision can be made as to if and what control response is warranted. Thus, while the EGPIC system can eliminate the need to visually inspect the commodity on an ongoing scheduled basis, increasing insect counts may still mandate a visual inspection before control decisions are made. The EGPIC system employs a sensitivity control in order that it not count objects smaller than the smallest stored-product insect of concern (e.g., grain particles) . Because of this, smaller insects such as psocids and mites are not counted even though their presence may be of interest to the facility manager. This sensitivity control must be set conservatively (higher sensitivity) in order to ensure that each probe maintains a reasonable count accuracy with the smallest stored-product insect of concern because of large electronic and mechanical component variability across probes. However, this may occasionally lead to false positives due to other ver small insects (e.g., psocids) and grain particles. Other potential sources of false positives are electrical impulse noise (e.g., generated by electric machinery) and a crawling or clinging insect managing to get near the infrared beam which can cause a multitude of false counts. The EGPIC system has a self-test feature to insure that receiving no counts from a probe is not an indication of a probe or system failure. At regular time intervals, the system momentarily decreases the infrared beam source output, simulating an insect falling through and masking part of the beam, and then checks whether this "count" is detected. However, this is a pass/fail test, so there is no warning of a gradual performance degradation until failure occurs.
While various methods and systems have been developed for monitoring insect infestations in stored-products, there remains a need in the art for a system for remote monitoring of pest infestations which provides a more accurate count and species identification. The present invention provides a remote system for automatically counting insects which enables a qualitative analysis of an analog sensor output signal to provide additional information that can help identify species, reject erroneous counts, etc. which is different from prior art methods and systems.
SUMMARY OF THE INVENTION
It is therefore an object of the present invention to provide a monitoring system for insect infestations in stored-products that gives both accurate counts and/or qualitative information such as insect species identification.
Another object of the present invention is to provide a monitoring system that counts all objects falling past at least one sensing transducer including those that are not identified as insect species of concern and has the ability to discriminate between the different falling object categories.
A further object of the present invention is to provide a monitoring system that includes at least one sensing transducer for detecting insects falling past said transducer and for statistically identifying insect species .
A still further object of the present invention is to provide a monitoring system that includes at least two beams for detecting insects falling past said transducer and for statistically identifying insect species.
A further object of the present invention is to provide a monitoring system that has a means for obtaining identical response sensitivity from all probes despite large electronic and mechanical component variability across probes .
A still further object of the present invention is to provide a monitoring system which obtains consistent response sensitivity from each probe despite changes resulting from component aging, environmental changes, and potential foreign matter accumulation (e.g., dust, moisture, etc.) on the system's sensing transducer components.
Another object of the present invention is to provide a monitoring system which monitors the ongoing performance of each deployed probe while in situ, thus obtaining an indication of a forthcoming need for probe maintenance before probe failure.
A still further object of the present invention is to provide a monitoring system which improves system accuracy by only counting insects falling past at least one sensing transducer while rejecting potential detection of insects inadvertently loitering in the vicinity of the sensing transducer.
Another object of the present invention is to provide a monitoring system which improves system accuracy by rejecting false detections due to electrical transients (noise spikes) .
Further objects and advantages of the invention will become apparent from the following description.
BRIEF DESCRIPTION OF THE DRAWINGS
Figure 1 is a drawing showing placement pattern of a microcontroller-based insect monitoring system in a grain storage facility.
Figure 2 is a block diagram showing a microcontroller-based insect monitoring system implemented with infrared transducers producing a single beam.
Figure 3 is a drawing showing the location of temperature sensor 33, probe circuit board 34, and sensor head 24.
Figure 4 is a graph showing the waveforms from the sensor output analog processing implementation. Figure 5 is a flowchart of the microcontroller signal processing program sub-component when a single infrared beam is employed and part of the program's function is to check for adherence to signal timing criteria.
Figure 6 is a detailed schematic of the probe circuit implemented with infrared transducers producing a single infrared beam.
Figure 7 is a graph of pulse amplitude distributions for four different insect species as obtained with a single infrared beam.
Figure 8 is a graph showing how the length of a line L with any orientation in three-dimensional space can be calculated from the length of its projections on the three orthogonal coordinate axes .
Figure 9 is a drawing showing how three orthogonal infrared beams can be oriented to intersect underneath the bottom opening of a funnel used to direct the path of a falling insect .
Figure 10 is a drawing showing how two orthogonal infrared beams are oriented in a horizontal plane to intersect underneath the bottom opening of the funnel .
Figure 11 is a graph of pulse amplitude distributions for four different insect species as obtained with two intersecting, orthogonal infrared beams. The overlap of the distributions is far less than that obtained with a single beam as shown in Figure 7.
Figure 12 is a block diagram showing the functional components of a two beam, microcontroller based insect monitoring system. Figure 13 is a photograph of the beam generated by an infrared LED and projected from a distance of about 7.6 mm onto a sheet of graph paper with about 1 mm grid spacing, showing its non- uniform intensity.
Figure 14 is a graph of the empirically derived non-linear relationship between Target Peak Amplitude and object cross- sectional area shown with two different linear extrapolations, each based on the target peak amplitude obtained with a different calibration ball diameter.
Figure 15 is a flowchart of the signal processing program subcomponent for a sensor 20 with two infrared beams when the timing criteria are checked by the central location device.
Figure 16 is a detailed schematic of a probe circuit implemented with infrared transducers producing two beams .
DETAILED DESCRIPTION OF THE INVENTION
The present invention is useful for providing a quantitative and/or qualitative detection of insect infestations in stored products such as grains, fruits, nuts, vegetables, and legumes, for example (Figures 1, 2, and 12) . Enhancement of a grain probe trap with a microcontroller-based insect monitoring system 10, eliminates (a) the labor intensive process involved in its use, (b) the limitations on where it can be located in a storage structure, and (c) the lack of information available from it until removed for the stored commodity and inspected.
System 10 not only determines when an analog output signal of a sensing transducer 14 exceeds a certain threshold value to generate a digital pulse (Figure 4) which is then counted; it also acquires and analyzes the sensor 20 output signal waveform to extract additional information from it which is then utilized to determine, for example, (a) what insect species of concern are present, (b) if other objects are entering the probe, (c) the probe's present sensitivity, (d) the need for forthcoming maintenance, and (e) the recognition and subsequent rejection of false positives due to either crawling insects or electrical noise spikes. System 10 can use the generated data to perform additional analyses such as spatial analysis to generate three dimensional insect population contours and to make insect management decisions using predictive models, etc.
System 10 includes at least one sensing transducer 14 with at least one analog output signal which can be, for example, an infrared beam receiver 32 (e.g., a phototransistor) , a moisture sensor (e.g., a parallel plate capacitor), etc., and the information extracted from the output waveform of the transducer 14 is primarily its amplitude, its duration, and its time of occurrence. It can also include a smart sensor with built-in analog to digital conversion and signal processing, in which case the invention could be implemented, in whole or in part, in the sensor 20 body itself.
For purposes of illustration, the following detailed description exemplifies the implementation of the present invention using an electronic grain probe insect detector having at least one infrared beam transducer 14 in the sensor head 24, such as for example, as described in United States Patent No. 5,646,404 (Litzkow et al, July 8, 1997; herein incorporated by reference) ; and Shuman et al.. (A Computer-Based Insect Monitoring System for Stored-Products Using Infrared Sensors, presented at Third International Symposium on Sensors; August 17-21, 1997 in Tiberias, Israel; published in Acta Horticulturae, Volume 562, 243-255, 2001 ; herein incorporated by reference) . One of ordinary skill in the art could readily incorporate any type of sensor 20 capable of an analog output in which the waveform peak amplitude is indicative of insect species, given the detailed description provided below.
At least one beam transducer 14 is mounted in sensor head 24 at the bottom of the upper probe body section 13. Each transducer 14 is operatively connected to probe circuit board 34 either directly or through a transducer cable 25 such as is shown in Figure 3. For purposes of the present invention, directly connected means the leads of the transducer connect to the circuit board. When two of more transducers 14 producing two or more beams are used, the beams can have any orientation which a falling object, such as an insect or grain particle, will pass through. When using multiple beams it is well within the ordinary skill in the art to determine beam orientation given the present detailed description, such as for example, vertically stacked beams which are parallel to each other; non- parallel beams; non-parallel intersecting beams; orthogonal, intersecting beams; etc. However, the different orientations and/or positions of multiple beams should improve the probability of capturing the largest cross-sectional area of the falling object. For purposes of the present invention, multiple beams means two or more beams. This is important because the orientation of a falling object is random-i.e., two objects that are the same will fall through a beam in different orientations and the probe could see them as differing in size depending on the orientation as it passes through a beam. To further refine the use of multiple beams, the use of orthogonal, intersecting beams allows the use of vector addition which combines the results obtained from the different beams and increases the accuracy of species identification. For sensors 20 having transducers 14 that produce three orthogonal, intersecting beams, the beams are oriented symmetrically about the vertical fall line through the funnel as the rotational axis of symmetry (Figure 9) . When two orthogonal, intersecting beams are used, the beams are located along a horizontal plane (Figure 10) . Probe circuit board 34 is mounted near transducer (s) 14 within a distance that results in an acceptable degradation of transducer 14 signals and susceptibility to electrically induced noise. One of ordinary skill in the art could readily determine the maximum distance for acceptable degradation of transducer 14 signals and susceptibility to electrically induced noise. Circuit board 34 (Figures 2,3, and 12) includes a programmable microcontroller 36 and at least one voltage threshold detector 40. It further includes beam current generator 35 which employs the supply voltage and series resistance to control the LED current. Alternatively, multiple LEDs can be connected in series and driven by a constant current source to provide greater current stability while permitting simultaneous self- testing by momentarily decreasing the output of the constant current source. Microcontroller 36 includes at least one analog input 44, at least one digital input 46, a digital output 48, and an internal non-volatile memory 37 containing a software program for analyzing at least one signal. The software program measures the duration of a signal, the duration of time between signals, monitors the signal for a maximum analog value, records the time at object detection, and stores these extracted parameters for transmission to a central location device 42. The pulse timing decision making analysis software can either be located in microcontroller 36 or central location device 42. It is well within the, ordinary skill in the art to determine where the decision making process is located. Some of the advantages of having the pulse timing decision analysis in central location device 42 include reducing the microcontroller software decision making overhead, allowing for a higher rate of insect counting; allowing criteria tuning based on experience where the user can select minimum and maximum allowable pulse durations and minimum allowable time between pulses; alerting the user of problems such as excessive electrical noise or insects loitering in the beam(s)which are indicated by excessive numbers of counts being rejected due to signal pulse data that do not satisfy the timing criteria; etc. The duration of the signal and the duration of the time between signals is determined by measuring the signal present digital pulse duration and the time between contiguous pulses (time-since-last) by the timers in microcontroller 36 running a signal processing software subcomponent . These timing data are used for decision making by either microcontroller 36 or central location device 42 (Figures 5 and 15) . Each probe 12 with at least one transducer 14 producing at least one beam, has dedicated circuit board 34 which processes the transducer 14 output signal, stores the extracted parameter data in non-volatile memory 37, and on command, transmits this data back through a transmission medium 52 to central location device 42 (Figures 2 and 12) . For purposes of the present invention, the nonvolatile memory 37 is a computer readable medium. The computer readable medium must be capable of operatively interacting with central location device 42. External memory can be added to circuit board 34 if additional memory is needed for storing extracted parameter data prior to transmission to central location device 42. A transmission medium is any medium through which data can be transmitted such as for example cables, including fiber optic cables; wireless, including radio links; etc. When probes 12 contain a temperature sensor 33
(Figures 2 and 3) , a temperature reading is stored in a memory such as memory 37 of microcontroller 36 or external memory located on circuit board 34, each time an insect is detected and/or on scheduled intervals. This data is also transmitted with probe 12 extracted parameter data in order to aid in using the data to estimate infestation levels . For the purposes of this invention, the central location device 42, by way of definition, is anything which can acquire, analyze, store, and display data, such as for example a computer, a hand-held monitor, etc. The data can be displayed as text or graphically to enhance the observation of trends .
In operation of circuit board 34, the conditioned sensor output is connected to the various parts of board 34 via at least one capacitive coupling 39 in order to present a signal to coupling 39 only when a sensor output transient occurs as when an object passes through a beam or beams. For purposes of the present invention, sensor output is conditioned by an operational amplifier configured as a current-to-voltage convertor 38. This conditioning circuit implementation allows the phototransistor 32 bias voltage to be set by the bias reference voltage 41 applied to the operation amplifier. The capacitive coupling and this phototransistor bias circuit effectively eliminates the effects of slow changing sensor output signals due to such variables as changing environmental conditions and/or sensor component aging. Microcontroller 36 has at least one analog input 44 (analog to digital converter; A/D input) and a non-volatile memory 37 as well as digital inputs 46 and outputs 48 (Figures 2 and 12) . The capacitively coupled sensor analog voltage signal is applied to analog input 44 as well as to a voltage threshold detector 40. For example, see Figure 6, Pin 2 of PIC16F872 for a single beam and Figure 16, Pins 2 and 3 for two orthogonal, intersecting beams in a horizontal plane. The threshold level of detector 40 is set slightly above the electronic noise floor of the conditioned sensor voltage signal so that it generates a signal present digital pulse (Figure 4) whenever any object passing near the transducer 14 alters the transducers ' 14 output level . This signal present digital pulse, which persists as long as the sensor signal is greater than the threshold level, is connected to digital inputs 46 (Figures 2 and 12) of microcontroller 36 to alert it to begin processing the signal coming in on its analog inputs 44. Also see Figures 6 and 16, Pin 21 of PIC16F872 and PIC16F873 for a single beam and two orthogonal, intersecting beams in a horizontal plane, respectively. The signal present digital pulse is also monitored by microcontroller 36 to determine the duration of a signal and duration of time-since-last signal. Microcontroller 36 stores the data extracted from sensor signals in its memory 37 and, upon request from a /central location device 42 , transmits this data back to it using a serial transmission protocol (Figures 2 and 12) . For a single beam or two orthogonal, intersecting beams in a horizontal plane, for example, these are transmitted back via Pin 23 of PIC16F872 or PIC16F873, respectively (Figures 6 and 16) . Multiplexer 50 allows the single transmission channel 52 to be bidirectional, carrying both the data request from central location device 42 to microcontroller 36 and stored extracted parameter data in the opposite direction.
The sensor output analog processing microcontroller software programs are written into the probe circuit at the time of manufacture of each probe after the circuit is completely assembled. The software programs include a signal processing sub-component, a calibration sub-component, and a data transmission sub-component embedded in a main program loop. The signal processing sub-component operation is summarized in software flowcharts (Figures 5 and 15) . It contains an interrupt service routine that is called by the main program to analyze the incoming sensor signal whenever the leading edge of an incoming signal present digital pulse generates an interrupt via the digital input 46 (Figures 2 and 12) . See Figures 6 and 16, PIN 21 of 16F872 or 16F873 for a single beam or two orthogonal, intersecting beams in a horizontal plane, for example. A signal present digital pulse usually indicates that an insect is falling past at least one transducer 14. The falling insect simultaneously results in a sensor analog voltage signal applied to the analog input 44 of microcontroller 36, whose instantaneous amplitude is at least partially determined by some physical property of the insect indicative of its species as sensed by the at least one transducer 14. The interrupt service routine monitors the analog sensor signal during the presence of the signal present digital pulse, and stores the maximum analog value attained during the signal present digital pulse interval and its time of occurrence (time-stamp) . This stored value is called the Target Peak Amplitude (TPA) of the analog signal, and it is achieved during the excursion of the insect past the at least one transducer 14. It is statistically proportional to some physical property of the insect. However, there can be a significant variability in the distribution of these Target Peak Amplitudes obtained when multiple insects of the same species fall past the at least one transducer 14. In the case of using infrared beam transducers, the nonuniform cross- sectional intensity of the infrared beam (Figure 13) , the nonuniform cross-sectional sensitivity of the phototransistor 32, and the random orientation and pathway of insects as they pass through the beam, all contribute to the variability in these Target Peak Amplitude distributions (Figure 7) . Since these distributions for different insect species may overlap, it may not be possible to positively identify the species of each falling insect by the Target Peak Amplitude of its generated analog signal using a single beam. Even so, when a number of insects of the same species falls past a transducer 14, a distribution pattern emerges with a mean and variance that can be used to identify that species . In those situations where the identity of the species cannot be ascertained with absolute certainty, it can be narrowed down to those with similar physical properties, such as similar body size as in the case of an infrared beam. It then may be narrowed down even further by knowing the predominant species in a particular geographic region. The validity of this statistical approach is based on empirical evidence that stored-product insects of any one species tend to aggregate in clusters so that the vast majority of insects entering a particular probe during a limited time interval will be of the same species. Even if there is still uncertainty, there may still be enough information to make insect control management decisions without visual inspections of the infested commodity since the destructive potential of different species is generally proportional to their body size.
When three orthogonal, intersecting beams are used, the three pulse amplitudes can be used to calculate an effective insect size value that is virtually independent of a falling insect ' s orientation. This calculation is the vector sum of the three pulses ' amplitudes and is equal to the square root of the sum of the squares of the three pulse amplitudes . As an analogy of this (Figure 8) , if a line segment of length L with any orientation in 3 dimensional space is viewed along each of the three orthogonal coordinate axes (x, y, and z) , the exact length of the segment can be calculated as the square root of the sum of the squares of the length of the segment as projected (seen) on each of the coordinate axes. Thus, the variability of the above effective insect size value would then be mainly due to factors other than insect orientation, such as non-uniformity of the infrared beams' intensities. With the use of only two orthogonal, intersecting beams, the pulse peak amplitudes from the two beams are utilized by taking the square root of the sum of the squares (vector sum) of the two amplitudes which is a more accurate method than the use of a single beam implementation for statistically inferring the species of a falling insect (Figures 7 and 11) . 'Each beam has its own current-to-voltage converters 38, capacitive coupling 39, and voltage threshold detector 40 as described above. Microcontroller 36 has two A/D inputs 44, one for each beam, and the individually measured pulse amplitudes are both transmitted back to central location device 42.
Since the signal present digital pulse is generated whenever any object passes near the at least one transducer 14 producing at least one beam, objects other than stored-product insects of concern will also get recorded. However, since their Target Peak Amplitudes are recorded, detections of differing sized objects will not erroneously be counted as stored-product insects of concern, such as for example, weevils or beetles. In fact, these other counts may provide useful information about the presence of other differing sized targets such as, for example, mites, psocids, predator insects, grain particles, etc.
When there are multiple signal present digital pulses (overlapping but not necessarily simultaneous) generated as an object falls through the intersection of multiple beams, the timing of the multiple signal present digital pulses can be processed individually, both in terms of their durations and the time intervals between pulses. However, the microcontroller 36 is alerted to begin processing at the arrival of the earlier analog pulse by combining together the multiple signal present digital pulses using a logical OR Gate 36 (Figure 12) whose output is connected to the single interrupt generating digital input 47 of microcontroller 36 (Figure 12) . In addition, the individual signal present pulses are also connected to other digital inputs 46 allowing for their possible utilization. The resulting composite signal present digital timing pulse, which begins at the leading edge of the earliest individual signal present pulse and ends at the trailing edge of the latest individual signal present pulse, is used to generate the microcontroller interrupt .
The duration of the signal present digital pulse is used to discriminate between falling objects and false detections. Optionally, this function can either be included in the microcontroller 36 interrupt service routine or in the central location device 42 software. Since the range of time it takes for an object to fall past at least one transducer 14 is known, microcontroller 36 is programmed to not record events when the signal present digital pulse durations are not within some known range in order to prevent false positives (erroneous counts) . For example, since the range of time it takes for an object to fall through an infrared beam is known to be greater than about 2 msec and less than about 30 msec, either microcontroller 36 is programmed to not record events when the signal present digital pulse durations are outside of this range in order to prevent false positives or central location device 42 is programmed to flag false positive events based on the above (user adjustable) timing criteria. Electrical transients or noise spikes, that may be generated by electric machinery or electronic current surges, are typically a few microseconds in duration and almost always less than about 1 msec. Therefore, they would not be recorded (microcontroller 36) or would be flagged (central location device 42) despite the fact that their Target Peak Amplitudes may be comparable to those produced by falling insects. Also, in the unlikely event that an insect is able to loiter in the vicinity of the at least one transducer 14 or by crawling onto the surface of the transducer (s) 14, a series of false signal present digital pulses may be generated. However, these are almost always greater than some known time duration (30 msec) and would therefore not be recorded. This function can also be handled by central location device 42 by flagging events outside the timing criteria. To provide additional protection against false positives due to loitering insects, microcontroller 36 or central location device 42 is programmed to not record (microcontroller 36) or to flag (central location device 42) any signal present digital pulse generated within a specified retrigger interval (a time-since-last criteria with a default value of about 100 msec) of the end of a previously generated signal present digital pulse, even if the previous signal present digital pulse's duration was not within the acceptable range and therefore not recorded or was flagged. These default times can be optimized as the system is in use if the user sees that a different time frame will provide more accurate results. This retrigger interval also prevents multiple detections from being counted when a single insect falls past the at least one transducer 14, either due to an irregular (double peaked) shaped analog waveform or due to grain particles being pulled in by the insect when it enters a probe.
The above features are accomplished by the signal processing sub-component as shown in the software flowcharts (Figures 5 and 15) for when the timing decision criteria are checked in microcontroller 36 or in the central location device 42, respectively. In the flowchart of Figure 5, when the leading edge of an incoming signal present digital pulse generates an interrupt, the interrupt service routine first checks whether the interrupt is within the retrigger interval from the end of the preceding signal present digital pulse. In the non- retrigger case where a signal present digital pulse begins sufficiently after any previous falling insect, the interrupt service routine moves down the central column shown in the flowchart . The interrupt service routine first starts a signal present digital pulse duration timer and sets an initial Target Peak Amplitude value. It then enters an analysis loop where it begins by checking the signal present digital pulse duration timer. If the elapsed time is less than a known minimum acceptable period (sensor specific) and the signal present digital pulse is no longer present (indicative of a noise spike) , then the interrupt service routine drops out of the analysis loop, the retrigger interval timer is started, and the interrupt service routine ends. If not, the interrupt service routine continues down the central column and again checks the signal present digital pulse duration timer. If the elapsed time is greater than a known maximum acceptable period (indicative of a crawling insect) , then the interrupt service routine drops out of the analysis loop and a long-pulse timer (discussed below) is started. If not, the interrupt service routine continues down the central column and checks for the presence of the signal present digital pulse. If the signal present digital pulse is still present, then the interrupt service routine reads the current value of sensor analog voltage signal and compares it with the stored Target Peak Amplitude value. If the current value is larger, then it becomes the new Target Peak Amplitude value, or else the previous Target Peak Amplitude value remains. In either event, the interrupt service routine returns back to the beginning of the analysis loop where it previously checked the signal present digital pulse duration timer for some minimum acceptable period elapsed and the process repeats itself. If the signal present digital pulse ends while the interrupt service routine is going around the analysis loop (indicative of an insect falling past the transducer 14 within the acceptable time range) , it drops out in the central column to store the Target Peak Amplitude, current time, and temperature. Then the retrigger interval timer is started and the interrupt service routine ends.
In the retrigger case of an object falling past a transducer 14 in less time than the retrigger interval after a previously falling object, indicating that the incoming analog waveform should be ignored, the central column of the signal processing routine is bypassed and the long-pulse timer is begun. The function of this timer is to prevent an extremely long signal present digital pulse (e.g., due to a crawling insect) from tying up microcontroller 36 and preventing it from accomplishing its other tasks such as staying in communication with central location device 42. If the signal present digital pulse lasts less than the time-out duration of the long-pulse timer, then the retrigger interval timer is started and the interrupt service routine ends, or else a long pulse flag is set which disables further interrupts, and then the interrupt service routine ends . The long-pulse timer insures that the maximum duration of the interrupt service routine (which occurs in the non-retrigger case when the maximum acceptable period in the analysis loop is followed by a time-out of the long-pulse timer) is limited. A support subroutine (shown in the flowchart) , which is regularly called by the main program while performing its other tasks, checks for the continued presence of an ongoing signal present digital pulse (i.e., a signal present digital pulse that continues beyond the end of the interrupt service routine it initiated) whenever the long pulse flag is set. Once an ongoing signal present digital pulse ends, the support sub-routine clears the long-pulse flag (which re-enables interrupts) , starts the retrigger interval timer, and microcontroller 36 is again ready to receive input signals from the transducer (s) 14.
When the decision criteria are checked in the central location device 42, the signal processing sub-component of the microcontroller software is substantially simplified. Figure 15 shows the flowchart for this sub-component when two infrared beams are employed. When the leading edge of an incoming composite signal present digital pulse generates an interrupt, the interrupt service routine clears and starts the ""signal present pulse duration" timer, reads the ""time since last" timer (referred to as the ""retrigger" timer in Figure 5) and stores its value into temporary RAM. It then clears (initializes) the two Target Peak Amplitude values stored in temporary RAM. The interrupt service routine reads the current values of sensor analog voltage signals for both beams. The interrupt service routine then compares the current value with the stored Target Peak Amplitude value for beam #1. If the current value is larger, then it becomes the new Target Peak Amplitude value for beam #1, or else the previous Target Peak Amplitude value remains in RAM. The interrupt service routine then repeats this update process for beam #2. Afterwards, if the signal present digital pulse is still present, then the interrupt service routine loops back and again reads the current values of sensor analog voltage signals for both beams . This process continues until the composite signal present digital pulse is no longer present. At that time the interrupt service routine clears and starts the ""time since last" timer, and then reads the ""signal present pulse duration" timer and stores its value into temporary RAM. Finally the interrupt service transfers the ""signal present pulse duration" value, the ""time since last" value, and the two Target Peak Amplitude values from RAM into non-volatile memory (to be later read by central location device 42) and then the service routine ends.
The function of the calibration sub-component of the microcontroller program is to help provide consistent performance across probes despite large component tolerances and varying environmental conditions over longtime usage. Consistent qualitative performance is of importance since the values of the Target Peak Amplitudes will be utilized to make management decisions instead of just the quantitative insect count response. The calibration sub-component consists of two different response sensitivity initialization routines and then ongoing self-tests. Newly manufactured probes have an initial range of response sensitivity due to component tolerances, especially transducer 14 component parameters and sensor head mechanical tolerances. The first initialization procedure, performed with each new probe, consists of dropping a calibration basic object multiple times through the exact center of sensor head 24. The Mean of the Basic target Peak Amplitudes (MBPA) from these drops is permanently recorded in the non-volatile memory 37 of microcontroller 36 as a calibration factor. Whenever a probe is put into service and it establishes communication with central location device 42, it transmits its stored Mean of the Basic target Peak Amplitude value. There it is used to adjust the incoming Target Peak Amplitude data from that probe before they are stored and displayed. This normalization is accomplished by dividing the incoming Target Peak Amplitudes by the Mean of the Basic target Peak Amplitude, thus making all new probes appear to have identical sensitivity response performance.
The validity of this normalization is based on the assumption of a linear relationship between object size (i.e., its cross- sectional area that is masking a portion of the infrared light beam) and its resulting Target Peak Amplitude. However, due to the non-uniform cross-sectional intensity of an infrared beam, which is greatest in the center and weakens towards its edges (Figure 13) , the empirical relationship between cross-sectional area and Target Peak Amplitude is not exactly linear but curves downward (Figure 14) . This is because, as the cross-sectional area of an object increases, the additional cross-sectional area of the beam that is masked is of lower intensity. The non-linear relationship can be approximated by a linear extrapolation derived from two points, the origin and that obtained with the calibration Basic object. Therefore, the size of the selected calibration Basic object determines the slope of the resulting linear extrapolation and therefore its accuracy in approximating the actual relationship across the range of insect sizes encountered during normal field operation. The optimal calibration Basic object cross- sectional area was empirically found to be that obtained with about a 2.5 mm diameter ball . Although the mathematical normalization calculation could be accomplished by microcontroller 36 prior to transmission of Target Peak Amplitude data, it is left to central location device 42 in order to reduce the overhead (computational load) of microcontroller 36.
The second initialization procedure involves the system self- test feature. The microcontroller can generate a digital test pulse that results in a momentarily change in the transducer 14 output which simulates the passing of an insect near the transducer 14. By performing this self-test at regular intervals, the system can validate proper operation of each probe. For example, with a single beam or two orthogonal, intersecting beams in a horizontal plane, microcontroller 36 can generate a digital pulse (Figures 6 and 16, PIN 24 of PIC16F872 or PIC16F873) that results in a reduction in normal current .supplied to an infrared LED(s) 30. This results in a momentary decrease in the amount of infrared light received by phototransistor 32 which simulates an insect passing through the beam. The value of the self-test current perturbation was selected to generate a similar pulse amplitude as that produced by the Basic object calibration. The self-test initialization procedure is performed on each newly manufactured probe and the resulting peak amplitude (Initial Self-test Peak Amplitude, ISPA) is permanently recorded in the microcontroller's nonvolatile memory. When a probe is put into service, this Initial Self-test Peak Amplitude number is also transmitted to the central location device 42. While the probe is in service, its self-test is performed at regular intervals, for example, about every hour. The resulting peak amplitude, called the Current Self-test Peak Amplitude (CSPA) is also transmitted to the central location device 42. This Current Self-test Peak Amplitude may differ from the Initial Self-test Peak Amplitude due to changes such as component aging, environmental changes, and potential foreign matter accumulation such as dust, moisture, etc., on the transducer 14 components. In order to reduce the effect of such changes in the interpretation of the peak amplitude data, the ratio of the Initial Self-test Peak Amplitude to the Current Self-test Peak Amplitude is used as a factor to adjust the target data. Therefore, utilizing all the above calibration data, the Adjusted Target Peak Amplitude (ATPA) can be expressed as:
ATPA = (TPA/MBPA) x (ISPA/CSPA)
This adjustment tends to make all probes appear to have identical sensitivity response performance even while they are in service for long periods under varying environmental conditions. As before, although this calculation could be accomplished by microcontroller 36, it is left to central location device 42 in order to reduce the overhead of microcontroller 36. In the case of two transducers 14 producing two beams, central location device 42 uses the two ATPAs associated with each individual falling object to calculate the Amplitude Vector Sum (AVS) for the falling object. If the actual sensitivity response degrades too much resulting in very low Target Peak Amplitudes, the probe may become unreliable or nonfunctional and require maintenance such as cleaning and/or repair. However, by continuously monitoring changes in the Current Self-test Peak Amplitude, any gradual degradation in the sensitivity response will be observed. This will allow maintenance to be scheduled and performed before catastrophic failure occurs .
Lastly, a sensor 20 software includes a data transmission subcomponent of the microcontroller program which performs the task of transmitting the stored extracted parameter data, and the calibration factors back to the central location device 42 upon its request. As previously stored extracted parameter data are transmitted back, the microcontroller 36 memory is cleared for storing newly data.
The foregoing detailed description is for the purpose of illustration. Such detail is solely for that purpose and those skilled in the art can make variations without departing from the spirit and scope of the invention. INDEX OF THE ELEMENTS
10. Microcontroller-based insect monitoring system
12. Probe
13. Upper Body Section
14. Transducer
16. Aperture
17. Funnel 20. Sensor
24. Sensor Head
25. Transducer Cable
30. Infrared Light-Emitting Diode
31. Beam
32. Phototransistor
33. Temperature Sensor
34. Probe Circuit Board
35. Beam Current Generator
36. Programmable Microcontroller
37. Internal Non-Volatile Memory
38. Current to Voltage Convertor
39. Capacitive Coupling
40. Voltage Threshold Detector
41. Bias Reference Voltage
42. Central Location Device 44. Analog Input
46. Digital Input
47. Single Interrupt Generating Digital Input
48. Digital Output 50. Multiplexer
52. Transmission Medium 54. OR Gate *************************************
* OPI_R .ASM **FILE NAME***** **** **** *****************************
* "ORIGINAL DATE* ** ***********************************
* AUGUST 16 , 000 **REVISION*F01** ********************** * ** ************
* (c) 2000**OPIsystems Inc. ************ *************************************
************************************
LIST P=16C73, R=HEX, F=INHX8M ; * ************************************
PIC16C73 EQU OFFFH ;*
************************************
**************************************************************************** Notes:
ADC_CONVERTION Valid peak sample time: >2ms and <30ms , Osc/8 No more than one bug count per 100ms
Int_Reg, 0 ENABLE :
Int_Reg, 1 ENABLE:
Int_Reg, 2 ENABLE :
Int_Reg,3 ENABLE:
Int_Reg,4 ENABLE: Convert temperature
Int_Reg,5 ENABLE: Aquire temperature tata
Int_Reg,6 DALLAS CRC: Valid/Invalid "Current temperature"
Int_Reg,7 ENABLE: RTC Timebase increment
PORT_A_0 "Got a bug: Sampling input for ADC"
PORT_B_0 Got a bug: Level detect input [!] Response > 1.15us
PORT_B_l Temperature sensor: Serial port -- [!] Inactive: Tristated
PORT_B_2 Communications: Serial data output -- Inactive: [0]
PORT_B_3 Got a bug: Test signal output" Inactive: [0]
PORT_B_4 Communications : Serial data input [ ! ]
PORT_B_5 Temperature sensor: Forced pull up -- Inactive:- {13
PORT_C_3 Memory: Serial clock Inactive: [1]
PORT_C_4 Memory: Serial data Inactive: Tristated
ERROR_REG,0 Detected: Crawling bug <Current "New" Bug Count ">
ERR0R_REG,1 Failed: Bug count self test "IR-DIODE Device unusable"
ERROR_REG,2
ERR0R_REG,3 <RESERVED>
ERROR_REG,4 Warning: Current temperature is invalid
ERROR_REG,5 Warning: Memory device is full
ERROR_REG, 6 Failed: Memory device "Device unusable"
ERROR REG, 7 Failed: Dallas device "Device unusable"
****************************************************************************
**************************************************************************** PIC16C73 SYSTEM REGISTERS : BANK 0 Indir Equ 0x00 TmrO Equ 0x01
Pel Equ 0x02
Status Equ 0x03
Fsr Equ 0x04
Port_A Equ 0x05
Port_B Equ 0x06
Port_C Equ 0x07
*
Pclath Equ OxOA
Intcon Equ 0X0B
Pirl Equ OxOC
Pir2 Equ OxOD
Tmrl_L Equ OxOE
Tmrl_H Equ OxOF
Tlcon Equ 0x10 Tmr2 Equ Oxll T2con Equ 0x12 Sspbff Equ 0x13 Sspcon Equ 0x14 Ccprl_L Equ OxlS Ccprl_H Equ 0x16 Ccplcon Equ 0x17 Rcsta Equ 0x18 TXreg Equ 0x19 RXreg • Equ OxlA • Ccpr2_l Equ OxlB Ccpr2_H Equ OxlC Ccp2con Equ OxlD Adres_H Equ OxlE AdconO Equ OxlF
.****************************************************************************
****************************************************************************
PIC16C73 SYSTEM REGISTERS : BANK 1
Option Equ 0x81 Tris_A Equ 0x85 Tris_B Equ 0x86 Tris_C Equ 0x87 Piel Equ 0x8C Pie2 Equ 0x8D Peon Equ 0x8E Pr2 Equ 0x92
Sspadd Equ 0x93 Sspstat Equ 0X94 TXsta Equ 0x98 Spbrg Equ 0X99 Adres_L Equ 0X9E Adconl Equ 0x9F
. **********************************************************
****************************************************************************
DATA REGISTERS FOR PIC16C73 : BANK [0] ( 20 - > 3 F)
Rtc_Time_0 Equ 0x20 32-bit Timebase [BO]
Rtc_Time_l Equ 0x21 ' ■ - [BI]
Rtc_Time_2 Equ 0x22 [B2]
Rtc_Time_3 Equ 0x23 [B3]
Rtc_Timer Equ 0X24 Clocked Timer
Int_Reg Equ 0x25 Control Flags
ERROR_REG Equ . 0x26 Error Register e2_Register Equ 0X27
Second_Time Equ 0x28 DALLAS_0 Equ 0x29 Temp [TEMP]
DALLAS_1 Equ 0x2A Sign [TEMP]
DALLAS_2 Equ 0x2B User Byte [TEMP]
DALLAS_3 Equ 0x2C User Byte [TEMP]
DALLAS_4 Equ 0x2D Reserved [TEMP]
DALLAS_5 Equ 0x2E Reserved [TEMP]
DALLAS_6 ' Equ 0x2F Counts Remaining [TEMP]
DALLAS_7 Equ 0x30 Counts Per °C [TEMP]
DALLAS_8 Equ 0x31 CRC [TEMP]
DALLAS_CRC_ REG Equ 0x32 Calculated CRC Value
DALLAS_COUNTER_0 Equ 0x33
DALLAS_COUNTER_l Equ 0x34
DALLAS_DATA _REG Equ 0x35
Bug_Temp_l Equ 0x36 Current Bug Temperature -[BO]
Bug_Temp_0 Equ 0x37 - [BI]
Bug_ADC_l Equ 0x38 Peak ADC Reading
Bug_ADC_0 Equ 0x39 Peak ADC Reading
Bug_Time_3 Equ 0x3A Current Bug Time [BO]
Bug_Time_2 Equ 0x3B - [BI]
Bug_Time_l Equ 0x3C - [B2]
Bug_Time_0 Equ 0x3D - [B3]
ADC_Timer Equ 0x3E Adc Timer e2_Data Equ 0x3F
.****************************************************************************
. **************** ******************************* DATA REGISTERS FOR PIC16C73 : BANK [0] : (40 - > 5F) e2_Sys_Reg Equ 0x40
DALLAS_TEMP_0 Equ 0x41
EGPIC_ID Equ 0x42 e2_Cal_l Equ 0x43 e2_Cal_0 Equ 0x44 e2_Tail_l Equ 0x45 e2_Tail_0 Equ 0x46 e2_Head_l Equ 0x47 e2_Head_0 Equ 0x48
Bug_Counter_l Equ 0x49
Bug_Counter_0 Equ 0x4A e2_Bit_Counter Equ 0X4B e2_Byte_Counter Equ 0X4C
7
Com_Control Equ 0X4D
Com_Write_Sys Equ 0x4E
Cora_Read_Sys Equ 0x4F
Com_Byte_Couπter Equ 0x50
Com_Bit_Counter Equ 0x51
Com_Timer Equ 0x52
Com_Word_0 Equ 0x53
Com_Word_l Equ 0x54
Com_Serial_0 Equ 0x55 Current EGPIC ID Number
Com_Serial_l Equ 0x56
Com_Serial_2 Equ 0x57
Com_Error_Reg Equ 0x58
Com_Data_Size Equ 0x59
Com_Transmit_Reg Equ 0x5A
Com_CRC_Reg_0 Equ 0X5B
Com_CRC_Reg_l Equ 0x5C
Com_CRC_Timer Equ 0x5D
Com_Read_Fsr Equ 0X5E
Com_Write_Fsr Equ 0x5F
.*****************************************************************************
.******************************************************************* ***** **** DATA REGISTERS FOR PIC16C73 : BANK [0] : (60 -> 7F) e2_Address_0 Equ 0x60 e2_Address_l Equ 0x61 e2_Error_Count Equ 0x62 e2_Tail_Pl Equ 0x63 e2_Tail_P0 Equ 0x64 e2_Tail_Wl Equ 0x65 e2_Tail_W0 Equ 0x66 e2_Bal_l Equ 0x67 e2_Bal_0 Equ 0x68
DALLAS_TEMP_1 Equ 0x69
T100_A5 Equ 0x70
T100_A4 Equ 0x71
T100_A3 ' Equ 0x72
T100_A2 Equ 0x73
T100_A1 Equ 0x74
T100_AO Equ 0x75
T100_B5 Equ 0x76
T100_B4 Equ 0x77
T100_B3 Equ 0x78
T100_B2 Equ 0x79
T100_B1 Equ 0x7A
T100_BO Equ 0x7B
Fsr_Temp Equ 0x7D [ ! ] System Control
Status_Temp Equ 0x7E [ ! ] System Control
W_Temp . Equ 0x7F [ ! ] System Control
.****************************************************************************
DATA REGISTERS FOR PIC16C73 : BANK [1] : (A0 -> BA)
Com_Head_0 Equ OxAO 0x05 <Constant>
Com_Head_l Equ OxAl 0x64 <Constant>
Com_Head_Size_l Equ 0xA2
Com_Head_Size_0 Equ 0xA3
Com_Head_Control Equ 0xA4 0x10 <Constant>
Com_Head_ID_To Equ OxAS
Com_Head_ID_From Equ 0XA6
Com_Head_CRC_l Equ 0XA7
Com_Head_CRC_0 Equ 0xA8
Com_Head_Word_0 Equ 0xA9 <Reserved>
Com_Head_Word_l Equ OxAA <Reserved>
Com_Head_Word_2 Equ OxAB <Reserved>
Com_Head_Word_3 Equ OxAC <Reserved>
Com_Head_Word_4 Equ OxAD <Reserved>
Com_Head_Word_5 Equ OxAE <Reserved>
Com_Head_Word_6 Equ OxAF <Reserved>
Com_Head_Word_7 Equ OxBO <Reserved> e2_Bank0_0 Equ 0xB3 e2_Bank0_l Equ 0XB4 e2_BankO_2 Equ OxBS e2_BankO_3 Equ 0XB6 e2_BankO_4 Equ 0xB7 e2_BankO_5 Equ 0xB8 e2_BankO_6 Equ- 0XB9 e2_BankO_7 Equ OxBA
.****************************************************************************
.**************************************************************************** DATA REGISTERS FOR PIC16C73 : BANK [1] (F0 FF) e2_Bankl_0 Equ OxFO e2_Bankl_l Equ OxFl e2_Bankl_2 Equ 0XF2 e2_Bankl_3 Equ 0xF3 e2_Bankl_4 Equ 0xF4 e2_Bankl_5 Equ 0xF5 e2_Bankl_6 Equ 0XF6 e2_Bankl_7 Equ 0xF7
M93 Equ OxFD RESERVED: DO NOT USE
M94 Equ OxFE RESERVED: DO NOT USE
M95 Equ OxFF RESERVED: DO NOT USE
.****************************************************************************
-- INCLUDE ANY DEFINITIONS HERE
#Define MPU_COUNTER_l 0x36
#Define MPU_COUNTER_2 0x37
#De ine MPU_COUNTER_3 0x38
#Def ne e2_CNT_0 OxFO
#Define e2_CNT_l OxFl
#Define e2_CNT_2 0xF2
#Define e2_CNT_3 0xF3
#Define e2_CNT_4 0XF4
#Define e2_CNT_5 OxFS iDefine e2_Data_ 0 0x36
#Define e2_Data_ 'l 0x37 iDefine e2_Data_ 2 0x38 iDefine e2_Data_ 3 0x39 iDefine e2_Data_ 4 0x3A
#Define e2_Data_ 5 0x3B
#Define e2_Data_ 6 0x3C
#Define e2_Data_ 7 0X3D
#Define PORT_A 0x05 iDefine PORT_B 0x06
#Define PORT_C 0x07
#Define INDIR 0x00 iDefine STATUS 0x03 iDefine FSR 0x04
#Define TRIS_A 0x85 iDefine TRIS_B 0x86 iDefine TRIS_C 0x87
Constant On 0x01
Constant Off = 0x00
#Define Lsb 0 iDefine Msb 7
**************************************************************************** ****************************************************************************
PROGRAM START Org OOOOh ; Page [0]
Nop ; <Reserved: Microchip> Bcf Intcon, 7 ; [ ! ] Disable : Global interrupt Bcf Pclath,3 ; Force: Page [0]
Goto PROGRAM RESET ,- --> Go
****************************************************************************
INTERRUPT_VECTOR Org 0004h ; Page [0]
INCLUDE <OPI R.INT> ; "INTERRUPT HANDLING"
.**************************************************************************** ***********************************************************************
*************************************************************************
PROGRAM RESET Page [0]
*****************************i**********************************************
Clrwdt <Default;
Movlw 0x20 Movwf Fsr
CLEAR_REGISTERS_0 Movlw 0x00 Movwf Indir Incf Fsr,l Movlw 0x7F Ξubwf Fsr, 0 Btfss Status, 2 " Compare" Goto CLEAR REGISTERS
Movlw OxAO Movwf Fsr
CLEAR_REGISTERS_1 Movlw 0x00 Movwf Indir Incf Fsr.l Movlw OxBA Subwf Fsr, 0 Btfss Status, 2 "Compare" Goto CLEAR REGISTERS
Movlw OxFO Movwf Fsr
CLEAR_REGISTERS_2 Movlw 0x00 Movwf Indir Incf Fsr, 1 Movlw OxFF Subwf Fsr, 0 Btfss Status, 2 "Compare" Goto CLEAR REGISTERS
*****************************************************************************
Bcf Status, 5 Select Bank [0]
Clrf Port_A
Clrf Poirt_B Setup Initial Port Values
Bsf Port_B,5 2WPWR "Dallas"
Clrf Port_C
Bsf Status, 5 Select Bank [1]
Movlw B'lll' <Disable ADC>
Movwf Adconl ADC Configuration
Movlw B'0101' A0 & Al & A3 Analog Input
Movwf Adconl "ADC Configuration"
Bsf Adconl , 7 "ADC Configuration"
Movlw B'llllOlll
Movwf Tris_C Port Configuration
Movlw B'OOOlOOll [16F872]
Movwf Tris_B Port Configuration
Movlw
Movwf Tris A Port Configuration Bcf Status, 5 ; Select Bank [0]
Movlw B'100000011 CH: A0, OSC/32, ADC: Off Movwf AdconO ; ADC Configuration
Goto PROGRAM SETUP ; --> Go
.****************************************************************************
.****************************************************************************
PROGRAM SETUP ; Note: ** One Stack Level Not Available ** Call e2 SYSTEM START
Bsf Int_Reg,4 "Convert Temperature"
Call DALLAS ΓEMPERATURE [2] Convert-Temp / Get data
Movlw OxFF
Call PRE ΓIMER
Movlw OxFF
Call PRE ΓIMER
Bsf Int_Reg, "Convert Temperature"
Call DALLAS TEMPERATURE [2] Convert-Temp / Get data
Call INTERRUPT SETUP [!] "INTERRUPT TIMING"
Movf e2_Tail_l, 0
Subwf e2_Head_l , 0
Movwf Bug_Counter_l
Movf e2_Tail_0,0
Subwf e2_Head_0 , 0
Movwf Bug_Counter_0
Bcf Status, 0
Rrf Bug_Counter_l, 1
Rrf Bug_Counter_0 , 1
Bcf Status, 0
Rrf Bug_Counter_l , 1
Rrf Bug_Counter_0 , 1
Bcf Status, 0
Rrf Bug_Counter_l , 1
Rrf Bug_Counter_0 , 1
Goto MAIN LOOP -> Go
.****************************************************************************
**************************************************************************** INCLUDED PROGRAM ROUTINES DEFINITION FILES: INCLUDE AFTER EQUATES>
Include <OPI_R.RTC> Real Time Clock: 32-bit
Include <OPI_M.TMP> Dallas Sensor: +24.5°C
Include <OPI_R.BUG> Bug Counting: 8-bit ADC
Include <OPI_R.MEM> Microchip: e: Memory
Include <OPI_R.TRX>
Include <OPI COM.PGM> Communication Program
.****************************************************************************
(w)0X7F = Is Call PRE TIMER (w)0X40 = 0.5s (w)0X20 = 0.25s (w) 0X10 = 0.125s
.****************************************************************************
PREJΓIMER Movwf MPU COUNTER 3
PRE TIMER RESET Movlw OxOA
Movwf MPU_COUNTER_l
Movlw 0x07
Movwf MPU_COUNTER_2
PRE TIMER RUN Decfsz MPU_COUNTER_l , 1
Goto PRE_TIMER_RUN
Nop <Delay>
Decfsz MPU_COUNTER_2 , 1
Goto PRE_TIMΞR_RUN
Nop <Delay>
Nop <Delay> Nop <Delay>
Decfsz MPU_COUNTER_3 , 1
Goto PRE ΓIMER_HOLD
Return --> Exit
PRE TIMER HOLD Nop <Delay> Nop <Delay> Goto PRE TIMER RESET
************************************************************************
Org O6E0h ; <Reserved: Microchip>
.**************************************************************************** END
*************************************
* OPI_R.BUG **FILE NAME***** *************************************
* **ORIGINAL DATE* *************************************
* **REVISION*F01** *************************************
* (c)2000**OPIsystems inc.************ *************************************
****************************************************************************
Notes:
ADC CONVERTION Valid peak sample time: >2ms and <30ms , Osc/ε No more than one bug count per 100ms
Int_Reg, 0 ENABLE Bug Start Int_Reg , 1 ENABLE Int_Reg,2 ENABLE Int_Reg,3 ENABLE Process Bug Data Int_Reg,4 ENABLE Convert temperature Int_Reg,5 ENABLE: Aquire temperature tata Int_Reg, 6 DALLAS CRC: Valid/Invalid "Current temperature" Int_Reg,7 ENABLE: RTC Timebase increment
PORT A 0 "Got a bug: Sampling input for ADC"
PORT_B_0 Got a bug: Level detect input [!] Response > l.lSus
PORT_B_l Temperature sensor: Serial port -- [!] Inactive: Tristated
PORT_B_2 Communications: Serial data output -- Inactive: [0]
P0RT_B_3 Got a bug: Test signal output" Inactive: [0]
PORT_B_4 Communications : Serial data input [ ! ]
PORT__B_5 Temperature sensor-. Forced pull up -- Inactive: [1]
PORT_C_3 Memory: Serial control port" Inactive: [1]
PORT_C_4 Memory: Serial data port" Inactive: Tristated
ERROR_REG,0 Detected: Crawling bug or More than [1] per 100ms
ERROR_REG,l Failed: Bug count self test "IR-DIODE Device unusable"
ERROR_REG,2 <RESERVED>
ERROR_REG,3 <RESERVED>
ERR0R_REG,4 Warning: Current temperature is invalid
ERROR_REG,5 Warning: Memory device is full
ERROR_REG,6 Failed: Memory device "Device unusable"
ERROR REG, 7 Failed: Dallas device "Device unusable"
*;**************************************************************** ***********
.****************************************************************************
EGPIC BUGGED Modular Bug Counting Program
Btfsc ERROR__REG,3 EGPIC: Failed/Active Return --> Exit
Btfss Intcon,! Enable: Got a Bug, Start ADC Return --> Exit
Btfss Int_Reg,l [!] 100ms Timeout Goto ITS_BUG_TIME
Bsf ERROR_REG,0 Detected: Crawling Bug GOtO BUG TIMEOUT --> Go
**************************************************************************** ****************************************************************************
ITS BUG TIME Movf Rtc_Time_0, 0
Movwf Bug_Time_0 "Save current time"
Movf Rtc_Time_l, 0
Movwf Bug_Time_l "Save current time"
Movf Rtc_Tirae_2, 0
Movwf Bug_Time_2 "Save current time"
Movf Rtc_Time__3 , 0
Movwf Bug_Time_3 "Save current time"
Movf DALLAS_TEMP_0 , 0
Movwf Bug_Temp_0 "Bug Temp"
Movf DALLAS_TEMP_1 , 0
Movwf Bug_Temp_l "Bug Temp"
BUG TEMP VALID Movlw OxFF
Movwf Bug_ADC_0
Movwf Bug_ADC_l
Clrf TmrO
Bcf Intcon,2 Tmro: Overflow
****************************************************************************
ADC_CONVERTION Bsf AdconO , 2 "START ADC CONVERTION" ADC TIMEOUT 30 Movlw 0x4E [10ms]
Btfss Port_B,3 "Cell Test"
Movlw OxEB [30ms]
Subwf TmrO, 0
Btfsc Status, 0
Goto BUG_TIMEOUT
Btfsc Intcon, 2
Goto BUG_SUB_EXIT
Movlw 0X10 [2ms]
Subwf TmrO, 0
Btfsc Status, 0
Goto ADC_CONTINUE
Btfss Port_B,0 Got A Bug?
Goto BUG_SUB_EXIT
ADC CONTINUE Bt ss Port_B , 0 Got A Bug, Still?
Goto BUG_EXIT --> Go
Btfsc AdconO , 2 Convertion complete: Test
Goto ADC_TIMEOUT_30
Call BUG RESULT SAVE "ADC result check"
Goto ADC CONVERTION --> Go
.**************************************************************************** .****************************************************************************
BUG RESULT SAVE
Movf Bug_ADC_l , 0 "ADC Result" (Read)
Subwf Adres_H, 0 "Bug Result" (Save)
Btfsc Status, 0
Goto BUG_RESULT_2 --> Go
BUG RESULT 2 SAVE Movf ~ Adres_H, 0 "ADC RESULT" (READ)
Movwf Bug_ADC_l "BUG RESULT" (SAVE)
Bsf Status, 5 Select Bank [1] Movf Adres_L, 0 "ADC RESULT" (READ)
Bcf Status, 5 Select Bank [0]
Movwf Bug_ADC_0 "BUG RESULT" (SAVE)
Return [!] --> Exit
;**************************************************************************** BUG RESULT 2 MOVf Bug_ADC_l , 0 "ADC Result" (Read)
Subwf Adres_H, 0 "Bug Result" (Save)
Btfss Status, 2 "Compare"
Return [!] --> Exit
Movf Bug_ADC_0 , 0 "Bug Result" (Save)
Bsf Status, 5 Select Bank [1]
Subwf Adres_L, 0 "ADC Result" (Read)
Bcf Status, 5 Select Bank [0]
Btfss Status, 0
Goto BUG RESULT 2 SAVE ~ -> Go
Return [!] --> Exit
: ****************************************************************************
.****************************************************************************
BUG EXIT Btfsc Port_B,3 "Cell Test"
Bsf Bug_ADC_l , 7 "ADC Result: Cell Test"
Bcf Port_B , 3 "Cell Test"
Btfsc ERROR_REG,5 Warning: Memory is Full
Goto BUG_SUB_EXIT
Call e2_BUG_WRITE e2: Bug Write
BUG SUB EXIT Bsf Int_Reg, 1 [!] 100ms Timeout: Reset
Movlw 0x60
Clrf Tmrl_L Timer 1 (Low byte)
Movlw OxEA
Clrf Tmrl_H Timer 1 (High byte)
Bcf Pirl,2 [!] 100ms Timer @8Mhz
Bsf Intcon, 6 [!] Enable: RTC Interrupt
BUG MAIN EXIT Bcf Intcon, 1 Enable: "Bug Toasted"
Bcf Port_B,3 "Cell Test"
Return [!] --> Exit
.**************************************************************************** *****************************************************************************
BUGJTIMEOUT
Clrf Tmrl_L Timer 1 (Low byte)
Clrf Tmrl_H Timer 1 (High byte)
Bcf Pirl, 2 [!] 250ms Timer @8Mhz
BUG TIMEOUT CHECK B Bttffssss Port_B, 0 Got A Bug, Still?
Goto BUG_SUB_EXIT
Btfss Pirl, 2 [!] FLAG: "RTC Timer Expire"
Goto BUG_TIMEOUT_CHECK
Bcf Intcon, 4 Disable: Bug Counting
Bsf ERROR_REG,3 EGPIC: Failed
Goto BUG SUB EXIT
.**************************************************************************** *************************************
* OPI_COM. PGM **FILE NAME***** *** ************ * * * * *********** *******
* "ORIGINAL DATE* ************** * *********** * **********
* "REVISION* ** * *** * * * *** ** ** *** * ***** ** ** **********
* (c) 2000**OPIsystems inc. ************ *************************************
Constant EGP_Comport = Port_B Port <A-D> Constant _comRX = 7 In <0-7> Constant comTX = 6 Out <0-7>
****************************************************************************
Notes :
Constant EGP_Comport = Port_B Port <A-D> Constant _comRX = 4 In <0-7> Constant comTX = 2 Out <0-7>
.****************************************************************************
.****************************************************************************
COMLINE CONTROL BtfSS Pirl, 2 [!] FLAG: "RTC Timer Expire"
Goto COMLINE_PROCESS_2
Bcf Int_Reg,l [!] 100ms Timeout
Bcf Intcon, 6 [!] Disable: RTC Interrupt
Goto COM PRIORITY EXIT
COMLINE PROCESS Multi-Level Modular Programming --
Btfsc Intcon, 6 [ ! ] Enable : RTC Interrupt Goto COMLINE CONTROL
COMLINE_PROCESS_2 Btfsc Com_Write_Sys, 6 Command: Write Mode Goto COM WRITE MODE
**************************************************************************** COM RECEIVE BIT
Movlw 0x10 [4.0 MHz: 36us delay]
Movwf Com_Timer [ ! ] Command Abort Timer
COM RECEIVE DELAY Decfsz Com_Timer, 1 [ ! ] Command Abort Timer
Goto COM RECEIVE DELAY --> Go
Bsf Status, 0 ,
Btfss EGP Comport,_comRX ; <-- Comport: Receive
Bcf Status, 0 ;
Rrf Com_Serial_2 , 1 ;
Rrf Com_Serial_l , 1
Rrf Com_Serial_0, 1 ,
Btfss Com_Read_Sys , 0 ; Head Frame Read Enable
Goto COM_SERIAL_CHECK
Btfsc Com_Read_Sys , 2 ■ Enable: "CRC Bit"
Goto COM_CRC_BIT OM CRC READ OUT Decfsz Com_Bit_Counter,l ,-
Goto COM_BIT_EXIT -> Go
Movlw . 0x08
Movwf Com_Bit_Counter ;
Movf Com_Serial_2 , 0 ;
Btfsc Com_Read_Sys , 3 ,• Enable: "CRC Byte"
Xorwf Com_CRC_Reg_l , 1 ;
Btfsc Com_Read_Sys , 3 Enable: "CRC Byte"
Bsf Com_Read_Sys , 2 ; Enable: "CRC Bit"
Btfss Com_Read_Sys , 1 Head Frame Read Size
Goto COM_SI2E_CHECK
Movf Com_Read_Fsr, 0 ;
Movwf Fsr
Incf Com_Read_Fsr, 1 ;
Movf Com_Serial_2 , o ;
Movwf Indir ;
Bt sc Com_Read_Sys, 5 ; Enable: ID Check /Enable
Goto COM_ID_RETURN
Btfsc Com_CRC_Timer,4 ,- Head Frame: ID To
Goto COM_ID_CHECK OM ID RETURN Btfsc Com_CRC_Timer,5 ; Head Frame : ID_From
Bcf Com_Read_Ξys, 3 ; Enable: "CRC Byte"
Btfsc Com_CRC_Timer, 6 ; Head Frame: CRC_1
Bcf Com_Read_Ξys , 2 ; Enable: "CRC Bit"
Btfsc Com_CRC_Timer, 7 ; Head Frame: CRC 0
Goto COM_CRC_CHECK
Bcf Status , 0 ;
Rlf Com_CRC_Timer, 1 ;
Goto COM BIT EXIT -> Go
****************************************************************************
OM SERIAL CHECK
Movf Com_Serial_2, 0
Btfss Status, 2 "Compare"
Goto COM_BIT_EXIT --> Go
Movf Com_Serial_l , 0
Sublw 0x64
Btfss Status, 2 "Compare"
Goto COM_BIT_EXIT --> Go
Movf Com_Serial_0 , 0
Sublw 0x05
Btfss Status, 2 "Compare"
Goto COM_BIT_EXIT --> Go
Movlw 0x08
Movwf Com_Bit_Counter
Movlw Com_Head_Control
Movwf Com_Read_Fsr
Movlw 0x91
Movwf Com_CRC_Reg__0
Movlw 0x27
Movwf Com_CRC_Reg_l
Bsf Com_Read_Sys , 3 Enable: "CRC Byte"
Bsf Com_Read_Sys , 0 Head Frame Data Enabled
Goto COM BIT EXIT --> Go
**************************************************************************** **************************************************************************** OM SIZE CHECK
Movlw 0x02
Subwf Com_Serial_2 , 0
Btfss Status, 0 "Compare"
Goto COMLINE_EXIT --> Go [Command Exit] Movf Com_Serial_2, 0
Sublw 0x06
Btfss Status, 0
Goto COMLINE_EXIT --> Go [Command Exit]
Movf Com_Serial_2 , 0
Movwf Com_Data_Size
Clrf Com_CRC_Timer
Bsf Com_CRC_Timer,3
Bsf Com_Read_Sys , 1 Head Frame Data Sized
Goto COM BIT EXIT --> Go
.****************************************************************************
.**************************************************************************** OM CRC CHECK Movf Indir, 0
Subwf Com_CRC_Reg_0 , 0
Btfss Status, 2 "Compare"
Goto COMLINE_EXIT --> .Go [Command Exit]
Decf Fsr,l
Movf Indir, 0
Subwf Com_CRC_Reg_l ,'0
Btfss Status, 2 ; "Compare"
Goto COMLINE_EXIT --> Go [Command Exit]
Btfsc Com_Read_Sys , 4 ,- Data Frame CRC Checked
Goto COM_INTERPRETER --> Go Command Process
Movlw OxFF ;
Movwf Com_CRC_Reg_0 ; 110 0 6-bytes
Movwf Com_CRC_Reg_l ; 101 1 5-bytes
Movlw 0x01 100 2 4-bytes
Movwf Com_CRC_Timer ; 011 3 3-bytes
Btfss Com_Data_Size, 2 ;
Goto C0M_CRC_DATA_A1
Btfsc Com_Data_Size, 1 ;
Goto COM_CRC_DATA_A2
Bsf Com_CRC_Timer, 1
Bt ss Com_Data_Size, 0 ;
Bsf Com_CRC_Timer, 2
Goto COM_CRC_DATA_A2 OM CRC DATA Al Bsf Com_CRC_Timer, 3 ;
Btfss Com_Data_Size, 0 ;
Bsf Com_CRC_Timer, 4 ; OM CRC DATA A2 Bsf . Com_Read_Sys, 3 Enable: "CRC Byte"
Bsf Com_Read_Sys , 4 ; Data Frame Enabled CRC CHECK
Goto COM_BIT_EXIT --> Go
. ********** ******************************************************************
: **************************************************************************** OM CRC BIT Bcf Status, 0
Rrf Com_CRC_Reg_0 , 1
Rrf Com_CRC_Reg_l , 1 ;
Btfss Status, 0
Goto COM_CRC_EXIT --> Go
Movlw OxDA
Xorwf Com_CRC_Reg_l , 1 ;
Movlw 0xC9
Xorwf Com_CRC_Reg_0 , 1 , OM CRC EXIT Btfss Com_Write_Sys, 6 ;
Goto COM_CRC_READ_OUT Go
Goto COM CRC WRITE_OUT ; Go . ************** * *********************** **************************************
. ****************************************************************************
COMLINE EXIT -- Communictions Exit Protocol
Clrf Com_Write_Sys Clrf Com_Read_Sys
****************************************************************************
COM BIT EXIT Movlw 0x14 [4.0 MHz: 200us Timeout] Movwf Com Timer [ ! ] Command Abort Timer
COM SYNCH CHECK Btfsc EGP_Comport ,__comRX <-- Comport
Goto COMLINE_SUB_EXIT --> Go
Decfsz Com_Timer,l [ ! ] Command Abort Timer
Goto COM_SYNCH_CHECK --> Go
Clrf Com_Write_Sys
Clrf Com_Read_Sys
Bcf EGP_Comport , _comRX Latch State: Synch Mode
Bcf Intcon, 0
Goto COMLINE RETURN --> Exit
****************************************************************************
COMLINE_SUB_EXIT Bsf EGP_Comport ,_comRX ; Latch State: Data Mode Bcf Intcon, 0 ;
Goto COMLINE RETURN -> Exit
.****************************************************************************
.****************************************************************************
COM PRIORITY EXIT
Clrf Com_Write_Sys
Clrf Com_Read_Sys
Bsf EGP_Comport , _comRX Latch State: Data Mode
Bcf Intcon, 0
Goto COMLINE RETURN - Exit
.****************************************************************************
.****************************************************************************
COM ID CHECK
Movf Indir, 0
Sublw OxEE
Btfsc Status, 2 "Compare"
Bsf Com_Read_Sys , 6 Enable: ID = GLOBAL
Movf Indir, 0
Subwf EGPIC_ID,0
Btfsc Status, 2 "Compare"
Bs Com_Read_Sys , 5 Enable: ID = EGPIC
Btfsc Com_Read_Sys , 5 Enable: ID = EGPIC
Goto COM_ID_RETURN --> Go
Btfsc Com_Read_Sys , 6 Enable: ID = GLOBAL
Goto COM_ID_RETURN --> Go
Goto COMLINE EXIT -> Go
.**************************************************************************** . ****************************************************************************
COMLINE ID SETUP MOVf EGPIC_ID, 0 ;
Movwf Com_Byte_Counter
Bsf Com_Write_Sys , 6 ; ENABLE: Write Mode
Bsf Com_Write_Sys,5 ; ENABLE: ID Write
COMLINE ID WRITE Btfsc Com_Write_Sys,4 ; Command: ID Write Cancel
Goto COMLINE_EXIT --> Go
Decfsz Com_Byte_Counter, 1 ;
Goto COM_BIT_EXIT --> Go
Bsf Com_Write_Sys , 7 ENABLE: [0] Write
Bsf Com_Write_Sys , 4 ,- ENABLE: ID Write Cancel
Goto COM BIT EXIT --> Go
.****************************************************************************
.****************************************************************************
COM HEAD FRAME -- Multi-Level Modular Programming
Movlw Com_Head_Word_0 ;
BtfSS Com_Write_Sys, 1 ;
Movlw Com_Head_0 ;
Movwf Com_Write_Fsr ;
Movf Com_Data_Si ze, 0 ;
Btfss Com_Write_Sys , 1 ,-
Movlw 0x07
Addlw 0x02
Movwf Com_Byte_Counter ;
Bcf Com_Write_Sys , 0 ;
Bsf Com_Write_Sys, 6 ; Command: Write Mode
Movlw OxFF
Movwf Com_CRC_Reg_0 ;
Movwf Com_CRC_Reg_l ;
Goto COMLINE BYTE SET ; -> Go
**************************************************************************** ****************************************************************************
COM WRITE MODE Multi-Level Modular Programming
Movlw OxlA
Movwf Com Timer
COM WRITE DELAY 1 Decfsz Com_Timer,l
Goto COM_WRITE_DELAY_l --> Go
Nop
Bcf EGP_Comport , _comT PORT BIT MODE: OUTPUT [10]
Bsf Com_Write_Sys , 7 [!] Command: Write [0]
Goto COM_BIT_EXIT "Testing"
Btfsc Com_Write_Sys, 5 Command: Write Mode
Goto COMLINE ID WRITE --> Go
Btfss Com_Write_Sys , 0 /Enable: "CRC Bit" Goto COM CRC BIT
COM_CRC_WRITE_OUT Decfsz Com_Bit_Counter, 1
Goto COMLINE_STATE_SET --> Go
Decfsz Com_Byte_Counter, 1
Goto COMLINE BYTE SET --> Go Btfsc Com_Write_Sys,l
Goto COMLINE_EXIT --> Go
Bsf Com_Write_Sys , 1
Goto COM_ HEAD FRAME --> Go [Command Exit]
**************************************************************************** COM CRC WRITE Movf Com._CRC_Reg_0 , 0 ;
Btfss Com_Byte_Counter, 0 ,-
Movf Com_CRC_Reg_l, 0 ;
Bsf Com_Write_Sys, 0 ;
Goto COM_WRITE_SET
COMLINE_BYTE_SET Movlw 0x08 ;
Movwf Com_Bit_Counter ;
Movf Com_Byte_Counter, 0
Sublw 0x02
Btfsc Status, 0 "Compare"
Goto COM_CRC_WRITE
Movf Com_Write_Fsr, 0
Movwf Fsr
Incf Com_Write_Fsr, .1
Movf Indir, 0
Xorwf Com_CRC_Reg_l , .1
COM WRITE SET Movwf Com_Transmit_Reg
COMLINE_STATE_SET Btfss Com_Transmit_Reg, 0 Bsf Com_Write_Sys , 7 [!] Command: Write [0] Rrf Com_Transmit_Reg, 1
Goto COM BIT EXIT -> Go r ****************************************************************************
*************************************
* OPI_M.TMP (Final) **File Name***** *************************************
* July 30, 2000 "Original Date* *************************************
* August 29, 2000 **Revision*FFl" *************************************
* (c) 2000**OPIsystems Jj^Q ^ ************ *************************************
CONSTANT DALLAS_PORT = PORT_A PORT_<A-E> CONSTANT _dalTX = 3 BIT <0-7> "INPUT" CONSTANT _dalRX = 3 BIT <0-7> "OUTPUT" CONSTANT _pulTX = 4 BIT <0-7> "OUTPUT"
****************************************************************************
DALLAS SERIAL PORT IDENTFICATION [ dalTX & dalRX can be the same]
CONSTANT DALLAS_PORT = PORT_B PORT_<A-E> CONSTANT' _dalTX = 1 BIT <0-7> "INPUT" CONSTANT _dalRX = 1 BIT <0-7> "OUTPUT" CONSTANT _pulTX = 5 BIT <0-7> "OUTPUT" ****************************************************************************
**************************************************************************** Notes :
ADC CONVERTION Valid peak sample time: >2ms and <30ms , Osc/E No more than one bug count per 100ms
Int_Reg,0 ENABLE:
Int_Reg,l ENABLE:
Int_Reg, 2 ENABLE :
Int_Reg, 3 ENABLE :
Int_Reg,4 ENABLE: Convert temperature
Int_Reg,5 ENABLE: Aquire temperature tata
Int_Reg,6 DALLAS CRC: Valid/Invalid "Current temperature"
Int_Reg,7 ENABLE: RTC Timebase increment
PORT_A_0 "Got a bug: Sampling input for ADC"
PORT_B_0 Got a bug: Level detect input [!] Response > 1.15us
PORT_B_l Temperature sensor: Serial port -- [!] Inactive: Tristated
PORT_B_2 Communications: Serial data output -- Inactive: [0]
PORT_B_3 Got a bug: Test signal output" Inactive: [0]
PORT_B_4 Communications: Serial data input [!]
PORT_B_5 Temperature sensor: Forced pull up -- Inactive: [1]
PORT_C_3 Memory: Serial control port" Inactive: [1]
PORT_C_4 Memory: Serial data port" Inactive: Tristated
ERROR_REG,0 Detected: Crawling bug <Current "New" Bug Count">
ERROR_REG,l Failed: Bug count self test "IR-DIODE Device unusable"
ERROR_REG,2 BG before MC
ERROR_REG,3 [!] Interrupt Exit Control
ERROR_REG,4 Warning: Current temperature is invalid ERROR_REG,5 Warning: Memory device is full ERROR_REG,6 Failed: Memory device "Device unusable" ERROR REG, 7 Failed: Dallas device "Device unusable"
************************************************************************
. ****************************-************************************************
DALLAS TEMPERATURE "MEASUR TEMPERATURE"
Btfss Int_Reg,4 ; "Convert Temperature"
Return [!] --> Exit
Call DALLAS_RESET "Initialize and Reset"
Bcf Int_Reg, 4 "Convert Temperature"
Btfss ERROR_REG, 7 ERROR: "Dallas Failed"
Goto DALLAS_SYSTEM
Bcf Int_Reg,4 ; "Convert Temperature"
Bcf Int_Reg, 5 ; [!] Read Scratchpad: OFF
Return [!] --> Exit
DALLAS SYSTEM Btfsc Int_Reg,5 ; "Aquire Te erature Data"
Goto DALLAS_SCRATCHPAD ;
Movlw OxCC "Skip Rom"
Call DALLAS_WRITE "Write a byte"
Movlw 0x44 "Convert Temperature"
Call DALLAS_WRITE "Write a Byte"
Bcf DALLAS_PORT,_pulTX- ; [!] Convertion: "Pull up"
Bsf STATUS , 5 SELECT BANK [1]
Bcf DALLAS_TRIS,_pulTX ; [!] Convertion: "Pull up"
Bcf STATUS, 5 SELECT BANK [1]
Bsf Int_Reg,5 ; [!] ENABLE: Scratchpad Read
Return [!] --> Exit
.******** ********************************************************************
;****************************************************************************
DALLAS SCRATCHPAD ONLY TWO ATTEMPTS ARE MADE IN RETRIEVING VALID DATA!
Bcf Int_Reg, 5 [!] Read Scratchpad: OFF
Movlw OxCC "Skip Rom"
Call DALLAS_WRITE Write: 1-byte
Movlw OxBE "Read Scratchpad"
Call DALLAS_WRITE Write: 1-byte
Call DALLAS_READ Read: 1-byte
Movwf DALLAS_0
Call DALLAS_READ Read: 1-byte
Movwf DALLAS_1
Call DALLAS_READ Read: 1-byte
Movwf DALLAS_2
Call DALLAS_READ Read: 1-byte
Movwf DALLAS_3
Call DALLAS_READ Read: 1-byte
Movwf DALLAS_4
Call DALLAS_READ Read: 1-byte
Movwf DALLAS_5
Call DALLAS_READ Read: 1-byte
Movwf DALLAS_6
Call. DALLAS_READ Read: 1-byte
Movwf DALLAS_7
Call DALLAS_READ Read: 1-byte
Movwf DALLAS_8
Call DALLAS_CRC_CHECK <CRC> Varification
Return [!] --> Exit .****************************************************************************
.****************************************************************************
DALLAS READ " READ ONE BYTE " <BIT RATE: 2us/65us>
Movlw 0x08 "8-BIT READ" Movwf DALLAS COUNTER 0 "BIT COUNTER"
**************************************************************************** DALLAS BIT READ Bcf DALLAS_PORT,_dalTX PORT BIT STATE: [0]
Bcf Intcon, 7 [1] Disable: Global interrup
Bsf STATUS , 5 SELECT BANK [1]
Bcf DALLASJTRIS ,_dalTX PORT BIT MODE: OUTPUT
Nop <DELAY>
Bsf DALLASJTRIS ,_dalTX PORT BIT MODE: INPUT [2us]
Bcf STATUS , 5 SELECT BANK [1] [3us]
Nop <DELAY>
Nop <DELAY>
Nop <DELAY>
Nop <DELAY>
Nop <DELAY>
Nop <DELAY>
Nop <DELAYED TO llUS>
Bcf DALLAS_DATA_REG, 7 BIT STATE: [0]
Btfsc DALLAS_PORT, _dalRX PORT STATE: [1] / [0] <12us>
Bsf DALLAS_DATA_REG, 7 BIT STATE: [1]
Bsf Intcon, 7 [!] Enable: Global interrupt
Movlw OxOC
Call DALLAS DELAY
****************************************************************************
Decfsz DALLAS_COUNTER_0 , 1 "BIT COUNTER" Goto DALLAS_READ_SET --> Go Movf DALLAS DATA REG, 0 "READ BYTE"
Return [!] --> EXIT
****************************************************************************
DALLAS READ SET RRF DALLAS_DATA_REG,1 ; SHIFT BIT: RIGHT Goto DALLAS BIT READ ; --> Go
*********************************************************************
.****************************************************************************
DALLAS WRITE " WRITE 1-BYTE "
Movwf DALLAS_DATA_REG [!] "BYTE TO WRITE"
Movlw 0x08 "8 -BIT WRITE"
Movwf DALLAS COUNTER 0 "BIT COUNTER" *********************************** *****************************************
DALLAS BIT WRITE Bcf DALLAS PORT, dalTX PORT BIT STATE: [0]
Btfsc DALLAS_DATA_RΞG, 0 ; DATA BIT: ONE/ZERO
Goto DALLAS_WRITE_ONE [1] AT 7us ACTIVE LOW
Bcf Intcon, 7 [!] Disable: Global interrupt
Bsf STATUS, 5 SELECT BANK [1]
Bcf DALLASJTRIS, _dalTX , PORT BIT MODE: OUTPUT
Bcf STATUS , 5 SELECT BANK [1]
Nop <DELAY>
Nop <DELAY>
Nop <DELAY>
Nop <DELAYED TO 5us>
DALLAS WRITE TIMER Movlw 0x10
Call DALLAS_DELAY
Bsf STATUS , 5 SELECT BANK [1]
Bsf DALLASJTRIS, _dalTX ; PORT BIT MODE: INPUT
Bcf STATUS , 5 SELECT BANK [1]
Bsf Intcon, 7 ; [ ! ] Enable : Global interrupt
****************************************************************************
RRF DALLAS_DATA_REG,1 RIGHT SHIFT: NEXT BIT Decfsz DALLAS_COUNTER_0 , 1 Goto DALLAS BIT WRITE -> GO ...NEXT BIT
DALLAS WRITE EXIT Return --> EXIT
**************************************************************************** ****************************************************************************
DALLAS WRITE ONE " DATA BIT = [1] "
Bsf STATUS , 5 SELECT BANK [1] Bcf DALLASJTRIS ,_dalTX PORT BIT MODE: OUTPUT Nop <DELAY> Bsf DALLASJTRIS , _dalTX PORT BIT MODE: INPUT Bcf STATUS, 5 SELECT BANK [1]
Goto DALLAS_WRITE_TIMER ; --> EXIT .****************************************************************************
.****************************************************************************
DALLAS CRC CHECK POLYNOMIAL = (X8 + X5 + X4 + 1)
Clrf DALLAS_CRC_REG <RESET> Movlw DALLAS_0 FSR: ADDRESS START Movwf FSR
****************************************************************************
DALLAS CRC LOAD Movf INDIR, 0 Movwf DALLAS_DATA_REG SET: BYTE TO CHECK
Movlw 0x08
Movwf DALLAS COUNTER 0
**************************************************************************** DALLAS_CRC_RUN Call DALLASJRCJSAMPLE ; SAMPLE BIT (n)
RRF ' DALLAS_DATA_REG, 1 DecfSZ DALLAS_COUNTER_0 , 1 Goto DALLAS CRC RUN
Movlw DALLASJ7 FSR ADDRESS: END
Subwf FSR,0
Btfsc STATUS , 2 "COMPARE"
Goto DALLASJCRC_EXIT --> GO
Incf FSR,1 NEXT --> ADDRESS
Goto DALLAS_CRC_LOAD --> GO ...NEXT BYTE
****************************************************************************
DALLAS CRC EXIT Movf DALLAS_8 , 0 DALLAS: "CRC DATA"
Subwf DALLAS_CRC_REG, 0 "COMPUTED CRC"
Bsf ERROR_REG,4 Warning: Temperature Invalid
Btfss Status, 2 "COMPARE"
Return --> EXIT
Bcf ERROR_REG,4 Warning: Temperature Valid
Bcf Intcon, 7 [!] Disable: Global interrupt
Movf DALLAS _0 , 0
Movwf DALLAS_TEMP_0
Movf DALLASJI , 0
Movwf DALLASJTEMPJ1
Bsf Intcon, 7 '. '. ] Enable: Global interrupt
Return --> EXIT
.****************************************************************************
.****************************************************************************
DALLAS CRC SAMPLE ; POLYNOMIAL = (X8 + X5 + X4 + 1)
Btfsc DALLASJCRCJEG, 0 BIT STATE: [0]
Goto DALLAS_CRC_PHASEJ1 --> GO
Bsf STATUS, 0
Btfss DALLAS_DATA_REG, 0 INPUT STATE: [1]/ [0]
Bcf STATUS, 0
Goto DALLAS CRC PHASE 2 --> GO
**************************************************************************** DALLAS CRC PHASE 1 ,-
Bcf STATUS, 0
Btfss DALLAS_DATA_REG, 0 INPUT STATE: [1]/ [0]
Bsf STATUS, 0
Goto DALLAS CRC PHASE 2 --> GO
**************************************************************************** DALLAS CRC PHASE 2 ;
RRF DALLAS CRC REG, 1 ' ; "PROCESS START"
Btfss DALLASJCRCJREG, 7 BIT STATE: [1] / [0]
Goto DALLAS_CRC_PHASEJ3 --> GO
Btfss DALLASJCRCJREG, 3 BIT STATE: "TOGGLE"
Goto DALLASJ-RCJETJ3 --> GO
Bcf DALLAS CRC REG, 3 BIT STATE: [0] Goto DALLAS CRC PHASE 3 -> GO
DALLAS CRC SET 3 Bsf DALLAS_CRC_REG, 3 BIT STATE: [1] Goto DALLAS CRC PHASE 3 --> GO
**************************************************************************** DALLAS CRC PHASE 3 ;
Btfss DALLAS CRCJREG, 7 BIT STATE: [1] / [0]
Return --> EXIT
Btfss DALLAS_CRC_REG, 2 BIT STATE: "TOGGLE"
Goto DALLAS_CRC_SET_2 --> GO
Bcf DALLAS CRC REG, 2 BIT STATE: [0]
Return --> EXIT
DALLASJCRC_SET_2 Bsf DALLAS_CRC_REG, 2 ; BIT STATE: [1]
Return ; --> EXIT
****************************************************************************
DALLAS_DELAY Movwf DALLASJCOUNTERJl DALLAS DELAY Al Decfsz DALLASJ.OUNTERJ1, 1
Goto ' DALLASJDELAYJU Nop
Return [!] --> EXIT
**************************************************************************** ****************************************************************************
DALLAS RESET " INITIALIZE AND RESET "
Bsf DALLAS_PORT,_pulTX [!] Dallas "Pull up" Comport
Movlw OxAO
Call DALLAS DELAY
Bcf ERROR_REG,7 ; ERROR: "DALLAS FAILED"
****************************************************************************
DALLAS RESET Al Bcf DALLAS_PORT,_dalTX ; <DEFAULT>
Bcf Intcon, 7 ; [!] Disable: Global interrupt
Bsf STATUS, 5 SELECT BANK [1]
Bcf DALLASJTRIS,_dalTX ; /ENABLE: SERIAL_PORT,_TX
Bcf STATUS, 5 SELECT BANK [1]
Movlw OxAO ;
Call DALLASJJELAY
Bsf STATUS, 5 SELECT BANK [1]
Bsf DALLASJTRIS, _dalTX /ENABLE: SERIAL_PORT,_TX
Bcf STATUS , 5 SELECT BANK [1]
****************************************************************************
Movlw OxOD
Movwf DALLAS COUNTER 1 ; [4]
TIMEOUT BUSY Btfss DALLAS_PORT, _dalRX PRESENSE DETECTED: NO/YES
Goto TIMEOUT_EXIT --> GO
Decfsz DALLASJCOUNTER_l, 1
Goto TIMEOUTJBUSY --> GO
Bsf Intcon, 7 [ ! ] Enable : Global interrupt
Bsf ERRORJEG,7 ERROR: "DALLAS FAILED"
Return --> EXIT
TIMEOUT EXIT Bsf Intcon, 7 [!] Enable: Global interrupt
Movlw 0x64
Call DALLAS DELAY Btfss DALLAS_PORT,_dalRX ; DEVICE FAILED: NO/YES Bsf ERROR_REG,7 ; ERROR: "DALLAS FAILED"
Return -> EXIT ****************************************************************************
**************************************************************************** DALLAS PORT DEFINITIONS:
IFDEF PORT A <PORT A>
IF DALLAS_PORT == PORT_A
CONSTANT DALLASJTRIS = TRIS_A ENDIF ENDIF
IFDEF PORT B <PORT B>
IF DALLASJPORT == PORTJβ
CONSTANT DALLASJTRIS = TRISJ3 ENDIF ENDIF
IFDEF PORT _C ; <PORT C>
IF DALLAS_PORT == PORTJC
CONSTANT DALLASJTRIS = TRISJO
ENDIF
ENDIF
IFDEF PORT D ; <PORT_D>
IF DALLAS_PORT == PORTJJ
CONSTANT DALLASJTRIS = TRISJD ENDIF ENDIF
IFDEF PORT E ; <PORT_E>
IF DALLAS_PORT == PORT_E
CONSTANT DALLASJTRIS = TRIS_E ENDIF ENDIF ****************************************************************************
. ************** * **********************
; * OPIJA . INT **FILE NAME*****
. ******** ***** ******** *** * ****** *** * **
; * "ORIGINAL DATE*
. *************************************
,- * AUGUST 16 , 2000 **REVISION*F01"
. *************************************
,- * (c) 2000**OPIsystems inc . ************ . * **** ********* * ***** ** * * ****** **** ***
*************** ****** ********* **********************************************
Notes :
ADC CONVERTION Valid peak sample time: >2ms and <30ms , Osc/ε No more than one bug count per 100ms
Int_Reg,0 ENABLE <Reserved>
Int_Reg,l ENABLE <Reserved>
Int_Reg,2 ENABLE <Reserved>
Int_Reg,3 ENABLE <Reserved>
Int_Reg,4 ENABLE Convert temperature
Int_Reg,5 ENABLE Aquire temperature tata Int_Reg,6 DALLAS CRC: Valid/Invalid "Current temperature" Int_Reg , ENABLE : RTC Timebase increment
PORT_A_0 "Got a bug: Sampling input for ADC"
PORT_B_0 Got a bug: Level detect input [!] Response > 1.15us
PORT_B_l Temperature sensor: Serial port -- [!] Inactive: Tristated
PORT_B_2 Communications: Serial data output -- Inactive: [0]
PORT_BJ3 Got a bug: Test signal output" Inactive: [0]
PORT_B_4 Communications: Serial data input [!]
PORT_B_5 Temperature sensor: Forced pull up -- Inactive: [1]
PORTJCJ3 Memory: Serial control port" Inactive: [1]
PORTJCJ4 Memory: Serial data port" Inactive: Tristated
ERROR_REG,0 Detected: Crawling bug <Current "New" Bug Count">
ERROR_REG,l Failed: Bug count self test "IR-DIODE Device unusable"
ERROR_REG,2 <Reserved>
ERROR_REG,3 [!] Interrupt Exit Control
ERROR_REG,4 Warning: Current temperature is invalid-
ERROR_REG,5 Warning: Memory device is full
ERROR_REG,6 Failed: Memory device "Device unusable"
ERROR_REG,7 Failed: Dallas device "Device unusable"
******* *********************************************************************
.****************************************************************************
INTERRUPT SERVICE [6 12]
Movwf W Temp [!] Caution: iA
Movf Status, 0 [!] Caution: iB
Bcf Status, 5 [!] Caution: #C
Movwf StatusJTemp [!] Caution: #D Movf Fsr, o [!] Caution: #E
Movwf FsrjTemp [!] Caution: #F
Btfsc ERROR_REG,3 EGPIC: Failed/Active
Goto COMLINEJSTART
Btfsc Intcon, 1
Goto COM PRIORITY EXIT
COMLINE START Btfsc Com_Write_Sys,7 [!] Command: Write [0] Bsf EGP_Comport ,_comTX [ ! ] Port bit : Output Bcf Com__Write_Sys,7 Command: Write Mode
**************************************************************************** Goto COMLINE_PROCESS ; Command Interpreter
COMLINE RETURN Call EGPICJ3UGGED Got a bug
Btfss Int_Reg, 0 RTC: Switch
Call RTC~SERVICE Service 32 -bit RTC
**************************************************************************** MPU EXIT Bcf Int__Reg,2 [!] Interrupt Switch
Movf FsrjTemp, 0 [!] Caution: iA
Movwf Fsr [!] Caution: #B
Movf StatusJTemp, 0 [!] Caution: #C
Movwf Status [!] Caution: iD
Swapf W_Temp,l [!] Caution: E
Swapf WJTemp, 0 [!] Caution: #F
Retfie --> Exit
***************************************************************************
MAIN LOOP Call RTCJSERVICE ; Service 32-bit RTC
Call DALLAS_TEMPERATURE ; [2] Convert-Temp / Get data
Goto MAIN LOOP -> Go
.****************************************************************************
.****************************************************************************
INTERRUPTJETUP ; -- Setup System Interrupts --
Bcf EGPJCo port , _comTX ; [!] "Latch State" ****************************************************************************
Movlw 0x24 Movwf CcprlJϋ Compare Register (Low)
Movlw 0xF4 Movwf CcprlJH Compare register (High)
Clrf TmπJL Timer 1 (Low byte) Clrf Tmrl H Timer 1 (High byte)
* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *
Movlw OxOB SET COMPARE MODE: CCP1 Movwf Ccplcon COMPARE SYSTEM REGISTER Bsf Status, 5 Select Bank [1]
Movlw B'llOOOlll'
Movwf 0x81
Bsf Piel,2 Enable Interrupt : RTC, CCPl
Bcf Status, 5 Select Bank [0]
Movlw B'1100011 TMR1 Prescale [8]
Movwf Tlcon Enable Timer 1
Bsf EGPJomport ,_comRX [ ! ] "Latch State"
Movlw B'10011000'
Movlw B'10001000'
Movwf Intcon [ ! ] Enable Interrupts * ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *
Return ; --> Exit **********************************************************
; ************************************* * OPI_e2.MEM "FILE NAME*****
.*************************************
;* "ORIGINAL DATE*
**************************************
;* AUGUST 16, 2000 "REVISION*F01**
.*************************************
;* (c) 2000"OPIsysterns Inc. ************ **************************************
e2JRegister
CONSTANT e2_Port = Port_A PORT_<A-E> CONSTANT e2JD = 5 BIT <0-7> "OUTPUT" CONSTANT e2 CK = 0 BIT <0-7> "OUTPUT"
**************************************************************************** -- e2 SERIAL PORT IDENTFICATION --
CONSTANT e2_Port - Port_ PORT_<A-E> CONSTANT e2J3D = 4 BIT <0-7> "OUTPUT" CONSTANT e2 CK = 3 BIT <0-7> "OUTPUT"
.**************************************************************************** **************************************************************************** -- e2 Serial Control Frame -- e2_Control_Byte
EGPIC_ID e2JCal_l e2_Cal_0 e2Jrfead_l e2_Head_0 e2_Tail_l e2_Tail_0
**************************************************************************** ****************************************************************************
-- e2 Serial Data Frame [0] -- Old "MC" data
**************************************************************************** e2_Sys_Reg,0 e2 : e2JSys_Reg,l e2 : e2 JSys_Reg , 2 e2; e2 _Sys_Reg ,3 e2 : e2Jys_Reg,4 e2 : e2 : Device error e2_Sys_Reg,5 e2 : e2: Memory Empty e2JSys_Reg,6 e2 : R/W e2_Sys_Reg,7 e2 :
**************************************************************************** .**************************************************************************** e2_PageJWrite -- Modular Memory Mangement Technology --
Return -> Exit
.**************************************************************************** .**************************************************************************** e2JyteJrtrite Modular Memory Mangement Technology
Return -> Exit
.**************************************************************************** .**************************************************************************** e2_PageJRead Modular Memory Mangement Technology
Return -> Exit
.**************************************************************************** .**************************************************************************** e2_Byte_Read Modular Memory Mangement Technology --
Return ,- --> Exit
.****************************************************************************
.**************************************************************************** e2 MEMORY GO Modular Memory Mangement Technology --
Call e2_WRITE_MODE - -> Call
Call e2_STOP - -> Call
Call e2_START --> Call
Movlw b ' 10100000 1 e2 Mode: Write
Call e2_DATAJ RITE --> Call
Call e2_READ_MODE --> Call
Bsf e2_Port , e2_CK
Nop
Nop
Nop
Nop
Bcf e JSysJReg, 4 e2 : Device Error
Btfsc e2_Port , e2 JSD "Acknowledge"
Bsf e2J ysJAeg, 4 e2 : Device Error
Bcf e2_Port, e2_CK
Call e2_WRITE_MODE --> Call
Call e2JSTOP --> Call
Btf ss e2 JSys JReg , 4 e2 : Device Error
Clrf e2 Error Count e2 error: Control Return -> Exit
.****************************************************************************
.**************************************************************************** e2 SYSTEM START
Call e2_MEM0RYJG0
Btfsc e2JSys_Reg, 4 e2: Device Error goto e2_ERR0R [!] --> Go
Movlw B'OOOlllll1 e2: Control Address [H]
Movwf e2_AddressJl
Movlw B'111110001 e2: Control Address [L]
Movwf e2_AddressJ0 F8
Movlw e2JData_0
Movwf Fsr
Bsf e2JSysJReg, 6 e2: R/W
Call e2_ADDRESSING — > Go
Btfsc e2JSysJReg,4 e2: Device Error goto e2_ERROR [!] --> Go
Movf e2 JData _0 , 0 <Reset: Vector>
Sublw 0x05
Btfss Status, 2
Goto e2_FRAME_CNT_RESET
Movf e2_Data_l, 0 <Reset: Vector>
Sublw 0x64
Btfss Status, 2
Goto e2_FRAMEJCNT_RESET
Movf e2JDataJ2, 0 <Reset: Vector>
Sublw 0xA5
Btfss Status, 2
Goto e2_FRAMEJCNT_RESET
Movf e2_Data_3, 0 <Rese : ID>
Movwf EGPICJID
Movf e2_Data_4 , 0 <Reset: ID>
Movwf e2_Cal_l
Movf e2_DataJ5, 0 <Reset: ID>
Movwf e2_CalJ0
Movf e2 JData_6 , 0 <Reset: ID>
Movwf e2JBal_l
Movf e2 JData _1 , 0 <Reset: ID>
Movwf e2_Bal_0
Call e2_MEMORYJSCAN • <Address pointer set>
Goto e2 BUG SIZE . __> Go
.****************************************************************************
-**************************************************************************** e2_FRAME_CNTJESET ;
Call e2 MEMORY GO Btfss e2_Sys_Reg, 0 ; e2: Device.Reset Btf sc e2__Sys_Reg, 4 ; e2 : Device Error goto e2_ERROR [!] --> Go
Movlw 0x01 Movwf EGPICJID
Clrf e2_Cal_l Clrf e2_Cal_0
Clrf e2 Bal_l Clrf e2_Bal_0
Clrf e2_HeadJl Clrf e2_Head_0 Clrf e2_Tail_l Clrf e2JTail_0 ;
Clrf Bug_CounterJl ; Clrf BugJ ounter_0 ;
Bsf e2J≤ys_Reg, 0 ; e2 : Device Reset Call e2_FRAMEJCNT_WRITE ; Call e2_PAGING_RESET --> Go Call e2_MEMORYJSCAN <Address pointer set>
Goto e2 SYSTEM START -> Go
. ******** ********************************************************************
. **************************************************************************** e2_FRAME_CNT_WRITE Call e2JMEMORY_GO
Btfsc e2JSysJReg, 4 e2 : Device Error goto e2_ERROR [!] --> Go
Movlw 0x05
Movwf e2_Data_0
Movlw 0x64
Movwf e2_Data_l
Movlw 0XA5
Movwf e2 Data 2
Movf EGPIC_ID, 0
Movwf e2JDataJ3
Movf e2_Cal_l , 0
Movwf e2_Data_4
Movf e2_Cal J , 0
Movwf e2 Data 5
Movf e2_Bal_l, 0
Movwf e2__Data_6
MOVf e2_Bal_0 , 0
Movwf e2_Data_7
Movlw B ' OOOlllll ' e2 : Control Address [H]
Movwf e2_AddressJl
Movlw B ' lllllOOO ' e2 : Control Address [L]
Movwf e2_Address_0 F8
Movlw- e2_Data_0
Movwf Fsr
Bcf e2 Sys_Reg , 6 e2 : R/W
Call e2_ADDRESSING --> Go
Btf sc e2_SysJΛeg, 4 e2 : Device Error goto e2_ERROR [ ! ] - -> Go
Call e2_PAGING_DELAY Delay: 6ms
Goto e2 EXIT --> Go .**************************************************************************** e2._BUG_ RITE
Call e2JMEMORY_GO
Btfsc e2_Sys_Reg,4 e2 : Device Error goto e2_ERR0R [!] --> Go
Movf e2_Head_l , 0 e2 : Control Address [H]
Movwf e2_Address_l ,
Bcf e2_Head_0 , 0 <Default>
Bcf e2_Head_0 , 1 <Default>
Bcf e2_Head_0 , 2 <Default>
Movf e2_Head_0 , 0 ; e2: Control Address [L]
Movwf e2_Address__0 ;
Movlw BugJTemp_l ;
Movwf Fsr ;
Btfsc ERR0R_REG,5 Warning: Memory Full
Goto e2_BUG_DATA_WRITE ; --> Go
Movlw OxFO
Subwf e2_Head_0 , 0 e2 : Control Address [L]
Btfss Status, 2 ; "Compare"
Goto e2_BUG_WRITE_COUNT ; --> Go
Movlw 0x1F
Subwf e2_Head_l, 0 e2 : Control Address [H]
Btfss Status , 2 ; "Compare"
Goto e2_BUGJWRITE_COUNT ; --> Go
Clrf e2_Head_l ; e2 : Control Address [H]
Clrf e2_Head_0 ; e2 : Control Address [L]
Goto e2_BUG_WRITEJNEXT ; --> Go e2J_UG_WRITE_COUNT Movlw 0x08
Addwf e2_Head_0 , 1 e2 : Address [L]
Btfsc Status , 0 ;
Incf e2_Head_l , 1 ; e2: Address [H]
e2_BUG_WRITEJNEXT Incf BugJCounter_0 , 1 ,-
Btfsc Status , 2 ;
Incf BugJounterJI, 1 ;
Movf BugJounterJO , 0 ;
Sublw OxFD
Btfss Status, 2
Goto e2_BUGJDATA_WRITE ; --> Go
Movf BugJCounterJi, 0 ;
Sublw 0x03
Btfsc Status, 2
Bsf ERRORJREG, 5 Warning: Memory Full e2_BUG_DATA WRITE Bcf e2_SysJReg , 6 ; e2: R/W
Call e2_ADDRESΞING --> Go
Btfsc e2_SysJReg,4 ; e2 : Device Error goto e2_ERROR [!] --> Go
Bcf e2_Sys_Reg,5 ; e2 : Memory Empty
Bcf Int_Reg,3 "Bug Processing Done"
Call e2_PAGING_DELAY Delay: 6ms
Goto e2_EXIT --> Go
.★★A********************************************************************** .**************************************************************************** e2 BUG READ <MC>
Call e2_MEMORY_GO
Btfsc e2_Sys_Reg,4 e2 : Device Error goto e2_ERROR [!] --> Go
Btfsc e2_Sys_Reg,5 e2 : Memory Empty
Goto e2_BUG_READ_EXIT --> Go
Movf e2_Tail_Pl,0 <Default>
Movwf e2_Address_l
Bcf e2JTail_P0,0 <Default>
Bcf e2_Tail_P0 , 1 <Default>
Bcf e2_Tail_P0,2 <Default>
Movf e2_Tail_P0 , 0 e2 : Address [L]
Movwf e2_Address_0
Movlw e2_BankO_0
Movwf Fsr e2_BUG_READ_NEXT Bsf e2_Sys_Reg, 6 e2 : Read Call e2 ADDRESSING --> Go
Btfsc e2_Sys_Reg,4 e2 : Device Error goto e2_ERROR [!] --> Go e2 BUG SIZE Movf e2_Tail_Pl , 0 e2 : Address [H]
Subwf e2_Head_l , 0 e2.- Address [H]
Btfss Status, 2 "Compare"
Goto e2_BUG_READJEXIT --> Go
Movf e2_Tail_PO,0 e2: Address [L]
Subwf e2_Head_0 , 0 e2 : Address [L]
Btfss Status, 2 "Compare"
Goto e2_BUGJREAD_EXIT --> Go
Bsf e2_Sys_Re , 5 e2 : Memory Empty e2 BUG READ EXIT G Goottoo e2 EXIT --> Go
.****************************************************************************
.**************************************************************************** e2 ADDRESSING
Bcf e2_Port , e2_CK =Default>
Call e2_WRITEJMODE ; --> Call
Call e2_STOP ; --> Call
Call e2 START ; --> Call Movlw b'10100000' e2 Mode: Write
Call e2_DATAJWRITE --> Call
Call e2_READ_MODE --> Call
Bsf e2_Por , e2_CK
Nop
Nop
Nop
Nop
Nop
Btfsc e2_Port, e2JSD "Acknowledge"
Bsf e2_Sys_Reg,4 e2 : Device Error
Bcf e2_Port, e2_CK
Call e2 WRITE MODE --> Call
****************************************************************************
Bcf e2_AddressJI , 7 ,- <Default: WP not allowed>
Movf e2_Address_l, 0 , e2 Mode: Write
Call e2_DATAJWRITE --> Call
Call e2_READ_MODE -- Call
Bsf e2_Port , e2_CK
Nop
Nop
Nop
Nop
Nop
Btfsc e2_Port , e2JSD ,- "Acknowledge"
Bsf e2JSys_Reg,4 ; e2 : Device Error
Bcf e2_Port , e2_CK
Call e2 WRITEJMODE --> Call
****************************************************************************
Movf e2_Address_0 , 0 ;; e2 Mode: Write
Call e2_DATA_WRITE -> Call
Call e2JREAD_MODE -> Call
Bsf e2_Por , e2_CK
Nop
Nop
Nop
Nop
Nop
Btfsc e2_Port , e2JSD ; "Acknowledge"
Bsf e2JSys_Reg, 4 ; e2 : Device Error
Bcf e2_Port , e2_CK ,-
Call e2_WRITEJMODE --> Call
Btfsc e2Jys_Reg, 6 ; e2: R/W
Goto e2_FSR_READ
Goto e2 FSR WRITE
**************************************************************************** **************************************************************************** e2 FSR READ 8-byte
Call e2_START --> Call
Movlw b'lOlOOOOl1 e2 Mode: Read
Call e2_DATA_WRITE --> Call
Call e2_READ_MODE --> Call
Bsf e2_Port , e2JCK
Nop
Nop
Nop
Nop
Nop
Btfsc e2 Port,e2 SD "Acknowledge" Bsf e2_Sys_Reg, 4 ; e2 : Device Error Bcf e2~Port,e2 CK
****************************************************************************
Movlw 0X08
Movwf e2_ByteJCounter ' e2 FSR READ SET Cali e2JDATA_READ --> Call
Movwf Indir
Decfsz e2_Byte_Counter, 1
Goto e2_FSR_READ_NEXT e2 FSR READ END Call e2_WRITE_MODE --> Call
Bsf e2_Port , e2_SD "Acknowledge"
Nop
Nop
Bsf e2_Port , e2_CK
Nop
Nop
Nop
Nop Nop
Nop Bcf e2_Port,e2_CK
Call e2_STOP --> Call
Goto e2 EXIT --> Go
.*********************************************** e2_FSR_READ_NEXT Call e2_WRITE_MODE --> Call
Bcf e2_Port, e2_SD ; "Acknowledge"
Nop
Nop
Bsf e2_Port , e2_CK
Nop
Nop
Nop
"Nop
Nop
Nop
Nop
Bcf e2_Port , e2_CK '
Call e2_READ_MODE --> Call
Incf Fsr,l
Goto e2 FSR READ SET
**************************************************************************** **************************************************************************** e2 FSR WRITE 8-byte
Movlw 0x08
Movwf e2_ByteJCounter e2 FSR WRITE SET Movf Indir, 0
Call e2_DATA_WRITE -> Call
Call e2_READJMODE -> Call
Bsf e2_Por , e2_CK
Nop
Nop
Nop
Nop
Nop
Btfsc e2_Port,e2_SD "Acknowledge"
Bsf e2_SysJAeg, 4 e2 : Device Error
Bcf e2 Port,e2 CK Call e2 WRITE MODE -> Call
Incf Fsr,l
Decfsz e2_ByteJCounter,l
Goto e2 FSR WRITE SET
Call e2_STOP Call Goto e2 EXIT Go
.**************************************************************************** .**************************************************************************** e2 DATA READ
Movlw 0x08
Movwf e2_BitJCounter , e2 DATA READ SET Bsf e2_Port , e2_CK ;
Nop <Delay>
Nop <Delay> <Delay>
Nop <Delay>
Bsf Status, 0
Btfss e2_Port , e2__SD ;
Bcf Status, 0
Bcf e2_Port,e2 CK
Rlf e2_Data,l Decfsz e2JBitJCounter, 1 Goto e2 DATA READ SET
Movf e2_Data,0 RETURN ;[!] - EXIT .**************************************************************************** e2 DATA WRITE
Movwf e2_Data
Movlw 0x08
Movwf e2_BitJCounter e2 DATA WRITE SET Btfsc e2_Data, 7
Call e2_BIT_l
Btfss e2_Data,7
Call e2_BIT_0
Rlf e2_Data,l
Decfsz e2_Bit_Counter, 1
Goto e2_DATA_WRITEJSET
RETURN [!] -> EXIT
.****************************************************************************
e2 BIT 1
BsF e2 Port,e2 SD Nop <Delay> Nop <Delay> BsF e2 Port,e2 CK Nop <Delay> Nop <Delay> Nop <Delay> Nop <Delay> Nop <Delay> Nop <Delay> Nop <Delay> BcF e2 Port,e2 CK RETURN ; [!] --> EXIT
***************************************************************************^ ****************************************************************************
BcF e2 Port,e2 SD Nop <Delay> Nop <Delay> BsF e2 Port,e2 CK Nop <Delay> Nop <Delay> Nop <Delay> Nop <Delay> Nop <Delay> Nop <Delay> Nop <Delay> BcF e2 Port,e2 CK
RETURN [!] -> EXIT
**************************************************************************** **************************************************************************** e2 STOP
BcF e2 Port,e2 SD Nop <Delay> Nop <Delay> BSF e2 Port,e2 CK Nop <Delay> Nop <Delay> Nop <Delay> BsF e2 Port,e2 SD Nop <Delay> Nop <Delay> Nop <Delay> BcF e2 Port,e2 CK
RETURN ;[!] -> EXIT
**************************************************************************** **************************************************************************** e2 START
Bsf e2 Port,e2 SD Nop <Delay> Nop <Delay> Bsf e2 Port,e2 CK Nop <Delay> Nop <Delay> Nop <Delay> BcF e2 Port,e2 SD Nop <Delay> Nop <Delay> Nop <Delay> BcF e2 Port,e2 CK
RETURN ;[!] -> EXIT
**************************************************************************** **************************************************************************** e2 READ MODE
Bcf e2_Port , e2JCK <Default>
Nop
Bsf Status, 5 Select Bank [1]
Bsf e2 Tris,e2 SD Bcf Status, 5 Select Bank [0] RETURN [!] --> EXIT
**************************************************************************** **************************************************************************** e2 WRITE MODE
Bcf e2_Por , e2_CK <Default>
Nop
Bsf Status, 5 Select Bank [1]
Bcf e2JTris,e2_SD
Bcf Status, 5 Select Bank [0]
RETURN [!] --> EXIT
**************************************************************************** **************************************************************************** e2 EXIT
Bcf e2_Port , e2_CK ; <Default> RETURN ; [!] --> EXIT
**************************************************************************** **************************************************************************** e2 ERROR
Bcf e2_Por , e2_CK <Default>
Incfsz e2JErrorJCount , e2 error : Control
RETURN [!] --> EXIT e2 CONTROL ERROR Bsf ERROR_REG,6 e2 : <device failure>
Bcf e2 Port,e2_CK <Default>
RETURN [>] --> EXIT
.****************************************************************************
**************************************************************************** e2 Port DEFINITIONS:
IFDEF Port A <Port A>
IF e2_Port == Port_
CONSTANT e2_Tris = Tris_A ENDIF ENDIF
IFDEF Port B <Port B>
IF e2_Port == PortJB
CONSTANT e2_Tris = Tris_B ENDIF ENDIF
IFDEF PortJO •ϊPort C>
IF e2_Port == Port_
CONSTANT e2JTris = TrisJC
ENDIF
ENDIF
IFDEF Port D <Port D>
IF e2_Port == Port_D
CONSTANT e2JTris = Tris_D ENDIF ENDIF
IFDEF Port E <Port E>
IF e2_Port == Port_E
CONSTANT e2_Tris = Tris_E ENDIF ENDIF
.************************************* ******************** ******************** .********************************************* *********************** ******** e2 MEMORY_SCAN
Bcf ERROR_REG,5 Memory: Full
Clrf e2_Tail_0
Clrf e2_Tail_l
Clrf e2_HeadJ0
Clrf e2JHeadJl
Clrf Bug_Counter_0
Clrf BugJCounter_l
Bcf e2_Sys_Reg,l e2: 0x20 "found"
Bcf e2_Sys_Reg, 2 e2: 0x40 "found"
Bcf e2J_!ys_Reg, 3 e2: Data "found"
*********************************************************************** e2 PAGE SCAN Incfsz Bug_Counter__0 1
Goto e2_SCAN_COUNTED --> Go
Incf Bug_Counter_l 1 e2 SCAN COUNTED Movf Bug_Counter_0 0
Sublw 0x00
Btfss Status , 2
Goto e2_SCAN_READ --> Go
Movf Bug_Counter_l 0
Sublw 0x04
Btfsc Status, 2
Goto e2_MEMORY_RESET --> Go e2 SCAN READ Call e2_MEMORYJGO
Btfsc e2_Sys_Reg,4 e2 : Device Error
Bsf ERROR_REG,6 Memory: Failure
Movf e2_Head_l , 0 Address: MSB
Movwf e2_Address_l
Movf e2_Head_0 , 0 Address: LSB
Movwf e2_Address_0
Movlw e2_Data_0
Movwf Fsr
Bsf • e2_SysJeg,6 e2: R/W
Call e2_ADDRESSING --> Go
Btfsc e2_SysJReg,4 • e2 : Device Error
Bsf ERR0RJREG,6 Memory: Failure
**************************************************************************** e2 PAGE CHECK Movlw 0X20
Subwf e2_DataJ2 , 0 <Control Byte>
Btfsc Status, 2 <Compare>
Goto e2_PAGE_SETJ20 --> Go
Movlw 0x40
Subwf e2_DataJ2,0 <Control Byte>
Btfsc Status, 2 <Compare>
Goto e2_PAGEJET_40 --> Go
Btfss e2_Sys_Reg,2 e2: Data "Start" Clrf Bug_Counter_0 ;
Btfss e2_Sys_Reg , 2 , e2 : Data "Start"
Clrf BugJCounter_l ,
Bsf e2_Sys_Reg, 2 , e2 : Data "Start"
Btfss e2_Sys_Reg , 1 ; e2 : 0x20 " found"
Goto e2_SCAN_ADDRESSING ; - -> Go
Btfsc e2JSysJReg, 3 ; e2 : Data " found"
Goto e2JSCAN_ADDRESSING ; - -> Go
Bsf e2jSys_Reg, 3 ; e2 : Data "found"
Clrf BugJ ounter_0 ;
Clrf BugJ ounter_l ;
Movf e2_Head_0 , 0
Movwf e2JTail_0
Movf e2 JHead_l , 0 ;
Movwf e2_Tail_l
Goto e2_SCAN_ADDRESSING ; Go
** ************************************************************** * *********** e2 PAGE SET 20 Btfss e2_Sys_Reg , 3 e2 : Data " found" Goto e2 PAGE SET 20 Al - -> Go
Btfsc e2_Sys_Reg, l e2 : 0x20 "found"
Return --> Exit e2_PAGE_SET_20_Al Bsf e2JSys_Reg, 1 ; e2 : 0x20 "found" Goto e2_SCAN_ADDRESSING ; --> Go
**************************************************************************** e2 PAGE SET 40 Btfss e2_SysJReg,3 e2 : Data "found"
Goto e2_PAGE_SET_40_A1 --> Go
Btfsc e2JSys_Reg, 1 e2: 0x20 "found"
Return --> Exit
Bsf e2JSys_Reg, 1 e2: 0x20 "found"
Goto e2 SCAN ADDRESSING --> Go e2_PAGE_SET_40_Al Clrf BugJCounter JO Bsf e2JRegister, 2 <0x40> Clrf BugJ ounterJl Movf e2_Head_0 , 0 Movwf e2JTail_0 Movf e2_Head_l , 0 Movwf e2 Tail 1 Return - - > Exit
**************************************************************************** **************************** ************************************************ e2_SCAN_ADDRESSING Call e2_PAGE_ADDRESS ING Goto e2 PAGE SCAN --> Go e2_PAGE_ADDRESSING Movlw OxFO Subwf e2_HeadJ0 , 0 e2 : Control Address [L] Btfss Status, 2 " Compare " Goto e2_SCAN_INCREMENT - -> Go Movlw OxlF Subwf e2_Head_l , 0 e2 : Control Address [H] Btfss Status, 2 "Compare" Goto e2JSCAN_INCREMENT - -> Go Clrf e2_HeadJl e2 : Control Address [H] Clrf e2 Head 0 e2 : Control Address [L] Return --> Exit e2_SCAN_INCREMENT Movlw 0x08
Addwf e2_Head_0,l e2 : Address [L]
Btfsc Status, 0
Incf e2_Head_l,l e2 : Address [H] Return --> Exit ************* * **************************************************************
. * ***** ******** ************************************************************** e2 MEMORY RESET Clrf e2_HeadJ0
Clrf e2_Head_l ;
Clrf e2_TailJl
Clrf e2_Tail_l e2 PAGING RESET Clrf BugJCounter_0 ; Time = 6.336 (s)
Clrf BugJOounter_l . ;
Movf e2_Head_0 , 0
Movwf e2_Tail_0
Movf e2 JHeadJl , 0
Movwf e2_Tail_l e2 PAGE WRITING Call e2JMEMORYJGO
Btfsc e2J ysJReg, 4 ; e2 : Device Error
Bsf ERROR_REG, 6 Memory: Failure
Movf e2_HeadJl , 0 ; Address : MSB
Movwf e2_Address_l ;
Movf e2_Head_0 , 0 Address : LSB
Movwf e2_Address_0 ;
Movlw e2_DataJ0 ;
Movwf Fsr ,-
Movlw 0x20
Movwf e 2_Dat a J2 ;
Bcf e2JSysJReg, 6 ; e2: R/W
Call e2_ADDRESSING --> Go
Btf sc e2JSys_Reg, 4 e2 : Device Error
Bsf ERROR_REG, 6 Memory: Failure
Call e2_PAGE_ADDRESSING ,-
Call e2_PAGING_DELAY Delay: 6ms
Incfsz Bug_Counter_0 , 1 ;
Goto e2_PAGE_WRITTEN -> Go
Incf Bug_Counter JI , 1 ; e2 PAGE WRITTEN Movf Bug_Counter_0 , 0 ;
Sublw OxFF
Btfss Status, 2 ;
Goto e2_PAGE_WRITING -> Go
Movf Bug_Counter JI , 0
Sublw 0x03
Btfss Status , 2 ;
Goto e2_PAGEJWRITING --> Go e2 PAGE END Clrf Bug_Counter_0 ;
Clrf Bug_CounterJl ;
Movf e2JTail_0 , 0
Movwf e2_Head_0
Movf e2_Tail_l , 0
Movwf e2_Head_l ;
Call e2JMEM0RYJG0
Btfsc e2JSys Reg, 4 , e2 : Device Error
Bsf ERR0RJREG, 6 Memory: Failure
Movf e2_HeadJl , 0 ; Address: MSB
Movwf e2_AddressJl ;
Movf e2_Head_0 , 0 Address : LSB
Movwf e2_Address_0 ,
Movlw e2JData_0 ;
Movwf Fsr ,
Movlw 0x40 Movwf e2_Data_2
Bcf e2JSys_Reg, 6 e2: R/W
Call e2_ADDRESSING --> Go
Btfsc e2J ys_Reg, 4 e2 : Device Error
Bsf ERROR_REG, 6 Memory: Failure
Call e2 PAGING DELAY Delay: 6ms
Return --> Exit
**************************************************************************** **************************************************************************** e2 PAGING DELAY Clrf e2JDataJ0 <6ms> Timing Delay ®<8Mhz>
Clrf e2_DataJl e2 PAGING DELAYED Incfsz e2_Data_0 , 1
Goto e2_PAGINGJDELAYED --> Go
Nop
Incf e2JDataJl, 1
Movlw OxOA
Subwf e2JData_l , 0
Btfss Status , 2 <Compare = 6ms>
Goto e2 PAGING DELAYED --> Go
Return -> Exit
****************************************************************************
******************** *****************
* OPIJR. RTC (Final) "File Name***** ********************* *****************
* July 30 , 2000 "Original Data* ******************** *****************
* October 17 , 2000 **Revision*FFl** ********************* *****************
; * (c) 2000**OPIsystems inc . ************ . * * * * *** * ********* ******* *************
******** * *******************************************************************
Notes :
ADC CONVERTION Valid peak sample time: >2ms and <30ms , Osc/8 No more than one bug count per 100ms
Int_Reg , 0 ENABLE :
IntJReg,l- ENABLE:
Int_Reg, 2 ENABLE:
IntJReg,3 ENABLE: "Working on a bug"
IntJReg,4 ENABLE: Convert temperature
Int_Reg,5 ENABLE: Aquire temperature tata
Int_Reg,6 DALLAS CRC: Valid/Invalid "Current temperature"
Int_Reg,7 ENABLE: RTC Timebase increment
PORT_A_0 "Got a bug: Sampling input for ADC"
PORT_B_0 Got a bug: Level detect input [!] Response > l.lSus
PORT_B_l Temperature sensor: Serial port -- [!] Inactive: Tristated
PORT_BJ2 Communications: Serial data output -- Inactive: [0]
PORT_BJ3 Got a bug: Test signal output" Inactive: [0]
PORT_B_4 Communications: Serial data input [!]
PORT_B_5 Temperature sensor: Forced pull up -- Inactive: [1]
PORTJJ3 Memory: Serial control port" Inactive: [1]
PORT__C_4 Memory: Serial data port" Inactive: Tristated
ERROR_REG,0 Detected: Crawling bug <Current "New" Bug Count">
ERROR_REG,l Failed: Bug count self test "IR-DIODE Device unusable"
ERROR_REG,2 <RESERVED>
ERROR_REG, 3. <RESERVED>
ERROR_REG,4 Warning: Current temperature is invalid
ERROR_REG,5 Warning: Memory device is full
ERROR_REG,6 Failed: Memory device "Device unusable"
ERROR REG, 7 Failed: Dallas device "Device unusable"
******* *********************************************************************
**************************************************************************** REAL TIME CLOCK : 32-BIT TIME STAMP (INCREMENTING IN SECONDS SINCE 1904)
RTC SERVICE Btfss Pirl, 2 [!] FLAG: "RTC Timer Expire"
Return --> Exit
Bsf Int_Reg, 0 RTC: Switch
Bcf Pirl, 2 [!] FLAG: "RTC Timer Expire"
Btfsc Int_Reg,6 RTC Increment: On/Off
Goto RTCJSUBJCHECK --> Go
Bsf IntJAeg, 6 RTC Increment : Off Goto RTC MAIN EXIT -> Go
RTC SUB CHECK BtfSS Int_Re , 7 RTC Increment: On/
Goto RTC_SUB_EXIT --> Go
Bcf IntJReg, 6 RTC Increment : Off
Bcf Int_Reg,7 RTC Increment: Off
Btfsc SecondJTime, 0 "Cell Test"
Bsf Port_B,3 "Cell Test"
Bcf SecondJTime, 0 "Cell Test"
RTC MAIN Movf RtcJTimer, 0
Sublw 0x05 [5]
Btfss Status,
Goto RTC_INCREMENT_A1
Clrf RtcJTimer
Bsf IntJReg, 4 "Convert Temperatu
Goto RTC_INCREMENT_A2
RTC_INCREMENT_A1 Incf RtcJTimer, 1 Timer: [10s] RTC INCREMENT A2 Incfsz RtcJTimeJO , 1 "LSB"
Goto RTC_MAIN_EXIT --> Go
Incfsz RtcJTime_l , 1 _
Goto RTC_CP_TEST --> Go
Bsf Port_B , 3 "Cell Test"
Incfsz Rtcjrime 2 , 1 _
Goto RTC_MAIN_EXIT --> Go
Incf RtcJTime_3 , 1 "MSB"
Goto RTCJMAINJEXIT --> Go
RTCJSUB_EXIT Bsf In JReg, 7 RTC Increment : On
Bcf IntJReg, 6 RTC Increment : Off RTC MAIN EXIT Bcf IntJReg, 0 RTC: Switch
Return "Next Bit, Upon Interrupt"
**************************************************************************** RTC CP TEST Movlw 0x80
Subwf RtcJTimeJl,0
Btfsc Status, 2
Bsf Port_B , 3 "Cell Test"
Goto RTC MAIN EXIT --> Go
.****************************************************************************
*************************************
* OPI_R.TRX "FILE NAME***** *************************************
* "ORIGINAL DATE* *************************************
* **REVISION*F01** **************************************
* (c)2000"OPIsystems inc.************ *************************************
**************************************************************************** Notes:
ADC_CONVERTION Valid peak sample time: >2ms and <30ms , Osc/8 No more than one bug count per 100ms
Int_Reg, 0 ENABLE :
Int_Reg,l ENABLE:
Int_Reg,2 ENABLE:
Int_Reg,3 ENABLE:
Int_Reg,4 ENABLE: Convert temperature
IntJReg, 5 ENABLE: Aquire temperature tata
Int_Reg,6 DALLAS CRC: Valid/Invalid "Current temperature"
IntJReg, 7 ENABLE: RTC Timebase increment
PORT_A_0 "Got a bug: Sampling input for ADC"
PORTJB_0 Got a bug: Level detect input [!] Response > 1.15us
PORTJ3_l Temperature sensor: Serial port -- [!] Inactive: Tristated
PORT_B_2 Communications: Serial data output -- Inactive: [0]
PORT_B_3 Got a bug: Test signal output" Inactive: [0]
PORT_B_4 Communications : Serial data input [ ! ]
PORT_B_5 Temperature sensor: Forced pull up -- Inactive: [1]
PORTJC_3 Memory: Serial control port" Inactive: [1]
PORTJC_4 Memory: Serial data port" Inactive: Tristated
ERRORJREG,0 Detected: Crawling bug <Current "New" Bug Count">
ERROR_REG,l Failed: Bug count self test "IR-DIODE Device unusable"
ERRORJREG,2 BG before MC ??
ERROR_REG,3 [!] Interrupt Exit Control
ERROR_REG,4 Warning: Current temperature is invalid
ERROR_REG,5 Warning: Memory device is full
ERROR_REG,6 Failed: Memory device "Device unusable"
ERROR REG, 7 Failed: Dallas device "Device unusable"
**************************************************************************** **************************************************************************** Command Letter Identifier Codes
Constant EG_I -. 0x49
Constant EG_D = 0x44
Constant EG_V = 0x56
Constant EG_E = 0x45
Constant EG_A = 0x41
Constant EG_K = 0x4B
Constant EG_B = 0x42
Constant EG_G = 0x47
Constant EG_L = 'L'
Constant EGJM = 0x4D
Constant EG C = 0x43 Constant EG_N = 0x4E
Constant EGJT = 0x54
Constant EG_R = 0X52
Constant EG_S = 0x53
Constant EG_W = 0x57
Constant EG_P = 0x50
Constant EGJY = 0x59
Constant EG_1 = 0x31
Constant EG_0 = 0x30
Constant VE_SEND_ _SIZE = 0x06
Constant BG_SEND_ ~SIZE = OxOD
Constant MC SEND" "SIZE = 0x08
.****************************************************************************
.**************************************************************************** COM_INTERPRETER
Bsf Status, 5 ; Select Bank [1]
Movf Com_HeadJWord_0 , 0
Bcf Status, 5 Select Bank [0]
Movwf Com_Word_0 ;
Bsf Status, 5 ; Select Bank [l]
Movf Com_HeadJWord_l , 0 ;
Bcf Status, 5 Select Bank [0]
Movwf ComJWordJl ;
Movlw EG_I
Subwf Com_Word_0 , 0 ;
Btfsc Status , 2 ; "Compare"
Goto COM_ID
Movlw EG_V
Subwf ComJord_0 , 0 ;
Btfsc Status , 2 ; "Compare"
Goto COM_VE
Movlw EG_W
Subwf ComJWord_0 , 0
Btfsc Status, 2 ; "Compare"
Goto COMJWA
Movlw EG_B
Subwf ComJord_0, 0 ;
Btfsc Status, 2 ; "Compare"
Goto COM_BG
Movlw EGJM
Subwf ComJWord_0 , 0 ,-
Btfsc Status, 2 11Compare"
Goto COMJrtC
Movlw EG_R
Subwf ComJWord 0,0 ;
Btfsc Status, 2 , "Compare"
Goto COM_RS
Movlw EGJN
Subwf ComJWord_0 , 0 ,
Btfsc Status, 2 "Compare"
Goto COM_NT
Movlw EGJS
Subwf ComJord 0,0 ,
Btfsc Status, 2 , "Compare"
Goto COM SY Movlw EG_C
Subwf ComJWordJO , 0
Btfsc Status, 2 "Compare"
Goto COMJCP
Movlw EG_L
Subwf Com_Word_0 , 0
Btfsc Status, 2 "Compare"
Goto COMJLC
Goto COMJA --> Go [Command Exit]
**************************************************************************** OM ID Global ID Identification
Movlw EG_D EGPIC: Verrify Command Word
Subwf ComJWord_l , 0
Btfss Status, 2 "Compare"
Goto COMJNA --> Go [Command Exit]
Btfss ComJReadJSys , 6 Enable: ID = GLOBAL
Goto COMLINE_EXIT - -> Go
Movf CoπjDataJoize, 0 EGPIC: Verrify Command Word
Sublw 0x02
Btfss Status, 2 "Compare"
Goto COMLINE_EXIT --> Go
Goto COMLINE_ID_SETUP --> Go [Command Exit]
Following this command is a string of 255-bits. The EGPIC ID number corrisponds to one of 255-bit positions in this bit stream. If, for example, an EGPIC's ID equals 0x43 this EGPIC would then pull the line low for a duration equal to the remainder of a normal bit period at bit stream position 0x43. This indicates: EGPIC ID 0x43 is on the line.
**************************************************************************** OM VE EGPIC: <VERSION NUMBER>
Movlw EG_E EGPIC: Verrify Command Word
Subwf ComJWord_l , 0
Btfss Status, 2 "Compare"
Goto COM_NA --> Go [Command Exit]
Movf ComJDataJSize , 0 EGPIC: Verrify Command Word
Sublw 0x02
Btfss Status, 2 "Compare"
Goto COM_NA --> Go [Command Exit]
Movlw ComJHeadJWord_0
Movwf Fsr
Movlw E'
Movwf Indir
Incf Fsr,l
Movlw 'G'
Movwf Indir
Incf Fsr,l
Movlw ιp.
Movwf Indir
Incf Fsr,l
Movlw '1'
Movwf Indir
Incf Fsr,l
Movlw
Movwf Indir
Incf Fsr,l
Movlw '0'
Movwf Indir
Movlw 0x06 <Data Size>
Goto PREPARE HEAD FR
***************************************************************************** OM BC EGPIC: <DATA>
Movlw EG_C EGPIC: Verrify Command Word
Subwf Com_Wor _l , 0
Btfss Status, 2 "Compare"
Goto COM_NA --> Go [Command Exit]
Btfsc ERROR_REG, 6 e2 "Failure"
Goto COMJNA --> Go [Command]
Movlw 0x04 EGPIC: Verrify Command Word
Subwf Com_DataJSize, 0
Btfss Status, 2 "Compare"
Goto COMJNA --> Go [Command]
Movlw Com__HeadJWord_2
Movwf Fsr
Movf Indir, 0
Movwf e2_Cal_l
Incf Fsr,l
Movf Indir, 0
Movwf e2_Cal_0
Call e2_FRAMEJCNT_WRITE
Goto COM AK Go [Command]
***************************************************************************** OM LC EGPIC: <DATA>
Movlw EGJC EGPIC: Verrify Command Word
Subwf ComJWord_l , 0
Btfss Status, 2 "Compare"
Goto COM_NA --> Go [Command Exit]
Btfsc ERROR_REG,6 e2 "Failure"
Goto COM_NA --> Go [Command]
Movlw 0x04 EGPIC: Verrify Command Word
Subwf Com_Data_Ξize, o
Btfss Status, 2 "Compare"
Goto COM_NA --> Go [Command]
Movlw ComJHead_Word_2
Movwf Fsr
Movf Indir, 0
Movwf e2_Bal_l
Incf Fsr.l
Movf Indir, 0
Movwf e2_Bal_0
Call e2_FRAMEJCNTJWRITE
Goto COM _AK --> Go [Command]
.************************************************************************** **
COM BG ; EGPIC: <DATA>
Movlw EGJG EGPIC: Verrify Command Word
Subwf ComJWord_l , 0
Btfss Status, 2 "Compare"
Goto COMJC --> Go ...
Btfsc ERROR_REG,6 e2 "Failure"
Goto COM_NA --> Go [Command]
Movf Com Data_Size, 0 EGPIC: Verrify Command Word
Sublw 0x02
Btfss Status, 2 "Compare"
Goto COMJNA --> Go [Command Exit]
Btfsc ERROR_REG,3 EGPIC: Failed/Active
Goto COM NA --> Go [Command]
Movlw Com Head Word 0 Movwf Fsr
Movf BugJounterJi , 0
Movwf Indir
Incf Fsr,l
Movf BugJCounterJO , 0
Movwf Indir
Incf Fsr, 1
Movf e2_Head_l,0
Movwf Indir
Incf Fsr,l
Movf e2_Head_0 , 0
Movwf Indir
Incf Fsr,l
Movf e2_Tail_l,0
Movwf Indir
Incf Fsr,l
Movf e2JTail_0 , 0
Movwf Indir
Incf Fsr,l
Movf RtcJTimeJi , 0
Movwf Indir
Incf Fsr,l
Movf RtcJTime_2 , 0
Movwf Indir
Incf Fsr,l
Movf RtcJTimeJL , 0
Movwf Indir
Incf Fsr,l
Movf RtcJTime_0 , 0
Movwf Indir
Incf Fsr, 1
Bsf ERROR_REG,2 BG before MC <OK>
Movlw OxOA <Data Size>
Goto PREPARE HEAD FRAME
; EGPIC: <DATA>
Movlw EGJT
Subwf ComJWordJL , 0 ;
Btfsc Status, 2 ; "Compare"
Goto COMJMT --> Go ... "else where"
Movlw EG_C EGPIC: Verrify Command Word
Subwf ComJWord_l , 0 ;
Btfss Status, 2 ; "Compare"
Goto COMJNA - -> Go [Command Exit]
Movf Com_Data _Size , 0 ; EGPIC : Verrify Command Word
Sublw 0x04
Btfss Status, 2 ; "Compare"
Goto COMJNA --> Go [Command Exit]
Btfss ERRO JΛEG,2 BG before MC: OK/! OK
Goto COMJNA --> Go [Command]
Btfsc ERROR_REG,6 e2 "Failure"
Goto COMJNA --> Go [Command]
Btfsc ERROR_REG,3 EGPIC: Failed/Active
Goto COM_NA --> Go [Command]
Movf e2_Tail_0,0
Movwf e2_Tail_P0
Movf e2_Tail_l,0
Movwf e2JTail_Pl ;
Movlw ComJHeadJWord_2
Movwf Fsr ,
Movf Indir, 0
Movwf e2_TailJWl
Incf Fsr,l ,
Movf Indir, 0 , Movwf e2 Tail WO
Movf e2JTail_Wl,0
Subwf BugJCounterJl , 0
Btfss Status, 0
Goto COM_NA -> Go [Command]
Movf e2_TailJWO,0
Subwf BugJCounter_0 , 0
Btfss Status, 0
Goto COM_NA --> Go [Command]
Movf e2_Tail_Wl,0
Btfss Status, 2 >0
Goto COM e2 DECREMENT --> Go
MOVf e2_Tail_W0,0
Btfsc Status, 2 >0
GOtO COM NA --> Go [Command]
COM e2 DECREMENT Decfsz e2JTailJWO , 1
Goto COM_e2_BUG_ADDRESS
Movf e2_Tai1_W1, 0
Btfsc Status, 2
Goto C0M_e2_BUG_READ --> Go
Decf e2_Tail Wl,l
C0M_e2_BUG_ADDRESS Movlw 0x08 Addwf e2JTail_P0, 1 Btfsc Status, 0 "Carry" Incf e2_Tail_Pl,l
Movlw OxFO
Subwf e2JTail_P0 , 0 e2 : Address [L]
Btfss Status, 2 "Compare"
Goto COM_e2JDECREMENT --> Go
Movlw OxlF
Subwf e2_Tail_Pl,0 e2: Address [H]
Btfss Status, 2 "Compare"
Goto COM_e2JDECREMENT --> Go
Clrf e2_Tail_Pl e2 : Address [H]
Clrf e2_Tail_P0 e2 : Address [L]
Goto COM e2 DECREMENT --> Go
COM e2 BUG READ Call e2 BUG READ Bug Data: Read
Movlw Com_Head_ _Word.
Movwf Fsr
Bsf Status, 5 Select: Page [1]
Movf e2_BankO_ 0, 0
Movwf Indir
Incf Fsr,l
Movf e2_BankO_ _1, ,0
Movwf Indir
Incf Fsr.l
Movf e2_BankO_ _2, ,0
Movwf Indir
Incf Fsr,l
Movf e2_BankO_ _3, ,0
Movwf Indir
Incf Fsr,l
Movf e2_BankO_ _4, : 0
Movwf Indir
Incf Fsr,l
Movf e2_BankO_ .5, ,0
Movwf Indir
Incf Fsr, 1
Movf e2 Bank0_ 6, , 0 Movwf Indir
Incf Fsr, 1
Movf e2_Bank0_ _7 0
Movwf Indir
Bcf Status , 5 Select: Page [0]
Movlw 0x08 <Data Size>
Goto PREPARE HEAD FRAME
**************************************************************************** OM MT EGPIC: AK/NA
Movlw EG_T EGPIC: Verrify Comman
Subwf ComJWord_l , 0
Btfss Status, 2 "Compare"
Goto COMJNA --> Go [Command Exit]
Btfsc e2Jys_Reg, 5 e2 : Memory Empty
Bcf ERROR_REG,2 BG before MC <!OK>
Btfsc e2_Sys_Reg,5 e2 : Memory Empty
Goto COM_NA --> Go [Command]
Btfsc ERROR__REG,6 e2 "Failure"
Goto COMJNA --> Go [Command]
Btfss ERROR_REG,2 BG before MC: OK/! OK
Goto COMJNA --> Go [Command]
Movf ComJDataJSize, 0 EGPIC: Verrify Comman
Sublw 0x04
Btfss Status, 2 "Compare"
Goto COMJNA --> Go [Command Exit]
Btfsc ERROR_REG,3 EGPIC: Failed/Active
Goto COM_NA --> Go [Command]
Movlw Com_HeadJWordJ2
Movwf Fsr
Movf Indir, 0
Movwf e2_Tail_Wl
Incf Fsr, 1
Movf Indir, 0
Movwf e2_Tail_W0
Movf e2_Tail_Wl,0
Subwf BugJCounter_l , 0
Btfss Status, 0 >=
Goto COM_NA --> Go [Command]
Movf e2_Tail_W0,0
Subwf Bug_Counter_0 , 0
Btfss Status, 0 >=
Goto COM_NA --> Go [Command]
Movf e2_Tail_Wl,0
Btfss Status, 2 • >0
Goto COM_TAIL_ADDRESS --> Go
Movf e2_Tail_W0,0
Btfsc Status, 2 • >0
Goto COMJNA • --> Go [Command] OM TAIL CHECK Call e2_MEM0RYJG0
Btfsc e2JSys_Reg,4 e2 : Device Error
Bsf ERROR_REG , 6 • Memory: Failure
Movf e2_Tail_l,0 Address : MSB
Movwf e2_Address_l
Movf e2JTailJ0,0 Address: LSB Movwf e2_Address_0
Movlw e2_Data_0
Movwf Fsr
Movlw 0x20
Movwf e2_DataJ2
Bcf e2JSys_Reg,6 e2: R/W
Call e2_ADDRESSING --> Go
Btfsc e2_Sys_Reg,4 e2 : Device Error
Bsf ERROR_REG,6 Memory: Failure
Call e2_PAGING_DELAY Delay: 6ms
Movlw 0x08
Addwf e2JTail_0,l
Btfsc Status , 0 "Carry"
Incf e2 Tail l,l
Movlw OxFO
Subwf e2JTail_0,0 e2 : Address [L]
Btfss Status, 2 "Compare"
Goto COMJCOUNTERJCHECK --> Go
Movlw OxlF
Subwf e2_TailJl,0 e2 : Address [H]
Btfss Status, 2 "Compare"
Goto COMJCOUNTERJCHECK --> Go
Clrf e2JTail_l e2 : Address [H]
Clrf e2 Tail 0 e2 : Address [L] OM COUNTER CHECK Decfsz Bug_Counter_0 , 1
Goto COM_TAIL_ADDRESS --> Go
Movf Bug_CoύnterJI , 0
Btfsc Status, 2
Goto COM_TAIL_ADDRESS --> Go
Decf Bug_Counte Ji , 1 OM TAIL ADDRESS Decfsz e2JTailJW0 , 1
Goto • COMJTAILJCHECK --> Go
Movf e2_Tail_Wl,0
Btfsc Status, 2
Goto COM_MT_EXIT_2 Go
Decf e2_Tail_Wl,l
Goto COM TAIL CHECK Go OM MT EXIT 2 Movf Bug_CounterJI , 0
Btfss Status, 2
Goto COMJMTJEXIT --> Go
Movf BugJCounter_0 , 0
Btfss Status, 2
Goto COM_MT_EXIT --> Go
Call e2_PAGE_END OM MT EXIT Bcf ERROR_REG,5 Warning: Memory is Full
Bcf ERROR_REG,2 BG before MC <!OK>
Goto COMLINEJEXIT --> Go [Command Exit]
Goto COM AK --> Go [Command Exit]
**************************************************************************** OM NT ; EGPIC: <NONE>
Movlw EGJT EGPIC: Verrify Command Word
Subwf ComJWordJl , 0
Btfss Status, 2 ; "Compare"
Goto COM_NA --> Go [Command Exit]
Movf Com_DataJize, o , EGPIC: Verrify Command Word
Sublw 0x06
Btfss Status, 2 ; "Compare"
Goto COM_NA --> Go [Command]
Movlw Com Head Word 2 ; Movwf Fsr
Movf Indir, 0
Movwf Rtc_Time_ 3
Incf - Fsr, 1
Movf Indir, 0
Movwf RtcJTime _2
Incf Fsr.l
Movf Indir, 0
Movwf Rtc_Tάme_ 1
Incf Fsr.l
Movf Indir, 0
Movwf RtcJTime_ 0
Goto COM AK -> Go [Command]
. ************** **************************************************************
COM_RB ; EGPIC: AK/NA
Movlw EG_B EGPIC: Verrify Command Word
Subwf ComJWord_l , 0
Btfss Status, 2 "Compare"
Goto COMJNA --> Go [Command Exit]
Movf ComJDataJSize, 0 EGPIC: Verrify Command Word
Sublw 0x02
Btfss Status, 2 "Compare"
Goto COM_NA --> Go [Command]
Goto PROGRAM _START --> Go [Command RESET]
? .****************************************************************************
COM RS EGPIC: AK/NA
Movlw EG_S EGPIC: Verrify Command Word
Subwf Comjriordjl , 0
. Btfss Status, 2 "Compare"
Goto COMJRB --> Go [Command Exit]
Movf ComJDataJSize, 0 EGPIC: Verrify Command Word
Sublw 0x02
Btfss Status, 2 "Compare"
Goto COMJNA --> Go [Command]
Clrf RtcJTime_0
Clrf Rtc_Time_l
Clrf Rtc_Time_2
Clrf RtcJTimeJ3
Clrf ERROR_REG [!] Error: All Off
Bsf e2_Sys_Reg, 5 e2 : Memory Empty
Call e2_PAGING_RESET --> Go
Call e2_MEMORY_SCAN •-.Address pointer set>
Bcf Intcon, 1 Enable: "Bug Toasted"
Bsf Intcon, 4 [ ! ] Enable Bug Counting
Goto COMLINE_EXIT --> Go [Command Exit]
Goto COM AK --> Go [Command Exit]
***************************************************************************** COM WA EGPIC: AK/NA
Movlw EG_A EGPIC: Verrify Command Word
Subwf ComJWord_l , 0
Btfss Status, 2 "Compare"
Goto COMJNA --> Go [Command Exit]
Btfsc ERROR_REG,6 e2 "Failure"
Goto COMJNA --> Go [Command]
Movf ComJData_Size, 0
Sublw 0x03
Btfss Status, 2 "Compare"
Goto COMJNA --> Go [Command Exit]
Movlw ComJHeadJWord_2
Movwf Fsr
Movf Indir, o Movwf EGPIC_ID
Call e2_FRAME_CNT_WRITE
Goto COM AK -> Go [Command Exit]
*****************************************************************************
COM SY EGPIC: AK/NA
Movlw EG_Y EGPIC: Verrify Command Word
Subwf Com_Word_l, 0
Btfss Status, 2 "Compare"
Goto COMJNA --> Go [Command Exit]
Movf Com_Data_Size, 0 EGPIC: Verrify Command Word
Sublw 0x02
Btfss Status, 2 "Compare"
Goto COMJNA --> Go [Command Exit]
Movlw Com_Head_Word_0
Movwf Fsr
Movf DALLASJTEMPJI , 0
Movwf Indir
Incf Fsr, 1
Movf DALLASJTEMPJO , 0
Movwf Indir
Incf Fsr,l
Movf e2_Bal_l , 0
Movwf Indir
Incf Fsr,l
Movf e2_Bal_0 , 0
Movwf Indir
Incf Fsr,l
Movf e2Jal_l , 0
Movwf Indir
Movw In r
Incf Fsr, 1
Movf ERROR_REG, 0
Movwf Indir
Bcf Indir, 2 "BG before MC"
Bcf Indir, 3 "Dallas Abort"
Movlw 0x07 <Data Size>
Goto PREPARE HEAD FRAME
.****************************************************************************
COMJCP ; EGPIC: AK
Movlw EG_P EGPIC: Verrify Command Word
Subwf ComJWordJl , 0
Btfss Status, 2 "Compare"
Goto COMJNA --> Go [Command Exit]
Movf ComJDataJSize, 0 EGPIC: Verrify Command Word
Sublw 0x02
Btfss Status, 2 "Compare"
Goto COMJNA --> Go [Command Exit]
Bsf SecondJTime , 0 "Cell Test"
Goto COM_AK --> Go [Command Exit]
.****************************************************************************
COM AK EGPIC: AK
Btfsc Com_Read_Sys , 6 Enable: 11
Goto COMLINEJ3XIT --> Go [Cc
Movlw Com_HeadJWord_0
Movwf Fsr
Movlw 'A'
Movwf Indir Incf Fsr,l
Movlw •K'
Movwf Indir
Movlw 0x02 <Data Size>
Goto PREPARE HEAD FRAME
. ******* *********************************************************************
COM NA EGPIC: NA
BtfSC ComJRead_Sys , 6 Enable : ID GLOBAL
Goto COMLINE_EXIT --> Go [Com
Movlw Com_Head_Word_0
Movwf Fsr
Movlw 'N'
Movwf Indir
Incf Fsr,l
Movlw 'A'
Movwf Indir
Movlw 0x02 <Data Size>
Goto PREPARE HEAD FRAME
.****************************************************************************
*****************************************************************************
7
PREPARE_HEAD FRAME ;
BtfSC Com_Read_Sys , 6 ; Enable: ID = GLOBAL
Goto COMLINE_EXIT --> Go [Command -Exit]
Movwf ComJData_Size ;
Movlw Com_Head_0 ;
Movwf Fsr
Movlw 0x05
Movwf Indir ;
Incf Fsr,l ,-
Movlw 0x64 '
Movwf Indir ;
Incf Fsr,l ;
Movlw 0x00
Movwf Indir ;
Incf Fsr, 1
Movf ComJDataJSize ,0 ' ;
Movwf Indir ;
Incf Fsr,l
Movlw 0x10
Movwf Indir ;
Incf Fsr,l ;
Bsf Status, 5 ; Select: Page [1]
Movf Com_HeadJID_From, 0 ;
Bcf Status, 5 ; Select: Page [0]
Movwf Indir ;
Incf Fsr,l
Movf EGPIC_ID,0
Movwf Indir ;
Goto COM HEAD FRAME
* * * ********* * **** ****** ************** ************ ***** * ***** * ****************

Claims (22)

What is claimed is:
1. A system for quantitative and/or qualitative detection of insect infestation in stored products comprising:
(a) at least one probe detector containing a sensor head having at least one transducer for detecting the passage of at least one insect through said probe head and producing an analog output wherein said output is a waveform,
(b) a circuit board operatively connected to said transducers for collecting and storing data generated by said transducers , and
(c) a central location device operatively connected to said circuit board for collecting circuit board data for further processing and storage.
2. The system of claim 1 wherein said sensor head has infrared transducers producing multiple beams wherein orientation and position of each beam improves the probability of capturing the largest cross-sectional area of said insect.
3. The system of claim 1 wherein said circuit board comprises a programmable microcontroller, and at least one voltage threshold detector.
4. The system of claim 3 wherein said microcontroller includes an analog input, at least one digital input, a digital output and an internal non-volatile memory.
5. The system of claim 3 wherein said microcontroller contains a computer readable medium having a software program which includes a signal processing sub-component, a calibration subcomponent, and a data transmission sub-component .
6. The system of claim 5 wherein said signal processing subcomponent analyzes an incoming sensor signal to determine if the signal is produced by an insect falling through the sensor head by checking a signal present digital pulse duration; when said signal is produced by a falling insect, said sub-component determines at least one maximum analog value during a pulse interval, said sub-component time stamps said at least one determined maximum analog value, and stores said at least one value and the time stamp.
7. The system of claim 5 wherein said calibration subcomponent comprises at least two response sensitivity initialization routines in order to obtain calibration factors .
8. The system of claim 1 wherein said probe includes a temperature sensor operatively connected to said circuit board.
9. A method for detecting insect infestation in stored products comprising:
(a) placing a grain probe detector containing (1) a sensor head having at least one transducer for detecting the passage of at least one insect through the probe sensor head, and (2) a circuit board operatively connected to said transducers; into a stored product,
(b) detecting the passage of at least one insect through the probe and providing at least one analog output, and generating a signal present digital pulse in said circuit board based on said analog output,
(c) determining if said signal is greater than threshold level,
(d) sending said signal greater than threshold level to a microcontroller on said circuit board,
(e) processing said signal to extract data from said signal, and
(f) storing said extracted data in a memory of said microcontroller.
10. A method for detecting insect infestation in stored products comprising:
(a) placing a probe detector having (1) a sensor head having infrared transducers producing multiple beams for detecting passage of at least one insect through the probe sensor head, and (2) a circuit board operatively connected to said transducers; into a stored product,
(b) detecting passage of at least one insect through the probe and providing at least two analog outputs,
(c) determining if said outputs are greater than threshold level ,
(d) generating a signal present digital pulse,
(e) converting said analog outputs to target peak amplitudes,
(f) combining individual time duration digital pulses to form a composite digital pulse,
(g) measuring the time between contiguous pulses,
(h) measuring composite signal digital pulse duration, and (i) transmitting peak amplitudes with time stamps, time between contiguous pulses and signal present digital pulse duration to a central location device.
11. The method of claim 10 further including calculating a vector sum to obtain an insect size value.
12. The method of claim 10 further including using a mathematical classification analysis to determine insect species using the data transmitted to said central location device .
13. The method of claim 9 further comprising: sending said data stored by said memory to a central location device.
14. The method of claim 13 further including calculating a vector sum to obtain an insect size value.
15. The method of claim 13 further comprising using a mathematical classification analysis to determine insect species using the data transmitted to said central location device .
16. A computer readable medium encoded with a software program for monitoring insects in stored products wherein said program
(a) analyzes at least one incoming analog sensor signal when at least one incoming signal present digital pulse is detected,
(b) measures duration of the at least one signal present digital pulse,
(c) monitors the at least one analog sensor signal for a maximum analog value,
(d) records and stores an at least one maximum analog value to form at least one target peak amplitude for transmission to a central location device, and
(e) records and stores time of occurrence of said at least one maximum analog value.
17. The computer readable medium of claim 16 wherein said program further calibrates new grain probe detectors for consistent performance by
(a) determining a standard mean target peak amplitude creating a first calibration factor , and
(b) recording and storing said standard mean target peak amplitude for transmission to said central location device.
18. The computer readable medium of claim 16 where said program further self-tests new grain probe detectors to validate the operation of at least one grain probe detector by
(a) generating a digital test pulse to simulate an insect passing said transducer to obtain an initial self-test peak amplitude creating a second calibration factor,
(b) recording and storing said initial self-test peak amplitude for transmission to a central location device.
19. The computer readable medium of claim 16 wherein said program self-tests grain probe detectors that are in operation in a stored product by. (a) generating a digital test pulse to simulate an insect passing said transducer to obtain a current self-test peak amplitude creating a third calibration factor,
(b) recording and storing said current self-test peak amplitude for transmission to a central location device.
20. A method for detecting insect infestation in stored products comprising:
(a) placing a grain probe detector containing (1) a sensor head having an infrared transducer for detecting passage of at least one insect through the probe sensor head, and (2) a circuit board operatively connected to said transducers; into a stored product,
(b) detecting the passage of at least one insect through the probe and providing at least one analog output, and generating at least one signal present digital pulse in said circuit board based on said analog output,
(c) determining if said at least one signal is greater than threshold level,
(d) sending said at least one signal greater than threshold level to a microcontroller on said circuit board,
(e) processing said signal to extract data from said at least one signal, using a computer readable medium having a software program which (1) analyzes said analog sensor signal when an incoming signal present digital pulse is detected,
(2) measures duration of the signal present digital pulse,
(3) records and stores the duration of the signal present digital pulse,
(4) monitors the analog sensor signal for a maximum analog value,
(5) records and stores time of occurrence of said maximum analog value.
(6) records and stores a maximum analog value to form a target peak amplitude for transmission to a central location device , (7) measures the duration of the interval between contiguous signal present digital pulses, and (8) records and stores said duration.
21. The method of claim 20 further comprising: sending said stored data to a central location device for analysis .
22. The method of claim 21 further comprising self-testing said grain probe detectors wherein said program
(1) generates a digital test pulse to simulate an insect passing said transducers to obtain a current self-test peak amplitude creating a calibration factor,
(2) recording and storing said current self-test peak amplitude for transmission to a central location device.
AU2002256410A 2001-05-02 2002-05-02 Sensor output analog processing-a-microcontroller-based insect monitoring system Abandoned AU2002256410A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
US09/846,277 2001-05-02
US10/135,503 2002-05-01

Publications (1)

Publication Number Publication Date
AU2002256410A1 true AU2002256410A1 (en) 2002-11-11

Family

ID=

Similar Documents

Publication Publication Date Title
WO2002088700A1 (en) Sensor output analog processing-a microcontroller-based insect monitoring system
KR101118245B1 (en) A preconsideration management system of fruit tree insect pest by extracting insect type and distribution from photograph images
US5646404A (en) Electronic grain probe insect counter (EGPIC)
US20060082444A1 (en) Management system for enhanced RFID system performance
JPH06507241A (en) High-speed particle measurement and classification system
CN105931402A (en) Optical fiber perimeter intrusion monitoring method based on image recognition
CN105259909B (en) Vegetation collecting method and harvester based on unmanned vehicle
US6707384B1 (en) Sensor output analog processing—A microcontroller-based insect monitoring system
IL261481B2 (en) Improved system and method for detecting agricultural pests
US20230390941A1 (en) System and method for sorting and/or packing items
CN105606532B (en) Pest counts and category identification device
CN107037062A (en) Coaxial cable material microwave property is monitored on-line and diagnostic device and method
KR101864284B1 (en) System and method for forecasting tree disease
US9417120B2 (en) Device and methods for quantifying plants using an active light sensor for scanning plants in a defined area
Sciarretta et al. Development of automated devices for the monitoring of insect pests.
JP2022538020A (en) automatic spore trap
AU2002256410A1 (en) Sensor output analog processing-a-microcontroller-based insect monitoring system
CN109884088A (en) Fruit maturity compartment intelligent checking system and detection method
JP2004530141A (en) Method and apparatus for detecting, identifying and quantifying densitometric insects in stock cereals
CN105700500A (en) Automation equipment for IOT (Internet of Things) WIFI module tension testing
Deng et al. Discrimination of crop and weeds on visible and visible/near-infrared spectrums using support vector machine, artificial neural network and decision tree
US20240096185A1 (en) Intrusion detection algorithm with reduced tuning requirement
CN104778494A (en) Multi-sensor target identification algorithm for insect counting
Shuman et al. Sensor output analog processing-a microcontroller-based insect monitoring system
JP7181302B2 (en) Two-step detection method for distributed vibration