$Id: README,v 1.8 2003/09/30 23:34:36 dwalters Exp $ -- Open Automaton Project: http://oap.sourceforge.net -- SONAR ARRAY MODULE INTRODUCTION ------------------------------- This README covers the source code and circuit schematics for the Open Automaton Project Sonar Array Module. The Sonar Array Module is a hardware device that manages the scanning of range measurements from an array of SRF04 sonar sensors around the robot, passing range and configuration data to and from the robot's mainboard via the I2C interface. This module can monitor up to 16 sonar sensors. The circuit schematic (sonar_array_module.sch) was developed in gschem, part of the gEDA package, version 20030525. LICENSING --------- All source code and electronic circuit designs are copyright (C) 2003, Dafydd Walters. The Open Automaton Project software is distributed under the terms of the GNU General Public License. See the file COPYING.SOFTWARE for details. Please see the file COPYING.ELECTRONICS to see the terms under which the electronic circuit designs of the Open Automaton Project are distributed. OPERATION NOTES --------------- This module can drive up to 16 SRF04 sensors, but the number of sensors set by host command 100 (see SMBus interface descritption below), MUST be an EVEN NUMBER between 2 and 16, even if there are an odd number of sensors actually in use. This restriction is necessary because of the way the module alternates between sonar sensors that drive the two capture inputs (CCP1 and CCP2) of the PICmicro at 25ms intervals. Note that this restriction is not currently enforced in the firmware, but if the host does not adhere to it when setting the number of sensors with command 100, the resulting echo readings will be unpredictable. Example: Let's say you actually have 3 sonar sensors. These should be hooked up to channels 1 through 3, and the host should set the number of sensors to 4. When the host reads the sensors, commands 1 through 3 will return true sonar echo return times, and command 4 will always return a zero echo return time. SMBUS INTERFACE --------------- This module is a slave on the I2C SMBus, with the fixed address 87 (the address can be changed by modifying the source code and re-compiling). The device responds to the following host (master) commands: Block Read, Command = 1 to 16: Report the latest sonar reading and timer count for a given channel. 3 data bytes are transferred. The first two are the 16-bit sonar ping return time in microseconds, and the third byte is the 8-bit timer tick count at the time that sonar reading was taken. The sonar readings are sent low data byte first. The timer tick count is in multiples of 25 milliseconds. Since it is an 8-bit value, it wraps around every 6.4 seconds. If the sonar power is off, zero readings are returned for both distance and timer count. Zero readings for distance only are returned when no sonar echo was detected at all for the channel. Read Byte Data, Command = 17: Read the number of sonars (set by command 100). One data byte returned, an even number in the range 2 to 16. Read Byte Data, Command = 18: Read power state. 0 = sonars powered down, 1 = sonars powered up. Commands 102 and 103 set this value. The sonar array is powered down after reset. Write Byte Data, Command = 100: Set number of sonars (one data byte). This has to be an EVEN NUMBER between 2 and 16. Module stores this value in nonvolatile EEPROM. Send Byte, Command = 101: Zero the 8-bit timer counter. No data bytes. Send Byte, Command = 102: Power up the sonar array. Send Byte, Command = 103: Power down the sonar array (low power mode). This is useful to conserve battery life when the robot is not moving. This is the default state when the Sonar Array Module is reset. PEC (Packet Error Checking) is disabled for all SMBus commands. FIRMWARE NOTES -------------- The software for the PICMicro is written in assembly language, and compiles using the GNU PIC Assembler, gpasm. To compile the source code into a hex file suitable for programming a PIC16F876 device, type gpasm -n sonar_array_module.asm The resulting hex file will be called sonar_array_module.hex The -n option puts DOS-style CR-LF newline sequences in the .hex file, required by most device programmers. It also compiles with the MPASM compiler for Microsoft Windows that is a part of the MPLAB suite from Microchip. However, you must make sure the assembly (.asm) file is in Windows/DOS format (i.e. with CR-LF sequences at the end of each line) before it will successfully compile in MPASM for Windows. Some device programmers require the configuration bits to be set manually. It is very important that these are set correctly. The Sonar Array Module requires the following configuration bit settings: - Flash program memory code protection: Off - In-circuit debugger mode: disabled (RB6 and RB7 are I/O) - Flash program memory write enable: Off - Data EE memory code protection: Off - Low voltage programming: Off (RB3 is I/O) - Brown-out reset enable bit: Enabled - Power-up timer enabled: On - Watchdog timer: Off - Oscillator: XT (crystal) The above configuration settings are represented by the configuration word 3D71 in hexadecimal.