$Id: README,v 1.10 2003/09/13 07:16:03 dwalters Exp $ -- Open Automaton Project: http://oap.sourceforge.net -- POWER MANAGEMENT MODULE INTRODUCTION ------------------------------------ This README covers the source code and circuit schematics for the Open Automaton Project Power Management Module. The Power Managment Module is a hardware device that controls the power source to the robot's main 12V rail (either main battery, or external), and also controls the signal to initiate battery charging. This module is also responsible for continuously monitoring the main battery voltage, and the voltage of the external power source. All communication between this module and the robot's mainboard is via the I2C interface using the SMBus protocol. The circuit schematic (power_management_module.sch) was developed in gschem, part of the gEDA package, version 20030525. Circuit schematic symbols that are not in the symbol library bundled with gEDA are included as separate sym files (these .sym files can be copied into your local symbol directory, typically /usr/local/share/gEDA/sym/local/). 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. CIRCUIT NOTES ------------- When assembling this circuit, it is essential to use heavy gauge wiring and wide circuit board tracks for all of the 12V DC and GROUND runs. This is because of the high currents drawn (up to 5 Amps). Thin wires will get hot and will cause undesirable voltage drops, not to mention that inadequate wire gauge for these kinds of currents is a potential fire hazard. OPERATION NOTES --------------- This module operates autonomously, and is not dependent on communication with the host mainboard to perform power management operations. The host interface provides supervisory functions to allow the mainboard to monitor the state of the power management module, and to set its configuration (stored in nonvolatile EEPROM). Full details of the host SMBus interface is provided in the next section. The power management module (PMM) monitors the state of three microswitches, each connected to one of the electrical contacts that mate with the Docking Station. These microswitches are closed when the robot is docked in the charging position. When the microswitch closures are sensed, the Power Management Module initiates the charging sequence as follows: 1. Instruct the Docking Station to supply the external 12V DC power supply. 2. When the external 12V supply is stable, switch the robot's main power rail from the on-board battery to the 12V external supply, leaving the battery open circuit (no load). 3. Close the circuit from the battery to the charger terminals. 4. Instruct the Docking Station to start charging the battery. The PMM sends instructions to the Docking Station via infrared, using a modified version of the Sony IR remote control protocol. The LEDs signal the following states: - LEDs off: Not charging. - Green LED on: Charging sequence active. - Red LED on: Error condition. SMBUS INTERFACE --------------- This module is a slave on the I2C SMBus, with the fixed address 86 (the address can be changed by modifying the source code and re-compiling). The device responds to the following host (master) commands: Read Byte Data, Command = 1: Report battery voltage to host, as raw 8-bit ADC bitcount (one data byte). Read Byte Data, Command = 2: Report external supply voltage to host, as raw 8-bit ADC bitcount (one data byte). Read Byte Data, Command = 3: Report charger voltage to host, as raw 8-bit ADC bitcount (one data byte). Read Byte Data, Command = 4: Report current state to host (one data byte) 0 = reset; transient state; about to enter state 1 1 = waiting for microswitches to close, 2 = waiting for good external supply, 3 = charging, 4 = error. Read byte Data, Command = 5: Report error code to host (one data byte) 1 = error waiting for good ext. supply in state 2, 2 = battery not charging in state 3. Read byte Data, Command = 6: Report state of microswitches (one data byte) bit 0 = charging voltage docking microswitch, bit 6 = external supply docking microswitch, bit 7 = ground docking microswitch. When bit is 1, microswitch is open. When bit is 0, microswitch is closed (pressed). Unused bits are 0. Read Byte Data, Command = 7: Report good external supply voltage threshold to host, as raw 8-bit ADC bitcount (one data byte). Write Byte Data, Command = 100: Set good external supply threshold voltage in raw 8-bit ADC bitcounts (one data byte). Module stores this value in nonvolatile EEPROM. PEC (Packet Error Checking) is disabled for all SMBus commands. Reading the error code (command 5) has the secondary effect of resetting the error condition, returning the PMM to state 1 (waiting for microswitches to close). CIRCUIT NOTES ------------- The IR LED is a high output device (100mA forward current at 1.2V) emitting 16mW of radiant power. 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 PIC16F819 device, type gpasm -n power_management_module.asm The resulting hex file will be called power_management_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 Power Management Module requires the following configuration bit settings: - Flash Code Protection off - CCP1 on RB3 - In-circuit Debugger disabled - Flash write enable off - EE Code Protection off - Low Voltage Programming Enable off, RB3 is I/O - Brown-out Reset Enable on - RA5/MCLR pin function is digital I/O - Power-Up Timer on - Watchdog Timer off - Oscillator: INTRC, port I/O function of RA6 and RA7 The above configuration settings are represented by the configuration word 2F50 in hexadecimal.