retepsnikrep wrote:Mindaugas.
Nice to see your input on the thread thanks. I'll have a look at your formula and see how it works out...
Peter,
I'll go through your questions one by one.
I'm not using floating point maths.
The best estimated resolution is 20mV. This is just because my formula looses just one bit during calculation while yours looses 2. The reduced formulas for working with integers would be:
Yours: CellV = 31750 / CellA * 4
Mine: CellV = 63500 / CellA * 2
I am using generic PIC12F683 and software written just in assembler.
The VSM file is here
http://www.sklandymas.lt/EV/BatteryModule_v2.DSN
The main daisy-chain serial comm concept is simulated by VSM in this test schematic
http://www.sklandymas.lt/EV/BMS_Test4.DSN
I haven't built actual device yet and used the software compilation and debugging with PIC Simulator IDE from
http://www.oshonsoft.com/
It works on it performing serial comms and ADC measurements.
I've put nearly finished .asm code here
http://www.sklandymas.lt/EV/BatteryModule.asm
It does not do ADC 8 times oversampling and does not have the master reset routine implemented yet.
1) A very valid point. I had these pulldown resistor originally in but removed trying to simplify the schematic which is using just one wire to connect all the modules. I'll make final decision once I've built and tested working prototypes.
2) I'm using separate LED which is on when shunt is enabled and blinks when MCU sends data to serial out. Might put additional LED but now trying to get components count to minimum.
3) Again valid point regarding Ref current drain. I'll redo the calculations and put an optimal resistor value.
4) The pin choice exercise was done very carefully. Every pin number function was chosen with well grounded reason according to guidelines:
a) Comparator in and out pins used as serial in and out
b) ICSP programming should be possible without any jumpers needed
5) Actually No. The master is able to communicate to each chip directly while other chips are working just as simple serial line repeaters. This is done by using PIC's internal comparator. PIC works in two basic modes:
a) Transparent Receive mode. Comparator works in mode 011 which transparently passes inverted input signal out while software waits for comparator interrupt and and reads COUT while receiving
b) Transmit mode. Comparator works in mode 100 where COUT pin is general I/O pin and is used by software to send data byte. Please note that in this mode chip is able to receive data but it is not passed transparently to transmit
The communication protocol has several commands types according to which the chips communicate:
A. Read Battery / Balancing voltages from all cells. (hex commands 81 or 82 ) Master sends the command and all chips receive it knowing that chain voltages transmission will follow. The chip with ID=1 temporarily goes to transmit mode and sends two bytes: his ID and voltage (for example 01 54). Then it goes back to transparent receive mode. Next chip in chain has ID 2 and listens to transmission. When it receives that chip 1 has transmitted its value it would know "I'm next because I'm number 2" and transmits it's voltage value in the same fashion. And this goes on through the chain until last battery chip has transmitted its value. So for example master sends hex 81 and then receives 81 01 54 02 60 03 58 04 58 ... and so on. 81 is echo that went through all cells when transmitting the command. 54 60 58 58 are shifted voltage values from cells 1,2,3,4 and so on.
B. Read Battery / Balancing voltages from cell N ( hex commands A1 or A2 ). Master sends the command followed by chip ID it addresses. All chips receive it. All chips ignore this command except the chip that has the ID equal to the second byte of the command. It temporarily goes to transmit mode and transmits its ID and voltage. So for example master sends A1 03 to read cell 3 voltage. Then it receives A1 03 03 58 where 58 is the desired voltage response from cell 3.
C. Write balancing voltage commands ( hex commands C2 or E2 ). Slaves just receive the command in transparent mode and store the balancing voltage value if the command was addressed to them.
D. Enumerate cells and store their IDs (hex command C8 ). When receiving this command all slaves go to Transmit mode and wait to receive for ID assigned to them. Master sends 01 to lowest cell directly telling it "you are number 1". The chip receives it, stores it's ID in EEPROM, increments by 1 (which makes it 2 for next cell), sends to next upper cell and goes back to transparent receive mode. In this way all the cells enumerate automatically, store their IDs and report the number of cells back to the master.