Old BMS Software Thread

Threads relating to the BMS system begun by Peter Perkins

Moderators: GregsGarage, retepsnikrep

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

Code

Postby retepsnikrep » Mon Nov 23, 2009 12:03 pm

This is Rick's code.

www.solarvan.co.uk/bms/Digslave.pbp

Having looked at it a bit today I think it should be fairly easy to sort. It compilies correctly with all the rems (') removed but I haven't tested it.

Just looking I note the interupt routine is a bit tricky I think we can do away with that in this version as the chip will be 10-20 x faster than a picaxe version, so we can just test the slave bus pin at the end of the adc readings and if it is high send the data.

Picaxe maths is different from PBP maths in that picaxe is strictly left to right but pbp has a hierarchy of operators. Need to check that.

I'll have a fiddle around later.
Last edited by retepsnikrep on Thu Nov 26, 2009 3:25 pm, edited 1 time in total.
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: Code

Postby GregsGarage » Mon Nov 23, 2009 12:18 pm

retepsnikrep wrote:Just looking I note the interupt routine is a bit tricky I think we can do away with that in this version as the chip will be 10-20 x faster than a picaxe version, so we can just test the slave bus pin at the end of the adc readings and if it is high send the data.


Is their some sort of count function we could use. So the pic counts the number of pulses on the slave bus input, if 0 then it continues its loop and if it is 1 (or greater) then it outputs on the master bus. Or alternatively just increase the length of the slave pulse so it doesn't miss it, but if it is too long it might output 2 sets of data.

Edit: Or use the interrupt to set a flag and then use this to send data at a convenient time in the program, ie, not in the middle of the cell voltage calculation loop.

Greg
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:

Postby retepsnikrep » Mon Nov 23, 2009 2:20 pm

I've made up a slave board with a socket fitted to fiddle about. I can program the pic no problem. I removed all the interrupt stuff and just have a simple (if pin = low then main) . It should be fast enough that we can do this without issue.

If the slave bus input pin goes high it then waits until it goes low and then sends the data as before.

It doesnt work as yet as led does not turn on/off as voltage increased but I suspect the maths part.
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.

steiner
Posts: 89
Joined: Mon Sep 08, 2008 1:50 am
Location: Florida

Postby steiner » Thu Nov 26, 2009 4:59 am

I wanted to provide some background on the code that I wrote for using a standard PIC on the slave portion. I have some of Peter's slave boards and one of his master boards. I was able to get this configuration working just fine using the original picaxe chips on both boards. What I wanted to do was see if I could replace the picaxe on the slave with a standard pic. The reasoning behind this was cost (about 1/2 as much for standard pic) and I have all of the hardware necessary to program pics because I have used them in the past.

The problem that I ran into was communication between the pic and the picaxe. I was able to see the data via a scope coming out of the slave when a picaxe was installed. My thinking was if I could get the data to look the same when using a standard pic, the picaxe on the master would never know the difference. I felt as though I was able to do this but yet the picaxe on the master kept giving me a data error which is what the master code is designed to do if there is a communication problem. During my trouble shooting, I inserted several lines in the slave code to see if they would have a positive affect. One of them is "define CHAR_PACING 2000". This didn't seem to affect it one way or the other. You will also notice in the "Loop 1" portion I just forced Vdata=85. I wanted to elminate any calculations that were going on in the pic. With Vdata=85, the output should produce an alternating series of ones and zeros for the entire byte. This made it a little easier to compare the scope readings.

I wish you luck solving this and I will try to help when I can. I had decided that it would probably be easier for me to rewrite the master code to a standard pic and that should solve the communication problems. Other projects have gotten in the way and I haven't had an opportunity to work on this.

Rick

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

Non Picaxe Slaves

Postby retepsnikrep » Thu Nov 26, 2009 6:20 am

Rick

Can you post your latest code, I've tried tinkering with what I had but I can't get it to do the adc readings let alone do the serial stuff. Thanks

Peter

Edit

OK this seems to be working now turning load led on/off correctly when changing voltage applied to the slave board. It is also sending data when reqd, master bus data looks ok on the scope but am unable to check if OK as no spare built Master. Can't be far out now. So Greg over to you.

www.solarvan.co.uk/bms/pbpsla05.pbp
www.solarvan.co.uk/bms/PBPSLA05.HEX
www.solarvan.co.uk/bms/PBPSLA05.ASM

You only need the hex file for the programmer.

I note there is no 4800 baud option with pbp which I am using at present with by picaxe slaves. It goes from 2400 to 9600 bauid so this is now set for 9600 and should be twice as fast. Remember the baud in the master software recieve will have to be changed to reflect this.

Master updated to suit.

www.solarvan.co.uk/bms/MASTER_8mhz_2611 ... 00BAUD.txt
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.

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

Postby retepsnikrep » Sun Nov 29, 2009 8:01 am

If our new pbp code and boards work OK I'm going to try and get the slave bus to send a few other codes to the slaves so we can change the bypass load cut in/out point without re-programming them. I did fair bit of work on this over a year ago so hopefully don't have to re-invent the wheel.
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: Non Picaxe Slaves

Postby GregsGarage » Sun Nov 29, 2009 11:13 am

retepsnikrep wrote:Edit

OK this seems to be working now turning load led on/off correctly when changing voltage applied to the slave board. It is also sending data when reqd, master bus data looks ok on the scope but am unable to check if OK as no spare built Master. Can't be far out now. So Greg over to you.

www.solarvan.co.uk/bms/pbpsla05.pbp
www.solarvan.co.uk/bms/PBPSLA05.HEX
www.solarvan.co.uk/bms/PBPSLA05.ASM

You only need the hex file for the programmer.

I note there is no 4800 baud option with pbp which I am using at present with by picaxe slaves. It goes from 2400 to 9600 bauid so this is now set for 9600 and should be twice as fast. Remember the baud in the master software recieve will have to be changed to reflect this.

Master updated to suit.

www.solarvan.co.uk/bms/MASTER_8mhz_2611 ... 00BAUD.txt


I completely missed this until this morning, :roll: maybe because you edited your post it didn't flag up on the forum as being a new post. Anyway, great work. :D

I will have to get building to test it now.
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:

Postby retepsnikrep » Sun Nov 29, 2009 11:33 am

Well I have just tried my single test slave programmed with pbp assembler and the Master V2 i just built. Seems to work OK straight off. 8)

Comms at 9600 baud :D

Master does not like having no temp sensors connected though so gives constant alarms as thinks battery temp is 255C LOL :shock:

www.solarvan.co.uk/bms/MASTER_8mhz_2911 ... 00BAUD.txt

Master above corrected for new sv2000 chips.
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.

steiner
Posts: 89
Joined: Mon Sep 08, 2008 1:50 am
Location: Florida

Postby steiner » Tue Dec 01, 2009 1:41 am

Peter,

Great job.

I haven't had a chance to look at your code to see what the difference is. Do you have any ideas what I was doing wrong?

Have you run across your 3-1/2" LCD display that doesn't have a housing? I am hoping to find some time to work on this over the Christmas holiday. I am also interested in one of the PCB boards for the remote display.

Rick

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

Postby retepsnikrep » Tue Dec 01, 2009 6:34 am

Rick

Send me a list by pm/e-mail of exactly what you need and address etc, i still have that display waiting for you.

RE The code I think it was several things, some of the defines were missing, some of the adc commands where pointing to the wrong pin/s. Little errors that I'm sure added up a frustrating time. I posted your earlier code have a look at that and mine I can't remember the exact differences. I also got rid of the interrupt routine.

Peter
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 40 guests