Old BMS Software Thread

Threads relating to the BMS system begun by Peter Perkins

Moderators: GregsGarage, retepsnikrep

GregsGarage
Posts: 870
Joined: Tue Apr 01, 2008 5:27 pm
Location: Galashiels, Scottish Borders
Contact:

Re: Old BMS Software Thread

Postby GregsGarage » Mon Jan 30, 2012 2:57 pm

Great link. It seems to me that we are already doing most of what he is suggesting. That is we average 10 samples of the ADC which seems to be what he is doing, only he's doing it 16 times for 12bit resolution.

A couple of thoughts. Since we transmit cell voltage as 1 byte (8 bits) of data for each cell, how would we utilize the extra resolution?

The higher resoultion takes more time. Since the slaves have to measure one after the other, even though you could get higher accuracy for each individual cell, the greater time could mean you get more variation between cell readings as pack voltage changes under normal driving conditions. It's a balancing act with the present system between keeping the time for the slave loop as short as possible so that you get a indication of cell voltages at a specific load and increasing the slave loop time to get more accurate individual cell reading, but maybe not under the same load conditions.

A good application of this would be if we went to a bidirectional parallel bus like the EVILbus I have mentioned in other posts (or maybe CAN). You could then broadcast a cell read command to all the slaves which would all take their measurements at the same time and then transmit their results in turn back to the master. This then solves the problem of the slave loop time and also opens up the possibilty of transmiting several bytes of data from each cell back to the master provided the baud ratge is high enough.

On a slightly related note I have been asked to fit some Rudman Regulators to a EV. These actually use an implementaion of the EVILbus so I will be taking notes, pics, etc. Issac's problems with his optos has shown that some improvements can be made to the existing design, so I want to see if I can get the latest version of slaves that we are working on, in my vehicle with one board mounted behind my front bumper and another at the back of the car. At the moment I've had to move the front slave inside the passenger compartment to overcome interference.
Greg Fordyce

Daewoo Matiz
http://www.evalbum.com/4191

isaac_alaska1
Posts: 100
Joined: Sun Apr 03, 2011 7:41 pm

Re: Old BMS Software Thread

Postby isaac_alaska1 » Fri Feb 24, 2012 10:11 am

good news! we took the machine out today and had very few problems. the speed sensor was giving us totally random results (usually less than 1 mph when i was doing 20 according to a radar sign) but i'm about 99% sure this was EMI related, since the vss leads travel literally all the way over the top of the battery pack (and perpendicular to both the positive and negative pack bus) through unshielded, non-twisted wires. we are also using a pretty weak pull up resistor (10k) on the speed sensor. the sensor pulls the signal line low twice per revolution. there was also a pretty big gap (about 1/4 inch) between the sensor and the magnetic disk. to fix the problem i twisted the signal and ground together, shielded all three wires (signal, ground, and 5v supply to the sensor) with aluminum foil, grounded the shield at the sensor, and reduced the gap between the sensor and disk to less than 1/8th inch. hope to test it again tomorrow and see if this fixed the problem. I haven't changed the pull-up resistor but it was working with no load on the motor so i'll try it first without changing it.

we've fixed almost all issues with using the new pic (pic18f2680) except for the opto outputs. for some reason with the new pic, instead of toggling the charge enable, charge cutback, or controller cutback optos, it only pulses them. (for a very brief period of time, the led is lit for such a short period of time you can't see it with the lights in the room on)

any ideas what might be causing this?

i used the charge enable transistor to drive a small relay that varies the control voltage that our charger sees. the charger uses this control voltage to regulate current output, from zero to 100% of max output. it works with the original code on the old pic, but like i mentioned, the output on the new pic only pulses rather than stay toggled.

User avatar
retepsnikrep
Posts: 1387
Joined: Sat May 26, 2007 4:50 pm
Location: North Yorkshire England
Contact:

Re: Old BMS Software Thread

Postby retepsnikrep » Fri Feb 24, 2012 10:24 am

Post you complete code so i can look at it please.

Good effort on the vehicle. glad it's working so far.

Change that pull up as well any interference that gets in will affect the whole system not just the one function.
Regards Peter

Two MK1 Honda Insight's. One running 20ah A123 Lithium pack. One 8ah BetterBattery Nimh pack.
One HCH1 Civic Hybrid running 60ah A123 Lithium pack.

isaac_alaska1
Posts: 100
Joined: Sun Apr 03, 2011 7:41 pm

Re: Old BMS Software Thread

Postby isaac_alaska1 » Fri Feb 24, 2012 7:14 pm

This is the code we are using. the display looks really nice with it now. just gotta figure out how to make the opto outputs stay toggled.

edit*

oops i forgot to actually stick the link in here. here it is

https://rapidshare.com/files/2288336884 ... 8F2680.pbp

User avatar
retepsnikrep
Posts: 1387
Joined: Sat May 26, 2007 4:50 pm
Location: North Yorkshire England
Contact:

Re: Old BMS Software Thread

Postby retepsnikrep » Fri Feb 24, 2012 8:58 pm

I can't download that link please change the extension to txt and attach it here to your post thanks.

