Old BMS Software Thread

Threads relating to the BMS system begun by Peter Perkins

Moderators: GregsGarage, retepsnikrep

jackbauer
Posts: 19
Joined: Wed Jan 26, 2011 8:38 pm
Location: Ireland
Contact:

Re: Old BMS Software Thread

Postby jackbauer » Fri Apr 08, 2011 8:49 pm

Martin , the lem hass 300 that i used requires a pull up resistor of i think 10k from 5v to the o/p.

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

Bug in slave software

Postby GregsGarage » Tue Apr 26, 2011 7:57 pm

I have been working on a noise problem on the master bus with my car and think I have found the cause. What was happening is that as soon as the controller started spinning the motor, even slowly in neutral, all the cell data would go. Looking at the master bus on the scope and it looked like one or more optos were conducting continuously. But with further investigations it looks like what is happening is that some noise is being read as commands on the slave bus. Looking at the software, if a slave recieves a command other than 1 - 13, it will run through the loop and send VDATA on the master bus and COMMAND on the slave bus. So the effect is any noise that a slave sees as a command gets retransmited to the rest of the slaves and also the master bus gets overwhellmed by lots of slaves all talking at the same time. The curious thing is that even with all this noise I am getting, I can still get a command 7 transmitted through all the slaves. So the solution should be simple.

Code: Select all

   if CellV > FailHigh then    'FailHigh voltage check if CellV > 3.85v then load is turned on.

   high Load         'Turn on bypass resistor and bypass led

   endif      



ReadSlave: '***NEW CODE***

   SERIN2 SlaveBusIn, 16468, 5000, TimeOut, [Command]   'Receive Command Byte on Slave Data Bus   Timeout 5s

'   9600** Inverted No Parity 16468 Idle Low

If (Command < 1) Or (Command > 13) Then ReadSlave '***NEW CODE***
'*******************************************************************************   



Incomming:            'Incomming Command

       

   if Command = 1 then       'If command = 1 then send voltage data on Master Bus

   CellS = CellV         'Store CellV in CellS for use with Command 3

   if CellV >DHigh or CellV <DLow then   'If V >4.30V or V <1.75V set out of range    

   VData = 0         'Set VData = 0 Cell error out of Voltage range condition

   else

   CellV = CellV - DLow      'Convert Word (CellV) data into Byte (VData) for output

   endif     

   endif


As you can see from the code snippet above I have added 2 lines of code, a Label (ReadSlave:) and a If .. Then statement that checks that COMMAND has a value from 1 to 13. If not it goes back to SERIN2 and waits again for a valid COMMAND. Please check for errors, I will hopefully test this tomorrow and post a fully complied SLAVE_V09 if it works o.k.
Greg Fordyce

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

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 » Tue Apr 26, 2011 9:27 pm

I hope it cures it :wink: I assume the problem/noise is in the connection from the master to the first slave only. ? You could use the double opto trick on that as well to start with. Extra opto right next to the input into first slave. Do you have all the slave boards together?
You might have to move them together :?

I also suggest increase the serial timeout to 10s as well, this will give longer end charge balancing time if reqd. Or add another command to change the timeout at will. But this would require a bit more code and adding of extra commands to the Master sorftware.
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.

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

Re: Old BMS Software Thread

Postby GregsGarage » Tue Apr 26, 2011 10:20 pm

Actually the problem seems to be after the first slave pcb. I think the long wire from the first to the second pcb might be where the problem is. Peter, I am having problems compiling it, if you have time could you add those 2 lines and compile it for me, thanks.

By the way, I am using the current loop for the master, looks promising but have to get this noise problem sorted out first.
Greg Fordyce

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

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 » Wed Apr 27, 2011 7:21 am

OK here is the new slave code.

I changed the timeout to 10s for the slave serial data in command.

I modiifed the change slightly to send the code back to the label Main: if data outside acceptable range was recd, otherwise it would sit in the serial loop and be unable to do the failsafe checks.

One thought, if you have such a lot of interfernece on that link from slave board 1 to 2 then even if slave 1 is trying to send the correct data it may still be swamped. The new code will remove illegal codes but the interference could still generate codes in the range 1 to 13 by chance. If slave board two recieves legal codes but not ones sent by you then that could seriously skew the BMS. If for instance it gets a load of command 5's then it could force the load cut in voltage down to a very low level!!!

Please use the reset to default commands 6 & 13 once you have it working to ensure slaves are all on a level playing field before making any other adjustments.
Attachments
SLAVE_V10_270411_MPASM.zip
(6 KiB) Downloaded 220 times
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.

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

Re: Old BMS Software Thread

Postby GregsGarage » Wed Apr 27, 2011 9:13 am

Thanks Peter, I will give it a try. The way I found the problem was by scoping the slave alive pin. I noticed that the program loop rate increased when I lost the master bus, but curiously the slaves where all still working. That is I could send command 7 through all the noise. My conclusions is that the slaves were receiving false data, but this was having no effect on any real commands being sent. Looks like the slave received a false command, causing it to loop through and send data as it supposed to at the end of the loop. Problem is this means that any false commands get sent on to the next slave and the master bus gets overwhelmed by lots of slaves talking at once.

One idea that came up as I was discussing the problem on the EV Tech list was to use a "Hamming code" for sending the slave commands. You will have to google it, but it is basically a way to send data and have error checking and correcting done on the fly. I have only looked briefly at it, but it may be suitable for the slave bus to ensure that the correct commands are sent and any corrupted data gets repaired on the way.

Heres the quote from Lee Hart on Hamming codes;
Another possibility (and simpler to implement on a limited micro) is to use an error-correcting code. For example a Hamming code uses 8 bits to send 5 bits of data. An error in any one bit is automatically corrected. A 256-byte lookup table converts a byte with any 1-bit error into 5 bits of error-free data.
Greg Fordyce

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

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 » Wed Apr 27, 2011 9:56 am

Yes i had thought of adding a checksum system and sending two or more bytes.
Well it is a work in progress so we can look at that over comming months.

Now i have the extra opto isolation on the master bus my system has not given a single error for several months :shock: so i haven't bothered to do any work on it at all :D I do have my 2 x 25cell slave boards stacked though so slave bus is quite short.
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.

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

Re: Old BMS Software Thread

Postby GregsGarage » Wed Apr 27, 2011 2:00 pm

Quick update. The V10 slave software seems to work o.k. It appears to be filtering out unwanted noise fine in the slave bus. However general noise on the master bus is still present and preventing the master from reading the data. I can see the data being sent on the scope, in the background of the noise, which I couldn't see before, so some progress. 8) At the moment I am using the current loop idea, so will have to go back to your isolated bus idea, which should solve the noise issue. I think I had two noise issues, the master bus which I temporarily solved using your isolated master bus trick and the slave bus issue which seemed to come and go for no apparent reason. But the controller switching frequency is 16khz, the slave runs at 4mhz and the baud rate is 9600, all numbers that evenly divide, I suspect that the noise at 16khz is causing the slave to read a particular value, that luckily isn't a valid command code, rather than getting a random number.

There is a version of the Hamming code called, Hamming(8,4) code that can handle 4 bits of data (enough bits for our 13 command codes), uses 3 bits for error correction and 1 bit for parity. So you not only get a checksum value, but single bit errors get corrected and it still only needs 1 byte of data. 8) I haven't looked close enough at it to really get my head around it, but looks like a good improvement when we have the time. :shock:
Greg Fordyce

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

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

Nearly there.

Postby GregsGarage » Wed Apr 27, 2011 2:45 pm

Isolated master bus has cleaned the signal up nicely. Getting a problem where I am losing the slave bus communication between 9 and 10, that is between the first and second slave pcb. I will reroute some of the wiring, maybe go to the back first and leave the front slave for last. If this sounds a bit strange, I realized a while ago that since my slaves where each wired to the battery boxes and not interconnected to each other It doesn't matter which way I route the master and slave wiring. The slaves are all isolated from each other and the master is a isolated parallel bus. :shock:
Greg Fordyce

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

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 Jun 06, 2011 5:20 pm

Master V29 Software small update.

This version moves the charge control toggle to the main switch level so you don't have to go into a sub menu first.
Press down to toggle charger on/off.

SOC now resets itself to 100% whenever charge is terminated by all cells passing 3.55V during the charge cycle.

SOC caluclation variable adjusted to try and get more accuracy with my 20 ah cells.
Attachments
MASTER_V29_040611_185V_P.zip
(28.31 KiB) Downloaded 197 times
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 2 guests