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:

Postby retepsnikrep » Sat Jul 18, 2009 6:12 am

Is this the part of the slave code you are talking about?

low MasterBus ;Turn on MasterBus Optocoupler (Reqd due to sink driven)
serout MasterBus,Baud2400,(VData) ;Send VData (b0) to Master at Baud2400
high MasterBus ;Turn off MasterBus Optocoupler (Reqd due to sink driven)

low SlaveBusOut ;Turn on interrupt signal for next Slave (SlaveBusOut)
Pause Delay ;Allow time for next Slave and Master to be ready
high SlaveBusOut ;Turn off interrupt signal for next Slave (SlaveBusOut)


I don't think even I can fully explain it now, except to say the slave optos are sink driven for better low voltage effciency. However being sink driven that means the optos are on when the Pin 5 is low. I found the serial commands did not work without the low/high commands. So the data is inverted from what you would expect when using the N1200 command. This is why the Master uses the T1200 command in the receiver section.

Of course looking at it again now my own logic does not make sense :oops: and there is probably a much simpler solution like a High MasterBus command at the program start!

Of course I found all this out by trial and error.

Feel free to change the code for a simpler version if you can get it to work.

I've actually been thinking about sending a pulse of length (X) instead of serial data using the PULSOUT command to transfer the Cell Voltage as this would be simpler. Running the 08M Slaves at 8mhz the pulse time is in 5us units.

PULSOUT MasterBus, VData ;Sends a pulse on the Master Bus equivalent to VData x 5us

Using PULSIN on the Master it can measure the length of the pulse and recreate the cell voltage.

PULSIN MasterBus , 1 , VData ;Receives the pulse in the Master

If no Pulse is received within the timeout period (0.32seconds at 8mhz) then we can jump to the error routine as we do now with any serial comms error. If the value in VData was 255 (Max) then that would take 255 x 5us to transmit or 1.275ms per Slave. Pretty fast and much faster than the serial comms! Hmm looks interesting. Could speed up the comms a lot!

We would need a High MasterBus instruction at the begining of the Slave software to turn the MasterBus opto off, because PULSOUT inverts the state of the pin. Then whenever it sends a pulse we get the desired signal out.

If the really short pulses proved inaccurate or prone to noise we could simply x 10 everything and take a more leisurely 12.75ms per slave to transmit the longest (highest possible voltage) VData pulse.

In fact thinking even more we could get rid of the squeezing the data into one byte system I used. 8)

So we could send the full Voltage Value using the Word Variable CellVoltage!!! :shock:

PULSOUT MasterBus, CellVoltage ;Sends a pulse on the Master Bus equivalent to CellVoltage x 5us

This avoid all the adding and subtracting 175 from variables at both ends!! :roll:

Edit

Try this Digital Slave software and look at the Master Bus signal with a scope.

www.solarvan.co.uk/bms/SLAVESIMPLEDIGIT ... _PULSE.TXT

Ignore the stupid google warning!!!!! :roll:
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:

Postby GregsGarage » Sat Jul 18, 2009 3:56 pm

Great idea Peter, using a pulse width to output battery voltage instead of serial data. 8) Hopefully it should make the system more resistant to electrical noise, or at least easier to filter out. I will try it out on my one spare slave module, but probably not for a couple of weeks due to lack of time at the moment. :cry:

It also gives me an idea of how to use the Splatco controller that I used on my first system for a fully digital master instead of the simple analogue slave setup that I was using. It also has the ability to measure pulse widths, so I can probably adapt bits of your master code to work with bits of my code. Could be an option for those that don't fancy building the master module.

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 » Sat Jul 18, 2009 5:38 pm

Greg, I think it will be intrinsically more interference resistant as well. And in fact we could even put some capacitance across the master bus to help with spikes depending on how it responds. The filtering can be more aggresive certainly. Harder pull down etc.

Here is an updated Pulse version of the Master.

www.solarvan.co.uk/bms/MASTER180709_V97_PULSE.txt

It has no syntax errors but is otherwise untested.

The delay in the Slave software needs adjusting once we have seen how fast the Master can process the incomming Pulse data on a simple test rig of say three or four cells.

The extended display does not work now and needs a new routine.

My Master is not accesible as it is installed in my car, so can someone do some experiments with this Pulse method to work out the timings.

As we are not relying on serial data it would also be possible to increase the Master cpu speed to 16mhz now with an external resonator which would double the program execution speed.

Note if we doubled the Master speed we would need to divide the CellVoltage by 2 once received to get the correct value.
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:

Postby GregsGarage » Mon Jul 20, 2009 6:40 pm

retepsnikrep wrote:My Master is not accesible as it is installed in my car, so can someone do some experiments with this Pulse method to work out the timings.


Peter,

I will need to build my last 2 slaves, but I don't have a Master PCB. Was looking at possibly the Splatco controller that I had used before, but I don't think it will be easy to measure the length of the pulses with it. I am going to look at the possibility of a Ardinuo board for a Master, failing that I'll have to get one of your Master PCB's when you get some more in.

Greg
Greg Fordyce

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

wjdennis
Posts: 17
Joined: Tue Aug 05, 2008 5:27 pm

Software Noise Mitigation

Postby wjdennis » Mon Jul 20, 2009 11:59 pm

Peter,
Microcontroller programming is new to me, but I think you can call an assembler routine from PICBASIC. Perhaps something like the following pulsin replacement for the Master would help get rid of spurious noise. Basically, it starts counting the high pulse, then waits for a minimum 1275-microsecond low signal afterwards. It the low signal doesn't last that long, then it considers it noise and keeps counting the high pulse.

Code: Select all

;The following code is calibrated for 8Mhz processor speed
;Each instruction takes 1/2 microsecond (uSec) to execute
;Branch instrutions take 1 uSec to execute
;
;First we'll wait until we see a 1 (high) on the MasterBus
;Then we'll count the number of 5-uSec intervals
;  until the signal goes back to 0 (low)
;When we see a 0 on MasterBus, we'll make sure that it
;  lasts 1275 uSec, otherwise we'll regard it as noise
;  and will continue counting 5-microsecond intervals
;If we return a zero in the CntrHigh/CntrLow combo
;  then some type of error occurred
;Otherwise, CntrHigh/CntrLow contains a number between
;  1 and 255:   5 = 1.80V;  6 = 1.81V,   7 = 1.82V ....
;       ....  248 = 4.23V  249 = 4.24V; 250 = 4.25V 
;  Less than 5 indicates undervoltage
;  Greater than 250 indicates overvoltage
;
Pulsin
   Clrf CntrHigh      ; Clear the high-order count byte
   Clrf CntrLow      ; Clear the low-order count byte
   Clrf ZeroCount      ; Clear Noise Duration
HighWait
   Btfsc PortA,7       ; Wait for a Slave 0 to 1 transition
   Goto CountIt       ; Slave is High!
IncWait
   Incfsz CntrLow,F   ; Increment low byte until > 255
   Goto HighWait
   Incfsz CntrHigh,F  ; Loop until high byte > 255
   Goto HighWait      ; Waits about 1/6 second in total
   Return         ; Both counters are zero: Error!
CountIt
   Clrf CntrHigh      ; Clear the high-order count byte
   Clrf CntrLow      ; Clear the low-order count byte
LowWait
   Btfss PortA,7      ; Still at logic 1?
   Goto NoiseCheck      ; Nope, make sure it's not noise
   Nop
   Nop         ; This whole Nop loop takes 10 cycles
   Nop         ; (i.e., 5 uSec at 8 Mhz)
   Nop
   Nop
   Incfsz CntrLow,F   ; Have we reached the limit? 
   Goto LowWait      ; Nope, keep counting pulse length
   Return         ; Yep, 255 intervals passed. Error!
NoiseCheck
   Btfsc PortA,7       ; Still zero?
   Goto AddNoise      ; Nope, must have been noise
   Nop
   Nop         ; This whole Nop loop takes 10 cycles
   Nop         ; (i.e., 5 uSec at 8 Mhz)
   Nop
   Nop
   Incfsz ZeroCount,F ; Waited Long Enough?
   Goto NoiseCheck      ; Nope, keep counting
   Return         ; Woo-hoo!  We got us a valid count
