Page 39 of 62

Re: Old BMS Hardware Thread

Posted: Mon Feb 07, 2011 8:17 am
by retepsnikrep
I changed the 1S pulse in pin to the unused oscilator pin 9 on left hand side of master chip, should be easier to link to as it has unused solder pads :)

I have finished the new master code will try it all this morning. We have a couple of extra Alarms now to help identify trouble spots. When commands are sent there are two possible alarms.

1) A serial data timeout, opps something has gone wrong with the comms :shock:
2) Command recd does not match command sent! oh bugger now we are in a mess :lol:

The Master now waits for the one second pulses from Gregs watchdog chip at the end of the main loop. It also has a fail safe in that if no 1S pulse is recd in a reasonable time then it triggers an alarm.
So the master and watchdog chips are in effect now spying on each other 8)

I have also made a minor change to the slave software, just increased the serial timeout to 10 seconds. it is not critical and you should only update if you have fresh slaves that need changing. It gives us a longer on balancing time > 5S possibility later on.

I may well hack on an auto off transistor to allow master to turn itself off once charging complete as well. So a momentary button to turn on master then turns transistor on. Master turns off transistor once charge completed ok. Might use pin 10 on left hand side as an output for that.

The master is now getting a bit messy and I'll have to rewrite it as some stage. All good fun though. :D

Re: Old BMS Hardware Thread

Posted: Mon Feb 07, 2011 11:28 am
by retepsnikrep
I've tried this and am getting close. hacked a wire from pulse pin to master pin 9

The watchdog appears to be operating correctly. The system was looping at two second intervals. I disabled the I2C temp sensors and chopped a few ms from some other routines and it now works correctly looping at 1s intervals. :)

So it appears with 50 cells and the two i2C sensors that the main loop takes longer than a second to execute. I need to perhaps just interogate one sensor per loop and alternate them. A bit of work left.

All this means that soc during discharging should be accurate once the loop is established. However during charging the accurate loop is bypased to allow more balancing time so it cannot keep accurate soc when charging. Once charging is finished I may just force system to reset soc to 100%

Re: Old BMS Hardware Thread

Posted: Mon Feb 07, 2011 2:32 pm
by GregsGarage
retepsnikrep wrote:The watchdog appears to be operating correctly.
:D :D
So it appears with 50 cells and the two i2C sensors that the main loop takes longer than a second to execute. I need to perhaps just interogate one sensor per loop and alternate them.

How about interrogating 4 (or more) sensors on a rolling basis? I was givving this some though last night and came to the same conclusion that you have, that is no need to read all the temp sensors every loop. I've got 4 sensors in my car so will need to read them possibly using this method.
All this means that soc during discharging should be accurate once the loop is established. However during charging the accurate loop is bypased to allow more balancing time so it cannot keep accurate soc when charging. Once charging is finished I may just force system to reset soc to 100%

Mutliply amp/seconds by extended loop time? So if you loop once every 5 seconds, multiply your figure by 5. Or another thought, continue checking amps every second but only do the voltage read every 5th loop?

Re: Old BMS Hardware Thread

Posted: Mon Feb 07, 2011 6:16 pm
by retepsnikrep
All sensible ideas I'll look again at it all tomorrow.

Re: Old BMS Hardware Thread

Posted: Mon Feb 07, 2011 7:04 pm
by jackbauer
Great news. I am actually using RA6 for the vss signal because i could not get it to work with RC1!! I tried everything. Five different chips. nada. I would go with the idea of forcing SOC to 100% once all cells pass say 3.55v. On the loop time issue why not have the watchdog pulses at 2 sec intervals. Solves all problems?

Re: Old BMS Hardware Thread

Posted: Mon Feb 07, 2011 7:16 pm
by retepsnikrep
OK I have added a routine to measure one temp sensor per loop. it steps through them each loop. I have removed the reading after the decimal point. Whole degrees is plenty accurate enough and it saves some variables, you may even be able to fit four readings with sign on same line :wink:

Strange someone else could not get speed to work on that pin. I have. Did you remove any capacitor across it? The pic needs to see a clean rise/fall from a pulse sensor. Also the pulsein command times out after 50 or 100ms or the program would get stuck at that point so your pulses must occur at least every 50 / 100ms.

Code: Select all

   DEFINE PULSEIN_MAX 10000   'Set PULSIN maximum count to 10,000 (50ms) (Range 0-65535 x 5us units)


I have also added a counter to ignore the CheckVoltage routine when charging for x loops. You can change the constant before compiling. I'm hoping this will mean the 1s loop also works for charging. As current and soc is still being done each second :)

I have also disabled the CheckSpeed section when charging, a complete waste of cycles and time :roll: It just jumps over this section when on mains charger, and again should help the 1S loop execute properly.

I'll test it all tomorrow 8)

Re: Old BMS Hardware Thread

Posted: Tue Feb 08, 2011 2:57 pm
by retepsnikrep
Strange after a lot of testing the master has become completely unreliable at the moment getting stuck etc and counting odd intervals.

Something very odd is happening. Not sure what, so going to remove the 1spulse stuff and just see how fast the main loop goes now with the normal but quicker code. Might be interference getting into the master 1S pulsein pin so may need a 0.1uf cap on it?

I notice the SV2000 video chip also outputs a pulse every second as a sort of I'm alive signal. . It sends 255 via serial 9600,8,N,1 on the tx pin. I might try attaching to that and waiting for the serial data to appear.

Attached is the code for what it's worth. it is not a zip file just rename it to *.txt

Quite a bit is changed. :shock:

Edit

I give up :roll: changed to the sv2000 one second pulses and now loop is running too fast. No sense at all. Runs too fast then freezes up for a bit after about 20-40 seconds. Must be a problem with master code or configs somehow. I even remmed out the temp sensors. Totally confused now.

Re: Old BMS Hardware Thread

Posted: Tue Feb 08, 2011 6:14 pm
by martinwinlow
Hi Peter, Forgive me if this has been posted before but is this the right way to wire up my LEM current sensor...

Re: Old BMS Hardware Thread

Posted: Tue Feb 08, 2011 6:23 pm
by retepsnikrep
I don't know i have never used one. Looks OK. Make sure 0v goes to ground and 5V goes to +5v and the signal goes to the input pin and see what happens when you pass a known current say 10A through it.

I assume it idles at 2.5v = 0A which is how the sensor circuit is set up.

Re: Old BMS Hardware Thread

Posted: Tue Feb 08, 2011 6:46 pm
by retepsnikrep
What a Bstrd think i have found the error.

Looking at the 16F886 chip pinouts I discovered that Pin RA6 & RA7 are not logically placed and are reversed!! :shock:

I was feeding the pulses into pin 9 the other spare crystal pin. And the pin with nothing attached was being used as the one second pulse input!!! This was floating free and picking up all sorts of cr*p. :roll: I'll try again tomorrow!!!

If you look down the left hand side of this diagram at RA0 to RA7 you will see what i mean :evil:

16F886.jpg
16F886.jpg (48.33 KiB) Viewed 18341 times


WTF are RA6 and RA7 reversed :?: