Greg thank you very much.
I was not understanding few things but now it's everything clear for me.
I thought it wasn't needed to remove pic from board, but since we need to do it, i'm going to build the circuit to program the pic on-board.
I made a few changes on my schematic, since I don't need few things, like speed sensor, interlocks, video out, etc... the only thing I need is to make a communication with other pic, the PIC24, wich does everything about security, read information from motor and sends information to a touchscreen LCD.
When I finish my board, i can post few pictures here, so you can see what i've done.
Regards,
Francisco.
Old BMS Software Thread
Moderators: GregsGarage, retepsnikrep
- retepsnikrep
- Posts: 1387
- Joined: Sat May 26, 2007 4:50 pm
- Location: North Yorkshire England
- Contact:
Re: Old BMS Software Thread
We look forward to seeing your pics and ideas. Sorry i've been busy on other stuff lately so Master v3 again on hold a bit.
Peter
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.
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.
-
- Posts: 870
- Joined: Tue Apr 01, 2008 5:27 pm
- Location: Galashiels, Scottish Borders
- Contact:
Re: Old BMS Software Thread
Here is how I suggest we use the 1 second pulse from the watchdog which toggles pin 7 once a second. SecondPulse needs to be defined as the input pin on the master to recieve the watchdog pulse, MasterPulse needs to be defined as a single bit variable and LoopCounter needs to be defined as a byte variable. My suggested changes to the MainLoop, new bits marked *NEW*.
Each individual loop might not be exactly 1 second long, but on average the program will loop once a second. So after one hour of running it will have looped 3600 times. Actually it will have looped more than that because I let it loop through the MenuButtons routine and skip the rest if one second hasn't elasped. This should improve the button response as they will be checked more often. While in the menus after a button press the SecondPulse will not be checked, so you lose this time. When coming out of the button routine and when the master is first powered up the program may hang for 1 second while waiting for the SecondPulse and Master pulse to equal. I don't believe this is a problem, but could be addressed with a bit more code. Any comments, suggestions or glaring mistakes?
Code: Select all
'*************************************************************************************************************
MainLoop: 'Main program loop
gosub MenuButtons 'Gosub MenuButtons gets button data (0,1,2,3,4,5 = no button) in Key
'Push = 0 Up = 1 Right = 2 Down = 3 Left = 4 No Key = 5
if Key = 0 then gosub SubMenu1 'If Menu button pressed gosub SubMenu1
serout PcLogger, N9600, [13,"DATA,TIME,"] 'Txd BMS Data bytes to Spreadsheet
toggle WatchDogLed 'Keeps watchdog happy, flashes every other time through loop
WHILE SecondPulse = MasterPulse 'Only do this after watchdog toggles SecondPulse *NEW*
gosub CheckVoltage 'Gosub CheckVoltage routine to collect/display Cell V data
gosub CheckCurrent 'Gosub CheckCurrent routine to calculate/display charge/discharge data
gosub CheckI2CTemp 'Gosub I2C Temp routine to collect/display battery temperature
gosub CheckSpeed 'Gosub CheckSpeed routine to calculate/display speed/distance
serout DriveInhibit, N2400, [85, 85, 85, 85, 85] 'Txd 5 byte preamble to clear Rxd
pause 10 'Pause for 10ms to allow serial rxd to clear
serout DriveInhibit, N2400, ["bms",Alarms,ErrCell] 'Txd data (2400 baud at 8mhz)
if Alarms > 0 then gosub DisplayAlarms 'If an Alarm is set then Gosub DisplayAlarms
if TSeconds > 29 then 'If Thirty seconds have elapsed then store data
VarA = 0
I2CWrite Scdeeprom,Sckeeprom,AT24C512B,VarA,[Cells,Odo.Byte0,Odo.Byte1,Trip.Byte0,Trip.Byte1,_
Dist.Byte0,Dist.Byte1,Soc.Byte0,Soc.Byte1] 'Write data to I2c eeprom starting at addr 0 'Line from above
TSeconds = 0 'Reset 30 second counter
endif
TSeconds = TSeconds + 1 'Increment Thirty Second Timer
Seconds = Seconds + 1 'Increment One Second Timer
MasterPulse = MasterPulse ^ 1 'Invert value for next change of SecondPulse *NEW*
LoopCounter = 0 'Keep counter reset unless Master loses watchdog pulse *NEW*
WEND ' *NEW*
LoopCounter = LoopCounter + 1 'This is a failsafe if we lose the SecondPulse from watchdog. *NEW*
Pause 10 '10 millisecond pause * 100 = 1 sec. *NEW*
If LoopCounter > 100 Then MasterPulse = MasterPulse ^ 1 'prevents program hang if SecondPulse doesn't toggle *NEW*
goto mainloop 'Goto main program loop
'*************************************************************************************************************
Each individual loop might not be exactly 1 second long, but on average the program will loop once a second. So after one hour of running it will have looped 3600 times. Actually it will have looped more than that because I let it loop through the MenuButtons routine and skip the rest if one second hasn't elasped. This should improve the button response as they will be checked more often. While in the menus after a button press the SecondPulse will not be checked, so you lose this time. When coming out of the button routine and when the master is first powered up the program may hang for 1 second while waiting for the SecondPulse and Master pulse to equal. I don't believe this is a problem, but could be addressed with a bit more code. Any comments, suggestions or glaring mistakes?
Greg Fordyce
Daewoo Matiz
http://www.evalbum.com/4191
Daewoo Matiz
http://www.evalbum.com/4191
- retepsnikrep
- Posts: 1387
- Joined: Sat May 26, 2007 4:50 pm
- Location: North Yorkshire England
- Contact:
Re: Old BMS Software Thread
Thanks for that Greg give it a try.
I'm horribly busy with loads of stuff so no software work from me for a bit. Ditto hardware
I'm horribly busy with loads of stuff so no software work from me for a bit. Ditto hardware
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.
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.
Re: Old BMS Software Thread
Hi all.
In slave program you use one equation that I don't understand.
RefVADC=63200 - (1.235x1023x100/2=63200)
Why 100/2?
Best Regards,
Francisco.
In slave program you use one equation that I don't understand.
RefVADC=63200 - (1.235x1023x100/2=63200)
Why 100/2?
Best Regards,
Francisco.
-
- Posts: 870
- Joined: Tue Apr 01, 2008 5:27 pm
- Location: Galashiels, Scottish Borders
- Contact:
Re: Old BMS Software Thread
f.mendes wrote:Hi all.
In slave program you use one equation that I don't understand.
RefVADC=63200 - (1.235x1023x100/2=63200)
Why 100/2?
Best Regards,
Francisco.
Peter can correct me if I am wrong but if I recall it has to do with the limitations of the pic maths. It all has to fit in 8 (or is it 16 bit?) so some funny eqautions result so we don't have an overflow.
The line in code is
Code: Select all
RefVADC con 63200 'Fixed Ref Voltage Calibration LM385 1.235v * 1023 * 100 / 2 = 63200
RefVADC is a constant set at 63200. Another way to think about how we got that number is (1.235v * 1023 * 100) / 2 = 63200. Notice that later we multiply the result by 2 which cancels out this divide by 2 and makes the pic maths work without an overflow. HTH Greg
Greg Fordyce
Daewoo Matiz
http://www.evalbum.com/4191
Daewoo Matiz
http://www.evalbum.com/4191
Re: Old BMS Software Thread
oh I see.
I thought it was because you have 100V of rated voltage.
But if it is for that reason, that is Ok.
It's 16 bits, 2^16=65535.
Regards,
Francisco.
I thought it was because you have 100V of rated voltage.
But if it is for that reason, that is Ok.
It's 16 bits, 2^16=65535.
Regards,
Francisco.
Re: Old BMS Software Thread
First off.. sorry if i'm miss posting this.. I'm not sure if my problem is software or hardware related.
I like this project very much, read almost the whole thread and decided to build a test slave for my cells.
I've build a test slave on a breadboard and programmed the latest slave software into it (V07), the bypass is working as expected turning on at and turning of at the correct levels (using a PIC12F683)
My next step was to send commands to the slave but I can't get this to work. I connected a netduino to the slaveIn and slaveOut port, modified the code to let the slave send out a signal over slave out at the serin2 timeout. When I run this the netduino receives my signal every 5 seconds as expected. But when sending a command from the netduino nothing happens.. I expect this command to be resend out over the slaveOut but is doesn't.. at the same time when sending a command every second the timeout never gets called.. so something is happening.. not sure what.
I have tested this with every serin2 port setting (driven/open, inverted etc etc), and all set to 2400 baud.. no response to send command, and receive is working fine.
Can anybody send me in the right direction to a solution for this?
I'm using the picbasic compiler 2.6A.
I like this project very much, read almost the whole thread and decided to build a test slave for my cells.
I've build a test slave on a breadboard and programmed the latest slave software into it (V07), the bypass is working as expected turning on at and turning of at the correct levels (using a PIC12F683)
My next step was to send commands to the slave but I can't get this to work. I connected a netduino to the slaveIn and slaveOut port, modified the code to let the slave send out a signal over slave out at the serin2 timeout. When I run this the netduino receives my signal every 5 seconds as expected. But when sending a command from the netduino nothing happens.. I expect this command to be resend out over the slaveOut but is doesn't.. at the same time when sending a command every second the timeout never gets called.. so something is happening.. not sure what.
I have tested this with every serin2 port setting (driven/open, inverted etc etc), and all set to 2400 baud.. no response to send command, and receive is working fine.
Can anybody send me in the right direction to a solution for this?
I'm using the picbasic compiler 2.6A.
- retepsnikrep
- Posts: 1387
- Joined: Sat May 26, 2007 4:50 pm
- Location: North Yorkshire England
- Contact:
Re: Old BMS Software Thread
There is a software patch for the compiler for serout commands 2.61A or something. Make sure you have it.
Difficult to comment on the rest without seeing the exact schematic and software you are using for both Master and Slave.
The slave will only respond (echo) if it recieves a valid command I don't know what you are sending it??
Difficult to comment on the rest without seeing the exact schematic and software you are using for both Master and Slave.
The slave will only respond (echo) if it recieves a valid command I don't know what you are sending it??
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.
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.
Re: Old BMS Software Thread
Hi Peter. Are you there?
What you say about my last comment?
About the function of RefADC?
Greetings.
Francisco.
What you say about my last comment?
About the function of RefADC?
Greetings.
Francisco.
Who is online
Users browsing this forum: No registered users and 12 guests