AddNoise
   Movf ZeroCount,W   ; Move Noise Duration to W
   Clrf ZeroCount      ; Clear Noise Duration for next time
   Addlw, 1      ; This code takes a 5-uSec interval
   Addwf CntrLow,F      ; Add Noise to pulse counter
   Btfss STATUS, C      ; Was there a carry?
   Goto LowWait      ; Nope, keep counting pulse length   
   Clrf CntrLow      ; Yep, this has all taken too long
   Return         ; So return zero: Error!    

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

Postby retepsnikrep » Tue Jul 21, 2009 3:35 am

If you def want a Master Greg I will order some more?

Interesting idea with the assembly subroutine, but sadly the Picaxe chips I'm using cannot make calls to assembler. :cry: So that idea is a non starter for the Picaxe chips. If someone wants to re-write the Master software in pure assembly :shock: or picbasic be my guest. I think we will have to see how the Picaxe count command copes to start with.
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:

Postby GregsGarage » Tue Jul 21, 2009 2:13 pm

retepsnikrep wrote:If you def want a Master Greg I will order some more?


Peter, don't rush out and order on my behalf just yet. I want to look at the possibility of using an Arduino board for the master. Don't think it is something that I don't like about your design, I just want to see if something could be used that is already available. Since only one master is required per vehicle, compared to the 25 - 100+ slaves that may be fitted to the same vehicle it may be worthwhile to look at alternatives.

I am thinking of this board http://arduino.cc/en/Main/ArduinoBoardDuemilanove together with this prototyping shield http://www.oomlout.co.uk/proto-shield-for-arduino-kit-p-206.html that sits on top of the Arduino board and would allow for optos and transistors required to send/receive data from slaves and drive relays. I think the watchdog pic could be mounted on it as well. Also I2C support is built in for the temperature sensors and lots of display options available as well. It may also be able to incorporate Bill's software noise mitigation routine as well, if it is required that is. Mostly I am thinking out loud here, will have to look at the Arduino in more detail and see if it will suit this project.

Greg
Greg Fordyce

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

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

Postby steiner » Thu Jul 23, 2009 3:43 am

I just received my new 3.5" display so I am currently working on updating the code to drive this display instead of the 16x2 display. As soon as I am finished with it I will try the "Pulse" version of the software to see how it works. It probably won't be until this weekend though.

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

Postby retepsnikrep » Thu Jul 23, 2009 4:52 am

steiner wrote:I just received my new 3.5" display so I am currently working on updating the code to drive this display instead of the 16x2 display. As soon as I am finished with it I will try the "Pulse" version of the software to see how it works. It probably won't be until this weekend though.


Rick.
Does your new display work ok? Pics?
Did you get it from that same e-bay seller?

RE the Pulse code the issue will be timing IMO.

We need to establish now long it takes the Master to execute one loop of the Pulse reception routine at 8mhz. Then adjust the slave delay accordingly so we know Master is waiting for a pulse before transmission of said pulse by the Slave actually starts.

I'm finally taking my PHEV off the road this week to sort the wiring etc for my cells and get my BMS working properly :roll: I will have the Master on the Bench next week so will also report back re Pulse mode in due course.

Talking about Noise.

We know that a useful or reasonable pulse should be between say 250-400 units (2.5-4.00V) anything outside that we could reject out of hand or log as an error, but Master could allow a certain number of errors before it actually flags an alarm. We could allow a slightly bigger range say 100-500 units which would be (1.00-5.00V) and def reject any pulse count outside that range. Master could allow a % of errors before an alarm is triggerd.
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 » Fri Jul 24, 2009 4:24 am

Peter,

No, sadly the display doesn't even work. I used the output from my video camera to test the display and I get nothing.

I don't know if it is from the same vendor as yours but the display looks very similar. I am in discussions with the vendor right now to see what they can do. Image

[/img]


Return to “BMS thread”

Who is online

Users browsing this forum: No registered users and 1 guest