OK I managed to get it but please post code directly on here attached to posts.

I'm not much help I could not see anything obvious. I suggest you add some code to watch your charger control variables by displaying them at various point where you think you should know the value and compare that with the actual.
Regards Peter

Two MK1 Honda Insight's. One running 20ah A123 Lithium pack. One 8ah BetterBattery Nimh pack.
One HCH1 Civic Hybrid running 60ah A123 Lithium pack.

isaac_alaska1
Posts: 100
Joined: Sun Apr 03, 2011 7:41 pm

Re: Old BMS Software Thread

Postby isaac_alaska1 » Sun Feb 26, 2012 8:40 am

Here's the latest, i guess this video doesn't have a whole lot to show about the BMS but it does show the vehicle a bit. And without the bms, the vehicle wouldn't be possible!
now i just need a charger than can charge more than 5 amps....might be time to collect up some server power supplies.

http://www.youtube.com/watch?v=0CL2DYab ... e=youtu.be

isaac_alaska1
Posts: 100
Joined: Sun Apr 03, 2011 7:41 pm

Re: Old BMS Software Thread

Postby isaac_alaska1 » Mon Feb 27, 2012 4:54 am

back again ;)

my load cut-in doesn't seem to be working. i've set the cutin voltage to 4.1 in the master and slave software, as shown below. The there's several cells at 4.12 volts, but the load leds are not coming on. i tried sending command 5 three times, but that didn't engage any of the loads either. sending command seven flashes each led, so i know the circuitry is wired correctly.

any ideas?

right now my charger won't charge higher than 196 volts on the pack, but if i could balance everything out (even at a lower level) then i could probably make the charger kick in and bring them up all together.

master software section:

Code: Select all

MaxPackV    con 20160    'Maximum pack voltage = 201.6  48 Cells (20,160 as 16 bit value) Res 10mv (Max 650v)(added by isaac)

MinPackV   con 0       'Minimum pack voltage = 0v  (0 as 16 bit value) Res 10mv
AbsMaxCellV   con 420      'Abs Maximum permitted cell voltage = (3.66V) (Alarm & Shutdown point)(isaac changed to 420)
AbsMinCellV   con 300      'Abs Minimum permitted cell voltage = (2.30V) (Alarm & Shutdown point)(isaac changed to 300)
MaxCellV   con 410      'Normal Maximum permitted cell voltage = (3.60V) (Charger/Regen cutback point)(isaac changed to 410)
MinCellV   con 350      'Normal Minimum permitted cell voltage = (2.40V) (Controller/Assist cutback point)(isaac changed to 350)
CutInVD      con 410      'Balancing load/bypass default cut in Voltage  (Must match value set in Slaves)(isaac changed to 410)
'MaxTemp      con 40      'Maximum permitted pack temperature = (40C) (Alarm & Shutdown point)(isaac changed back to 40)
MaxTemp     con 140  ' deg Far
MinTemp     con 120  ' deg Far
SocMax      con 1000   'Max cell capacity = 100% (1000 as 16 bit value)
SocMin      con 100      'Min cell capacity = 10% (100 as 16 bit value)
SocUnit      con 162         'SocUnit constant for Soc calculations. (For 20ah cells = 72) Test Value 62
DiscardLow   con 175      'Cell correction value 175 or 1.75V added to CellV to recreate correct V
TimeOut      con 100      'Serial Data Receive Timeout value 100ms
VoltageDrop   con 500      'Voltage Drop = 500 Pack must drop (5V) when charging before charger cuts off
FailSafeV   con 370      'Fail Safe Minimum Load voltage Cut off (<3.35V) Cell resting voltage (isaac changed to 370)
AT24C512B   con %10100000   'Control byte for AT24C512B eeprom %1010ddd0 (ddd) = device select bits
AlarmActivate   con 3      'Number of consecutive times Alarm must occur before Alarm activates
TempSensors    con 2           'Number of I2C temp sensors installed(isaac changed back to 2)
BalanceLoop    con 4           'Number of 1S loops for each Get Voltage acquisition when charging (Includes Acq)



slave software section:

Code: Select all

RefVADC     con 63200         'Fixed Ref Voltage Calibration LM385 1.235v * 1023 * 100 / 2 = 63200
DLow     con 175         'Cell correction value 175 (1.75V) subtracted from CellVoltage
DHigh     con 430         'Cell correction value 430 (4.30V) (If Cell V>430 or <175 then error)
CutInVD     con 410         'Balancing load/bypass default cut in Voltage  (Must match value set in Master)(isaac)
FailLowDef con 360         'Default Fail Safe Minimum Load voltage Cut off (3.35V)(Isaac)
FailHighDef con 420         'Default Fail Safe Maximum Load voltage Cut in (3.85V)(Isaac)

User avatar
retepsnikrep
Posts: 1387
Joined: Sat May 26, 2007 4:50 pm
Location: North Yorkshire England
Contact:

Re: Old BMS Software Thread

Postby retepsnikrep » Mon Feb 27, 2012 7:34 am

Change the Loadcut in V to 4.00 volts using the commands function for the slaves and by changing the variable/constants in the master, does it work then? The BMS voltage resolution is only about +/-25mv so bear that in mind.

