#REM Li-Ion Battery Management System Slave (Analogue) Module by Peter Perkins. Picaxe 08M - PIC12F683 - 120808 - www.150mpg.co.uk - V2.00 Beta. **************************** General Information ****************************** The BMS modules carry no warranty or guarantee of any kind! They are used at your own risk, and I make no claims as to their suitability for a particular function. Prospective users must evaluate the system before using it, and no liability will be entertained by myself in any shape or form whatsoever. The modules and software have been produced at low cost for the benefit of the EV & electronic community. The software is available free via the internet. Users may modify or adapt the system as they see fit. If you are not fully competent to work on potentially lethal battery systems and high voltages, then do not experiment with or use this system. Be aware that vehicle modifications can lead to invalidated insurance and warranty issues. You the end user remain fully liable for any modifications made to your vehicle. ************************* Slave Picaxe 08M Pinouts **************************** Top _____ (+ Cell Supply) +Ve -1| ^ |8- -Ve (- Cell Supply) (Program In) Rxd -2| 0 |7- Output 0 (Bypass Load Out) (Slave Data Bus Out) Output 4 -3| 8 |6- Input 1 (RefAdc In 1.235V) (Slave Data Bus In) Input 3 -4| M |5- Output 2 (Master Data Bus Out) ----- ************************ Slave Module Specification *************************** Supply/Cell Voltage 1.75 - 5.00V DC (Pic limits) Average Supply Current at 4.00v <100ua Voltage Ref LM 385 1.235V accuracy 1% Supply/Cell Voltage sensing accuracy +/- 30mv Maximum balancing/bypass current 333ma at 5.00V CPU Standard Speed 4mhz with internal resonator Permitted Working Cell Voltage Range 1.75 - 4.30V RefVADC should be 1263 but can be adjusted to compensate for variations. Note Slave Opto's are Sink driven therefore (Pic Output Low = Opto On, High = Opto Off) ***************************** Slave Clock Speeds ****************************** ********** Reducing Speed Should Save Power (Untested at present) ************ %00000000 = 31 kHz 19bps %00010000 = 125 kHz 75bps %00100000 = 250 kHz 150bps %00110000 = 500 kHz 300bps %01000000 = 1 MHz 600bps %01010000 = 2 MHz 1200bps %01100000 = 4 MHz 2400bps %01110000 = 8 MHz 4800bps Example = poke $8F,%01100000 'Set clock to 4 MHz ******************************************************************************* ********************** Program Size 74 out of 256 Bytes *********************** ******************************************************************************* #ENDREM `Variables Constants and I/O definitions `Variables 16bit symbol CellV = w0 ;w0 (b0,b1) = Cell voltage (16bit value) symbol RefADC = w1 ;w1 (b2,b3) = Raw Adc input data variable range 0-1024 10bit symbol CellA = w2 ;w2 (b4,b5) = Cell average voltage last 10 measurements `Variables 8bit symbol Counter = b13 ;b13 = General 0-255 byte ADC loop counter variable `Constants symbol RefVADC = 1270 ;Fixed Ref Voltage Calibration LM385 1.235v * 1023 = 1270 (1250-1280) symbol AbsMaxCellV = 380 ;Absolute Maximum Cell Voltage (Charger/Controller cutback point) symbol MaxCellV = 370 ;Maximum Cell Voltage (Balancing load/bypass cut in point) symbol MinCellV = 200 ;Minimum Cell Voltage 2.00v (Assist/Controller cutback point) `Pins used for I/O and designations `*** Digital high/low Inputs *** symbol Test = 3 ;Test Slave on Input 3 `*** Digital high/low Outputs *** symbol Load = 0 ;2W 15R Transistor driven load/bypass resistor on Output 0 symbol HighOpto = 2 ;HighOpto on Output 2 symbol LowOpto = 4 ;LowOpto on Output 4 `*** Analogue ADC Inputs *** symbol RefInput = 1 ;LM385 1.235V RefAdc on Input 1 `******************************************************************************* `******************************************************************************* Start: ;Main program start disablebod ;Disable Pic Chip Brown Out Detection to function at lower supply V `******************************************************************************* Main: ;Main program loop label CellA = 0 ;Set Cell Average word variable to 0 (Zero) for Counter = 1 to 10 ;10x ADC Oversampling loop counter readadc10 RefInput, RefADC ;Measure ADC voltage reference CellA = CellA + RefADC ;Add latest ADC reading to running total next Counter ;Repeat loop until 10 ADC readings obtained CellA = CellA / 10 ;Calculate average ADC reading for last 10 readings CellV = RefVADC *25 / CellA * 100 / 25 ;Calculate Cell Voltage from the average ADC reading if CellV > AbsMaxCellV then ;If Cell V > AbsMaxCellV (3.80v initial Value) then low HighOpto ;Turn on HighOpto (Warning/Charger/Controller/Regen Cutback) else high HighOpto ;Turn off HighOpto (Warning/Charger/Controller/Regen Cutback) endif if CellV > MaxCellV then ;If Cell V > MaxCellV (3.70v initial Value) then high Load ;Turn on load (and load indicator led If fitted) else low Load ;Turn off load (and load indicator led if fitted) endif if CellV < MinCellV then ;If Cell V < MinCellV (2.00 initial Value) then low LowOpto ;Turn on LowOpto (Warning/Assist/Controller Cutback) & led if fitted else high LowOpto ;Turn off LowOpto (Warning/Assist/Controller Cutback) & led if fitted endif Loop0: if pin3 = 1 then ;If pin 3 is 1 then Slave Test low LowOpto ;Turn on LowOpto and Led (All the Low V indicator Led's should light) goto Loop0 ;goto Loop0 and check pin3 again. endif goto Main ;Goto program main loop