BPS - home

construct.gif (3585 bytes)

 

Battery Management System
(Project finished in 2015)

Opis
Protokol komunikacije

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. In other words, the watchdog module in microcontroller must not wake up the device during message receiving; 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. 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 (excluding control characters) 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 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.
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.

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
A00U14FA<CR> - sent from third cell, which has been enquired
AFFU14FA<CR> - sent from fourth cell
AFEU14FA<CR> - sent from fifth cell
AFDU14FA<CR> - sent from sixth cell
AFCU14FA<CR> - sent from seventh cell
AFBU14FA<CR> - sent from eighth cell
AFAU14FA<CR> - sent from ninth cell
AF9U14FA<CR> - sent from tenth cell
AF8U14FA<CR> - sent from eleventh cell
AF7U14FA<CR> - sent from twelfth cell
AF6U14FA<CR> - sent from thirteenth cell
AF5U14FA<CR> - sent from fourteenth cell
AF4U14FA<CR> - sent from fifteenth cell
AF3U14FA<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*1024/0x14F = 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

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 of the cell.
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 haven'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


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.
A01W12F400<CR> - Sets the calibration constant in the first cell (reference voltage is 1.213V).
A02W12f354<CR> - The second cell is not accepting the calibration constant due lower case f and it sends back the previously stored calibration constant.


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.
A03V128<CR> - Set the bleeding threshold voltage in the third cell. Assuming that the calibration constant is 0x12F400, the actual threshold voltage is 0x12F400/0x128 = 4.196V (LiPo cell).