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:

Re: Old BMS Software Thread

Postby retepsnikrep » Sat Oct 09, 2010 12:26 am

Well done looks good. I'll let you iron out the bugs before I try and follow your lead. :shock:

What is the difference in code size between two versions?

How much space does new code take?

Master now has about 2000 words free.

Edit

Just tweaked master code and included the updated SOC code which works using the ampseconds we have been discussing. SOC is now to 0.1% instead of .01% but should be more accurate. Still needs the one second timer.

Also included start up current sensor offset calibration routine. When BMS is turned on each time now it gets the current sensor ADC reading when zero amps is flowing. It then uses this as the zero point offset to more accurately detect current levels. So BMS should be switched on before main contactor/car etc. It displays the offset / zero point on BMS startup splash screen. :)
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 » Sat Oct 09, 2010 10:11 am

retepsnikrep wrote:What is the difference in code size between two versions?

How much space does new code take?



If I said a lot smaller would you believe me. :shock: I started with your version http://www.solarvan.co.uk/bms/Watchdog12F683_110610_V02.txt and added the interrupt routine which then required MPASM instead of pbp built in PM assymbler. Reported code size of new version is 379 words and the old version is 961 words! This seems very strange, I can't believe the MPASM assembler is that much better.

EDIT: I just compiled V02 of the watchdog and it is 174 words, the 961 words is from the comments. So 379-174 is 205 words for the 1 second timer. So no problems fitting it into the master as far as space goes. Getting it to work is another story.
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 » Sun Oct 10, 2010 4:58 am

I have now installed and got MPASM working on my machine, had to download the latest MPLAB IDE software. I did a custom install and just installed the MPASM section and 8 bit chip support.

I edited the inc file and added the below to the Master code after commenting out the PM config stuff.

'Below used with MPASM Assembler
@ __config _CONFIG1, _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _CPD_OFF & _CP_OFF & _MCLRE_ON & _PWRTE_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT

It compiles without errors. Will try to test this AM on my 8 cell bench setup.

If it works OK then we could possibly add Interrupts to the Master. Not sure how best to do it, might be best to add interrupt to the button routine so it only interrupts it there. An interrupt occuring in the serial data comming in from the slaves will cause an error i'm sure. :shock:
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:

Re: Old BMS Software Thread

Postby retepsnikrep » Mon Oct 11, 2010 10:13 am

Here are two new bits of software compilied with MPASM

The remote display now works with pbpro 8) plain pics and the below Master code.

www.solarvan.co.uk/bms/MASTER_V19_111010_MPASM.txt
www.solarvan.co.uk/bms/MASTER_V19_111010_MPASM.hex

www.solarvan.co.uk/bms/REMOTEDISPLAY_V0 ... _MPASM.txt
www.solarvan.co.uk/bms/REMOTEDISPLAY_V0 ... _MPASM.hex

The Master has the new untested SOC code.
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 Oct 12, 2010 9:53 am

Been away a couple of days, will try the new master software as well. Another reason to go with the MPASM assembler is that the PM assembler is not recommended for versions of windows Vista and newer (I am using win7) and also 64 bit versions of windows.

retepsnikrep wrote:If it works OK then we could possibly add Interrupts to the Master. Not sure how best to do it, might be best to add interrupt to the button routine so it only interrupts it there. An interrupt occuring in the serial data comming in from the slaves will cause an error i'm sure. :shock:


Peter, I think you may be right about interrupts causing problems with the cell data routine. At the moment I can't see a way to use the routine I put in the watchdog directly in the master without causing potential problems. So how about if we monitor the 1 second toggle from the watchdog chip. Have the master program, loop at the buttons routine so that it keeps checking the buttons and the watchdog and when the watchdog toggles it exits the button loop and carries on with the rest of the program (or if a button is pressed, handles that). This should also improve the button response because it will check the button status more often. We can then concentrate on testing the 1 second routines and once that is working see if we can get the master code to directly time itself using the interrupt routines. If not then we just stay with the watchdog pulse.
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 Oct 12, 2010 3:31 pm

Sounds fine. I'm going to try a simple delay in my Master code though and calibrate the main loop so it executes once a second. I'm running the posted newest Master code in my car at present on the 50 cell system. Amps seems to be better, SOC no idea as one second thing not sorted yet. 8)
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
f.mendes
Posts: 19
Joined: Fri Sep 24, 2010 10:40 am

Re: Old BMS Software Thread

Postby f.mendes » Sat Oct 16, 2010 2:35 pm

Hi guys.

I've been busy in last weeks.

Since we've migrated to the PIC16F886, the transmission pin's also changed right?

In relation to the PIC12, there were also changes.

What are the transmission pin's of PIC12?

Regards,

Francisco.

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

Re: Old BMS Software Thread

Postby GregsGarage » Sat Oct 16, 2010 6:28 pm

Hi Francisco,

I don't really understand your question. Peter is always very good with his comments in the source code and defines all the pin functions there. Hope that helps.
Greg Fordyce

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

User avatar
f.mendes
Posts: 19
Joined: Fri Sep 24, 2010 10:40 am

Re: Old BMS Software Thread

Postby f.mendes » Mon Oct 18, 2010 6:34 pm

In PIC16F886 the pin of RX and TX are in pin 18 and 17, and in the master hardware picture those pin's are in pins 6 and 7.

And about PIC12F683 the RX is connected in pin 2 and TX is connected in pin 7.

But that was for PICAXE. Now the Pin's are different right?

So where do i connect those pin's in PIC12?

Regards,

Francisco.

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

Re: Old BMS Software Thread

Postby GregsGarage » Mon Oct 18, 2010 9:30 pm

Francisco,

The pins 6 & 7 on the master and slave pins 2 & 7 were used for the PICAXE programming header. The current circuit boards were designed when we were using the picaxe chips, but now that we have moved from the picaxe to bare chips and pbp the PICAXE headers are no longer needed. Peter has found a use for the picaxe programming lead on the master by using it to supply data, but unless you need it you can leave these components off of the pcb. What is required for the next version of the boards, both slave and master, is a ICSP header to replace the PICAXE header, so the pics can be programmed on the board. At the moment you have to remove them for programming. The pinout for the slaves at present is

Code: Select all

'************************** Slave PIC12F683 Pinouts ****************************

'                                    Top               
'                                   _____
'(+ Cell Supply)             +Ve -1|  ^  |8- -Ve               (- Cell Supply)
'(Slave Alive Out)           GP5 -2|  6  |7- GP0             (Bypass Load Out)
'(Slave Data Bus Out)        GP4 -3|  8  |6- GP1            (RefAdc In 1.235V)
'(Slave Data Bus In)         GP3 -4|  3  |5- GP2         (Master Data Bus Out)
'                                   -----
So pin 2 now toggles high/low but is not connected to anything. This is just a diagnostic aid, by connecting an oscilloscope to the pin you can check the slave is alive. Pin 7 is and has always been connected to the bypass load as well as the programming header. When programming the pic with the picaxe lead it toggled the load as well but that never affected the programming so it didn't matter. You will find a similar section in the master code, so I won't re-post it here. If you have designed, or are designing new boards, please post some pictures of your work for the benefit of us and others.

Pin 17 and 18 are indeed the hardware UART ports for the 16F886, but again because the board was designed for the PICAXE we have not necessarily used these pins for RX and TX. For version 3 these will be used for communications, but they have yet to be built. One thing I have found out is that it is possible to connect a pic to a serial port with just a 22k resistor from the TX on the pc to the RX on the pic and a current limiting resistor (470 to 1k) on the pc RX and the pic TX. The 22k resistor limits the current from the +10 to -10 volts RS232 levels to a safe amount for the pic and most PCs have no problem receiving TTL serial data. So while it doesn't comply with the RS232 standard it is good enough. 2 points to watch out for is that you have to use inverted serial on the pic and because of that you need to use the SERIN or SERIN2 command and not HSERIN. The thing that strikes me about this is that is what the picaxe programming header basically looks like, so it seems that is what they have been doing as well. Hope that helps.
Greg Fordyce

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


Return to “BMS thread”

Who is online

Users browsing this forum: No registered users and 40 guests