![]()
Battery Management System
(Project finished in 2015)
Description
Communication protocol
Fast charging procedure
Central unit (prototype)
Host protocol
Setup utility program for PC
Downloads
As it was mentioned on Description page, the communication with cell modules is established through daisy chain, i.e. central unit sends commands to the first cell in the chain and receives answer from the last cell in the chain. The example below shows how it works.
The communication is asynchronous serial with following parameters: 9600,8,N,1, which means that the speed is 9600bps, data length is 8 bit, no parity used and the length of stop bit is 1.
The time delay between two consecutive characters
must be shorter than ~2 seconds, otherwise the input buffer in module will be
purged by watchdog timer. In other words, the watchdog module in microcontroller must not wake up
the device during message receiving the message; the watchdog wake up always clears input
communication buffer.
In order to reduce energy consumption, the microcontroller is kept in sleep mode
(with activated interrupt on command input pin and watchdog module) and the
module wakes up from sleep when it detects the start bit on serial input pin, or
when watchdog timer expires (~2.3sec).
The difference between these two wake ups
is that the WDT (watchdog timer) clears input buffer and the start bit detection
activates timing module on order to receive the incoming character and then the
character is stored in the buffer. If the received character is
<CR>, the module first measures the voltage of the
pin GP4, sets internal flags regarding voltage levels and then parses the
message and executes the command or transfers it further on. The
<LF> character is ignored on receive, all other
are stored in input buffer which has size of ten bytes.
If the module receives
the character other than
<CR> or
<LF> and the buffer is already full, the buffer
has been then purged due illegal length of the message.
The structure of the message is:
AaaC[hhh[hhh]]<CR>[<LF>].
The items in square brackets are optional, <CR> is ANSI carriage return (code
0x0D). The cell module ignores any <LF> (ANSI
line feed) characters in the message.
Maximum length of the message is ten characters,
if cell module receives more than ten characters, it ignores the message. In
other words, the eleventh character, other than
<CR> (or <LF>,
which is anyway ignored) will purge the receiving buffer in the
module.
The cell module sends one <LF> in front of every
message, so, this communication can be easily monitored on any terminal,
equipped with appropriate serial interface.
The first three characters are used as address identifier, where first character
A is beginning of the message (as address
identifier) and then aa is hexadecimal
presentation of the address byte (i.e. from 00 to FF).
If cell module receives the address "01", it parses the message and executes the
particular command (rest of the message). If the address is other than 0x01, the cell
module decreases the address by one and then sends the command to next cell
module.
When the cell executes the command, it responds with address "00"
and sends the answer to the next cell.
C is the command for the addressed cell and
it can be one of following characters: W,
U, V,
H or L.
Note: The rest of command is interpreted only in the cell which has been
addressed, all other cells are just passing the rest through the chain with
decremented address identifier.
Following example shows how to count the cells in
same chain:
A00@<CR> - sent from central module to
first cell
AFF@<CR> - sent from first cell to second
one (decremented 0x00 in byte mode)
AFE@<CR> - sent from second
AFD@<CR> - sent from third cell, which
has been enquired
AFC@<CR> - sent from fourth cell
AFB@<CR> - sent from fifth cell
AFA@<CR> - sent from sixth cell
AF9@<CR> - sent from seventh cell
AF8@<CR> - sent from eighth cell
AF7@<CR> - sent from ninth cell
AF6@<CR> - sent from tenth cell
AF5@<CR> - sent from eleventh cell
AF4@<CR> - sent from twelfth cell
AF3@<CR> - sent from thirteenth cell
AF2@<CR> - sent from fourteenth cell
AF1@<CR> - sent from fifteenth cell
AF0@<CR> - sent from sixteenth cell back
to the central module
The number of the cells in the chain is: 256-0xF0 = 16
The character @ has been chosen as the
identifier for count cells command, it is not interpreted by any cell in the
chain.
This addressing system allows connecting up to 256 cells in the chain.
Note: The 256th cell is addressed from central module with
A00.
The returned command from the last cell in 256 cells configuration has same
address identifier, i.e.
A00.
The following example shows enquiry of third cell
voltage in the chain of 16 cells:
A03U<CR> - sent from central module to
first cell
A02U<CR> - sent from first cell to second
one
A01U<CR> - sent from second
A00U53CA<CR> - sent from third cell,
which has been enquired
AFFU53CA<CR> - sent from fourth cell
AFEU53CA<CR> - sent from fifth cell
AFDU53CA<CR> - sent from sixth cell
AFCU53CA<CR> - sent from seventh cell
AFBU53CA<CR> - sent from eighth cell
AFAU53CA<CR> - sent from ninth cell
AF9U53CA<CR> - sent from tenth cell
AF8U53CA<CR> - sent from eleventh cell
AF7U53CA<CR> - sent from twelfth cell
AF6U53CA<CR> - sent from thirteenth cell
AF5U53CA<CR> - sent from fourteenth cell
AF4U53CA<CR> - sent from fifteenth cell
AF3U53CA<CR> - sent from sixteenth cell
back to the central module
Assuming that the reference voltage in the cell module is 1.2V, the voltage of
the third cell is 1.2V*4096/0x53C = 3.668V.
The status of the cell is
0xA - the cell has activated bleeding since
last poll (see following paragraph).
The address of originator is ncells+256-address = 16+0xF8-256 = 3
Messages Description
Note: <LF> character is always ignored (and thus it can be inserted anywhere, even in middle of the command), it is omitted in message descriptions, although cell modules always send it as begin of every message.
AaaU<CR> - enquiry voltage of the cell, the cell answers A00Uyyys<CR>, where yyy is three digit HEX code of the measured reference voltage on the cell and s is status nibble of the cell in hex format.
Note: Actual voltage of the cell is calibration constant of the cell divided with this three digit hex number, expressed in milivolts.
The status of the cell has four bits information:
bit 0 - the cell has or had activated low voltage threshold since last poll
bit 1 - the cell has or had activated bleeding since last poll
bit 2 - the cell has or had activated high voltage threshold since last poll
bit 3 - the bleeding has been enabled.
These four bits are shown in HEX format, see
following examples:
8 - the cell had the voltage within limits
since last poll and hasn't activated bleeding
9 - the cell has (or had since last poll)
reached low level voltage alarm
A - the cell has (or had since last poll)
activated bleeding
E - the cell has (or had since last poll)
activated high voltage alarm as well as activated bleeding
There are four more possible combinations:
B - the cell was bleeding since last poll as
well as it had reached low voltage alarm, possible the cell is in bad condition
or the parameters were not set correctly.
C - the cell had reached high level alarm, but
it was not bleeding - the parameters are not set correctly
D - the cell had reached high level alarm and
low level alarm, but was not bleeding since last poll - the parameters are not
set correctly.
F - the cell had activated all three events
since last poll - the parameters are not set correctly and possible the cell is
bad
Any of those four conditions on any of the cells indicates the problem with the
cell(s), wiring or parameters.
Note: It can be caused with healthy cell too; if the module was not polled during whole cycle (discharge/charge) all flags can be triggered even with healthy cell.
AaaW[yyyyyy]<CR> - enquiry or set calibration constant
of the cell, the cell answers with A00Wyyyyyy<CR>,
where yyyyyy is six digit HEX code of calibration constant, stored in cell
module. The new constant will not be programmed in cell module if not received
all six HEX digits and will accept the message as enquiry of the calibration
constant.
NB The HEX digits A to F must be written in upper case,
otherwise will not be accepted as HEX code.
Examples:
A07W<CR>
- Enquiry seventh cell in the chain for the calibration constant.
A01W4BD000<CR>
- Sets the calibration constant in the first cell (reference voltage is 1.213V).
A02W43f354<CR>
- The second cell is not accepting the calibration constant due lower case f
and it sends back the previously stored calibration constant.
Note: The default value of calibration constant is 0x800000, which represents 2.048V reference voltage.
Tip: Calibrating the cell module is very
simple:
- Connect the cell module to power supply which gives highest predicted cell
voltage (must be below 5.5V).
- Enquiry cell voltage with command AaaU<CR>.
- Multiply measured cell module voltage expressed in milivolts with received
result and store it to module with described command.
Reminder: The result must be stored in proper hex format.
Example:
The module has been powered by precise 5V supply
and given result is 0x689:
0x689 * 5000 = 0x7FA3C8. The cell should then receive calibration command
A01W7FA3C8<CR>.
AaaV[yyy]<CR> - enquiry or set the bleeding threshold voltage in the cell. The actual bleeding voltage is the calibration constant divided by this three digit hex number, expressed in milivolts. The optional three hex digit argument must be entered in upper case (as for calibration constant) and all three digits must be present, otherwise, the command will be interpreted as enquiry for bleeding threshold voltage.
Examples:
A02V<CR>
- Enquiry second cell for bleeding threshold voltage. The cell module sends back
the threshold voltage in same format as command used for setting it, see below.
A03V4A0<CR>
- Set the bleeding threshold voltage in the third cell. Assuming that the
calibration constant is 0x4BD000, the actual threshold voltage is 0x4BD000/0x4A0
= 4.196V (LiPo cell).
AaaL[yyy]<CR> - enquiry or set the low alarm voltage in the cell. The Low alarm voltage is the calibration constant divided by this three digit hex number, expressed in miliVolts. The optional three hex digit argument must be entered in upper case (as for calibration constant) and all three digits must be present, otherwise, the command will be interpreted as enquiry for low alarm voltage.
Examples:
A02L<CR>
- Enquiry second cell for Low alarm voltage. The cell module sends back the low
alarm voltage in same format as command used for setting it, see below.
A03L5E0<CR>
- Set the Low alarm voltage in the third cell. Assuming that the
calibration constant is 0x4BD000, the low alarm voltage is 0x4BD000/0x5E0
= 3.303V (LiPo cell).
AaaH[yyy]<CR> - enquiry or set the low alarm voltage in the cell. The Low alarm voltage is the calibration constant divided by this three digit hex number, expressed in miliVolts. The optional three hex digit argument must be entered in upper case (as for calibration constant) and all three digits must be present, otherwise, the command will be interpreted as enquiry for low alarm voltage.
Examples:
A02H<CR>
- Enquiry second cell for high alarm voltage. The cell module sends back the
high alarm voltage in same format as command used for setting it, see below.
A03H49C<CR>
- Set the high alarm voltage in the third cell. Assuming that the
calibration constant is 0x4BD000, the high alarm voltage is 0x4BD000/0x49C= 4.211V (LiPo cell).
The cell can process any command in less than
20ms time, but total time delay for receiving the answer from the battery (to
central module) depends on number of the cells in the daisy chain. It is obvious
that the central module in large battery packs must send enquiries or commands
without waiting for the answer (pipeline) as, for example in 256 cells battery
pack (largest configuration), the time delay can be 256* 20ms = 0.512s and thus
it should take over two minutes to read all 256 cells voltage if waiting for
response after every command sent.
If the commands are sent without waiting for answer (with proper delay between
commands in order to allow cell modules to process them), the total time will be
even less than one second.
The polling of the voltage during discharging the cells is not necessary to be fast as there's special command for collecting general status of the battery, see command Sxy<CR> below.
The fast charging procedure is explained in separate paragraph.
Special commands without address field
Sxy<CR>
- Enquiry common status of the battery, where x
and y are status flags in same format as the
s status in cell response on command A00U<CR>,
only difference that this status is stored in the cell in separate
memory.
In other words, this status is not reset by command A00U<CR>.
x
nibble represents combined status of all cells with or function, i.e. it
shows triggered events of any cells (LVC, HVC or bleed) since last
Sxy<CR>
command.
y nibble represents combined status of all
cells with and function, i.e. it shows triggered events of all
cells (LVC, HVC or bleed) since last Sxy<CR>
command.
It is obvious than central module should always sends initial command S0F<CR>,
Note: This command has been implemented in order to simplify and speed up collecting status of the battery, e.g. as it is needed for fast charging procedure.
Reminder: Here're explained four bits from status nibbles
x and y:
bit 0 - the cell has or had activated low voltage threshold since last poll
bit 1 - the cell has or had activated bleeding since last poll
bit 2 - the cell has or had activated high voltage threshold since last poll
bit 3 - the bleeding has been enabled.
Examples:
S0F<CR>
- Sent by central module, illegal response from cell modules.
S80<CR>
- Some cells have disabled bleeding, it is necessary to send command
e<CR> in order to enable balancer in every cell module in the
battery.
S88<CR> - Normal situation: no cell is
bleeding, no alarms activated.
S98<CR> - At least one cell had activated LVC
alarm - reduce load.
SA8<CR> - At least one cell has activated
bleeding, i.e. has reached bleeding voltage threshold.
SC8<CR> - At least one cell has reached HVC
threshold, but not bleeding - check HVC and bleeding thersholds in the battery.
SE8<CR> - At least one cell has reached HVC -
reduce charging voltage/current.
SAA<CR> - All cells are bleeding, no HVC
detected - successful charging, reduce current/voltage as described in
fast charging procedure.
Note: It is obvious that x
AND y = x, as
well as x
OR y = y; if
not so, there was error in the communication.
NB If both (HVC and LVC) flags are set, there is hardware problem inside
battery (one or more cells are faulty).
e<CR> - Enable bleeding (default) in whole chain. Cell module passes this command on after setting internal flags, used in commands AxxU<CR> and Sxy<CR>.
d<CR> - Disable bleeding (default) in whole chain. Cell module passes this command on after setting internal flags, used in commands AxxU<CR> and Sxy<CR>.
These two commands are used for maintenance or service, under normal situation it is never needed to use them.
Note: The bleeding activated flag is not affected by
d<CR>
command.
Bleeding flags are triggered regardless the bleeding enabled flag,
d<CR>
command only disables output pin, used for bleeding.