Protocol Specification for Power Controller and Chargers. Version 1.0 Scope. ------ This document specifies the format for responses for queries sent to the power-controlling unit. Communication can be serial port or network communication. Basic Operation. ---------------- Master sends query to slave. Mater is likely to a host and slave is the power-controller. In response to master queries slave responds according to this specification. Text. End-Of-Line. ------------------ Char format is 8-bit US-ASCII. Responds is terminated with EOF 1A (HEX) 26 (DEC). Max size in response is 512 chars. Details. -------- Queries ======= q0 -- API version. Version of the API must verified at start. Major and minor number In this spec version is 1.0. q1 -- Free informal data. Not specified. Can be anything in example status summary. q2 -- Operational data. printf("%-6.2f %-6.2f %-6.2f %-6.2f%-6.2f %-4.2f %-5.1f %d %d %d %-6.2f %-4.2f\n", v_bat, v_goal, v_in, a_in, t_bat, v_lvd, v_lvd_hyst, is_disconnect, is_lvd, lvd_timer, v_load, a_load); Where: v_bat - Battery Voltage. Volt. v_goal - Voltage goal for charging. Volt. v_in - Input Voltage. Volt. a_in - Input Current. Ampere t_bat - Temperature from battery sensor. Celsius. v_lvd - Voltage for "low" disconnect of load. v_lvd_hyst - Voltagediff for reconnect of load = (v_lvd + v_lvd_hyst) is_disconnect - Boolean indicating if load is administratively disconnected. is_lvd - Boolean indicating if load is disconnected due to low battery voltage. lvd_timer - Integer. Indicating the load disconnect process. v_load - Load Voltage. Volt. a_load - Load current. Ampere. q3 -- Operational battery data. printf("%-6.2f %-4.2f\n", v_bat, a_load); Where: v_bat - Battery Voltage. Volt. a_load - Load current. Ampere. q4 -- Temperature sensors. A table of temperature sensors. Holding: 1) 64 bit sensor ID. 2) Temperature in Celsius. 3) Battery temperature sensor is marked with "battery". q10 -- err Error statistics. q11 -- mcu Microcontroller Information Requests ======== r0 -- Request for delayed shutdown, 1) seconds before load disconnects 2) seconds before load disconnects (same repeated) The success and activity of request can be monitored via the q2 query via the lvd_timer. Reconnect occurs when reconnect voltage is reached Shutdown comment ================ Automatic shutdown could be implemented as follows: The host reads q2 and monitors current battery voltage (v_bat) and compares this to the threshold for low voltage disconnect (v_lvd). If battey is about to reach the disconnect voltage: 1) The host will prepare for the shutdown accoring to it's needs, stopping sevices, syncing file system etc. 2) The host initiates a controlled shutdown by sending the shutdown request r0. Pseudo code: bat_ok = TRUE while(bat_ok) { read( q2 (v_bat, v_lvd) ) if(v_bat < v_lvd + 0.1) prepare_host_shutdown() bat_ok = FALSE send( r0 ) } } /* Wait for showdown */ Date: 2010-10-21 Author: Robert Olsson