Specifications
6.2. SOFTWARE
does not need to be fast and an RS232 standardised communication speed
of 9600bps with e ight data bits, no parity and one stop bit is used.
The link from the co-ordinator to the uplink module is in the form of
an I
2
C bus as outlined in Section 7.2.2. The reasons for this decision were
largely motivated by device flexibility and simplicity. Please see that section
for further motivation. Fortunately, the PIC 18F452 features an on-board
Master Synchronous Se rial Port (MSSP) which is I
2
C compatible.
The device is constructed on a compact printed circuit board (PCB) for
housing within the uplink module’s enclosure. Fuses were added to both rails
as a protection mechanism should one of the readers fail. Appendix B shows
the PCB layout and full circuit schematic.
6.2 Software
The purpose of this module is to collect the data from the two RFID readers
and determine the direction of animal movement through the gates.
Upon startup, the co-ordinator’s microprocessor initialises all peripherals
and resets all variables to zero. The software polls each connected RFID
reader in turn to check for transponders within range. All successful reads
(from any reader) are compared to a list of records of the tag ID and the
RFID reader where the tag was read. If no match was found in the list of
records, a new entry is generated, with a state variable set to the reader
where the tag was detected. If a match is found in the table, the stored state
member of that record is consulted to see what action is necessary. If it is a
duplicate entry, the read is ignored. Otherwise, the stored state variable is
altered to reflect the direction of the animal.
This list is constantly consulted for changes of this state variable. If it
reflects that an entry is an animal that has moved from one gate to another,
the entry is buffered in a transmission buffer which is then uploaded when
the uplink module polls the co-ordinator.
This process is achieved by cycling through the following four finite state
machines (FSMs) indefinitely:
1. Timer
58