Also note depending on your wire gauge to the cells if the voltage drop when the loads turns on takes the slave below the fail safe cut off in the slaves then it will turn off straight away.

Add a line of code so you can see what commands the master is sending on screen as it runs. Then you can see if it's the master not sending the correct command when V > X or the slave is not responding.
Regards Peter

Two MK1 Honda Insight's. One running 20ah A123 Lithium pack. One 8ah BetterBattery Nimh pack.
One HCH1 Civic Hybrid running 60ah A123 Lithium pack.

isaac_alaska1
Posts: 100
Joined: Sun Apr 03, 2011 7:41 pm

Re: Old BMS Software Thread

Postby isaac_alaska1 » Mon Feb 27, 2012 8:07 am

Here's the software i'm running, the load commands don't seem to be working like i expect them to. it works with the old pic, but i can't figure out why it's not working with the new pic. with the original pic, i can send command five to decrease cut in voltage, and then send command three to turn on loads as required. this turns on the loads on all of the high cells. i don't see why the command wouldn't work on the new pic though.

thanks for looking!

-isaac
Attachments
pic18F2620 master code.rar
The new code that runs on pic18f2620
(19.09 KiB) Downloaded 992 times
SLAVE_V11_20122011_pbp3.rar
The slave software i'm using
(4.34 KiB) Downloaded 990 times
master_isaac_Farenheit_pic16f886.rar
The older master software (for the original pic)
(18.19 KiB) Downloaded 995 times

User avatar
retepsnikrep
Posts: 1387
Joined: Sat May 26, 2007 4:50 pm
Location: North Yorkshire England
Contact:

Re: Old BMS Software Thread

Postby retepsnikrep » Mon Feb 27, 2012 7:07 pm

I strongly suspect if the old master code worked then the problem is with your new master code not the slaves.

What chip RU using exactly? 18F2620?

Looking at your new master code I suspect the below section is all to cock.

You need to read the data sheet very carefully and address each of these things in turn setting the registers as reqd. You will certainly need to sort out the comparator section, and adc sections as that will play havoc with the inputs/outputs.

Where did the intcon stuff come from and the LATB etc?

Code: Select all


   Define OSC 8         'Set PicBasic Pro processor speed to 8 Mhz (Must match oscillator value) 
   OSCCON = %01110101       'Internal 8 mhz Osc and stable

'   CM1CON0 = 0          'Comparator Off
'   CM2CON0 = 0          'Comparator Off

    INTCON  = %00000000
    INTCON2 = %10000000
    INTCON3 = %00000000

    LATB = 0

   T1CON = %00110001             'Enables and Starts Timer1 prescale 1:8 internal clock source 262ms at 8mhz
   
   TRISA = %11111111       'SET PORTA AS INPUTS
   TRISB = %00000000       'SET PORTB AS OUTPUTS
   TRISC = %10011111       'SET PORTC AS INPUTS EXCEPT PORTS C5,C6
   
   
   
'   ANSEL = %00001111      'SET INPUTS AN0-AN3 AS ANALOG INPUTS
'   ANSELH = %00000000              'Disable PortB AD
   
   ADCON0 = %01000001      'SETUP ADC CONVERTER MODULE FOSC/8 & ENABLE ADC MODULE on AD0
   ADCON1 = %10001011      'SETUP ADC RIGHT JUSTIFY SET REFV to VDD & VSS
   ADCON2 = %10000001


As an example here is a section from a different program using the same chip which I use that works OK for me.
You will need to adjust each parameter to suit the Master schematic/layout I/O etc.

Code: Select all

'18F2620

DEFINE OSC 8         'Set PicBasic Pro processor speed to 8 Mhz (Must change this if run at 32mhz mode) 
OSCCON = %01110110       'Internal 8 mhz Osc and stable

CMCON  = %00000111      'Comparators Off
CVRCON = %00000000      'CvRef Powered Down

CCP1CON= %00001100      'CCP1 Module PWM Mode
CCP2CON= %00000000      'CCP2 Module Disabled

HLVDCON= %00000000      'HLVCON Disabled

T1CON  = %00110000      '$30 = Prescaler 1:8, TMR1 OFF
   
TRISA = %00001011       'SET PORTA0, A1 & A3 AS INPUTS, REST AS OUTPUTS
TRISB = %00000000       'SET PORTB AS OUTPUTS
TRISC = %10010000       'SET PORTC AS OUTPUTS EXCEPT PORT C4 & C7
   
ADCON0 = %00000001      'SETUP ADC & ENABLE ADC MODULE on AN0
ADCON1 = %00001110      'SETUP ADC SET REFV to VDD & VSS AN0
ADCON2 = %00100010      'SETUP ADC FOSC/32 LEFT JUSTIFY TAD 8


For a start note the difference in the OSCON register between mine and yours.
Regards Peter

Two MK1 Honda Insight's. One running 20ah A123 Lithium pack. One 8ah BetterBattery Nimh pack.
One HCH1 Civic Hybrid running 60ah A123 Lithium pack.


Return to “BMS thread”

Who is online

Users browsing this forum: No registered users and 16 guests