Maximite Master

Threads relating to the BMS system begun by Peter Perkins

Moderators: GregsGarage, retepsnikrep

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

Maximite Master

Postby GregsGarage » Sun Sep 18, 2011 10:22 pm

O.K., I've taken the plunge and ordered a Maximite. This single chip computer runs a basic interpeter, has a SD card socket for loading programs and storing data, has a composite video out and keyboard input from a standard ps2 keyboard. It also has 20 i/o pins. So with a interface board and some software it should make for an interesting master for the bms. When the MM boots it looks for a program AUTORUN.BAS on the sd card and runs it if found. It can also launch and run other programs on the sd card from within a already running program. What this means is that instead of having a single program to do everything, we can have seperate programs for charging and driving (and maybe small configuration programs to calibrate vehicle speed sensors, etc.). Individually this should make the programs simpler and easier to follow. Editing the programs can be done directly on the maximite, just plug in a keyboard, 8) or edit them on your normal pc using notepad and save to the sd card.

I have been working on how to best utilize the 20 i/o pins. Pins 1 - 10 can provide analog input at 3.3v. So,
Pin 1 - Joystick/5 way button using Peter's existing 5 way button pcb.
Pin 2 - Current sensor, it will need a voltage divider to scale the 5v sensor to 3.3v.
Pin 3 thru 9 - Analog tempurature sensors. No 1 wire support (yet) for the DS18B20 temp sensors.
Pin 10 - Piezo buzzer (pins 1-10 also provide digital i/o at 3.3v)

Pins 11 - 14 can be configured to count, measure frequency or pulse duration.
Pins 15 - 16 and 19 - 20 can be configured as COM1 and COM2 respectively
Pins 10 - 20 can be configured as 5v tolerant digital i/o


Pin 11 - Vehicle speed sensor. I am planning to count pulses per second to calculate speed and distance instead of pulse duration.
Pin 12 - RPM (optional, I don't need this input as my controller handles this)
Pin 13 - Ignition switch input. I am thinking that this could be used to tell the MM to save data and shutdown when ign switched off. Maybe even to select which program to load, DRIVE.BAS or CHARGE.BAS
Pin 14 - COM1 output select relay. The Drive program will connect COM1 to my controller, the Charge program to the radio TX.
Pin 15 - COM1 RX
Pin 16 - COM1 TX
Pin 17 - Charger cutback
Pin 18 - Mains relay for charger
Pin 19 - COM2 RX Master bus in, this may require hardware inverting of the signal due to MM limitations
Pin 20 - COM2 TX Slave bus out

There are still some functions required. The interface board will need the watchdog pic but as the MM handles timing functions easily we don't need the one second tick from the watchdog anymore. As for the watchdog pulses, it should be possible to connect the watchdog to the master bus in. This frees up one of the 20 i/o pins. The MCLR pin on the MM is availible on the ICSP header so the watchdog can connect to that for resets. And finally there is a sound output on the MM. This can also provide a PWM signal that operates in the background. I am thinking this would be ideal for a fuel gauge driver. 8) I am not worrying about providing a logging output to a pc as that can be done on the SD card.

I will start drawing up a schematic for the interface board as and when time permits. Have I missed out any critical items in the list above?
Greg Fordyce

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

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

Re: Maximite Master

Postby GregsGarage » Sun Oct 16, 2011 12:01 am

I've got my Maximite SM1 from Dontronics and have been exploring it's features and doing a bit of coding. I have adapted one of the sample programs GRAPH.BAS to a simple BMS display. At the moment it just creates fake cell voltages using the RND() function. Heres a screen shot
image1.jpg
image1.jpg (13.19 KiB) Viewed 14384 times


And the code;

Code: Select all

100 ''''''''''''''''''''''''''''''''''''''''''''
110 ' GRAPH48.BAS
120 ' Demonstration program showing the ability
130 ' to graph and display BMS data.
140 ' Cell voltages are simulated with
150 ' random numbers.
160 '
170 '''''''''''''''''''''''''''''''''''''''''''
180 '
190 DIM barval(48)
200 DIM cellV(48)
210 CLS
220 width = MM.HRES - margin
230 height = 100
240 margin = 10
250 '
260 ' parameters for the bar graphs
270 bx = margin : by = MM.VRES-10
280 dx = bx : dy = by
290 GOSUB 620 ' draw the axies for the bar graph
300 '
310 TIME$ = "0:0:0" ' Zero the clock
320 FONT 2
330 '
340 HiV=0 : LoV=5 : PackV=0
350 FOR I = 1 TO 48
360 ' Generate random cell voltage values
370  cellV(I) = RND()+2.5
380 IF CellV(I) < LoV THEN
390 LoV = CellV(I) : LoCell = I : ENDIF
400 IF CellV(I) > HiV THEN
410 HiV = CellV(I) : HiCell = I : ENDIF
420 PackV = PackV + CellV(I)
430 NEXT i
440 LOCATE 0,0
450 ' Display cell and pack values
460 PRINT FORMAT$(PackV," Pack %4.1fV   ")TIME$
470 PRINT " High cell "FORMAT$(HiCell,"[%2.0f]");
480 PRINT "    "FORMAT$(HiV,"%3.2f")
490 PRINT "  Low cell "FORMAT$(LoCell,"[%2.0f]");
500 PRINT "    "FORMAT$(LoV,"%3.2f")
510 ''''''''''draw the bar graphs''''''''''
520 FOR j = 1 TO 48
530  barval(j) = (cellV(J)-2)*50
540  st = 6*(j - 1) + bx
550  LINE(st,by)-(st+3,by-barval(j)),1,bf
560  LINE (st,by-barval(j))-(st+3,by-height),0,bf
570 NEXT j
580 IF INKEY$="S" THEN SAVEBMP "image1"
590  PAUSE 200
600 GOTO 340
610 '
620 '''' Subroutine to draw the graph axies '''''
630 'CLS
640 LINE (dx,dy)-(dx, dy - height), 1
650 ' Draw the vert line
660 LINE (dx,dy)-(dx + Width ,dy), 1 
670 ' Draw the horiz line
680 FOR i=0 TO 33 'This loop draws the tick marks
690  h = dy - (height / 33) * i
700  t = dx - 5
710  IF i MOD 5 = 0 THEN t = dx-8 
720  ' Longer tick mark if unit of 0.5V
730  IF i MOD 10 = 0 THEN
740  ' Special mark for a unit of 1V
750    LOCATE dx - 42, h - 3
760    PRINT LEFT$(FORMAT$(i/10,"%f"),3);"V";
770    ' Label the tick mark
780    t = dx - 15
790   ENDIF
800  LINE (dx, h)-(t, h), 1
810  ' Draw the tick mark
820 NEXT i
830 RETURN


Next step will be to try and get it working with the slaves.
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: Maximite Master

Postby retepsnikrep » Sun Oct 16, 2011 7:27 am

I like that Greg. Goodbye master board V3 hello Maximite master V1 :)

How many cells can it graph max? I have 50 in my cars.
Is that using the rca or vga output.
Pic of your little screen?
Does it do floating point maths?

I might be tempted to forget the watchdog for the time being.
A little daughter interface board with all the signal conditioning isolation stuff on and the watchdog pic might be a good add on. You just need a simple potential divider for the current sensor.

The critical bit will be the serial comms for the slave/master bus as you say hardware inversion may be reqd. A simple transistor and pull/down resistor very easy.
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: Maximite Master

Postby GregsGarage » Sun Oct 16, 2011 10:14 am

I am using the PAL output which gives 304x216 pixels (vga at 480x432 and 80x36 characters is also supported). So it can easily handle many more slaves by adjusting the bar graph size. I have room to add 2 more cells to the graph as it stands by losing the graduations on the left. The font shown in the screen shot is FONT 2, a double size font which should be readable on the 3.5 inch display. This gives 23x10 character display. FONT 1 is 50x18 characters and isn't readable on the 3.5 inch, but is mostly readable on a 7 inch lcd.

Floating point maths at 32 bits is supported and in fact MMBasic only has 2 variable types, float and string. At 80mhz it is very quick even though it is interpreted rather than compiled. Being interpreted means that development is very quick. Spot a bug, edit the line and type run to see if it works. Not having to compile a hex file and burn to the pic is a real timesaver. And all the development can be done directly on the MM. 8)

I will get some pics of the MM uploaded, but it may not be today. The screen shot above was created in line 580 of the program. This demonstrates how easy the MM makes working with the SD card. I also have made a small configuration program that asks for pack parameters, number of cells, etc and saves the info to a file. The program then loads and runs a different program that read the file and displays the info you just entered. Another thing, using the INKEY$ command buffers key presses. You will notice that line 590 is a 200ms delay. I set this to 2000 (2 sec) and pressed the "S" key while it was paused and it saved the image next time around the program loop. This gives me another idea, instead of using your button routine we could just use a keyboard for input. A USB number pad could be used or we could make a button using a pic to emulate a ps2 keyboard and appropriate key codes. A quick google came up with some code examples for this, including some pbp code. This would free up another of the 20 i/o pins on the MM.
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: Maximite Master

Postby retepsnikrep » Sun Oct 16, 2011 5:14 pm

Ok Ok I'll have to get one :wink: do they have a UK supplier.

What eactly did you order and what does it look like cost after postage customs etc?

Must be quite a few ps2 keyboard emulators around how small do ps2 keypads get?
We only need one adc input for our button thing.

I think it has enough I/O not to worry too much.

Edit

I've ordered one as well now :roll:

Edit

The Maximite manual 2.6 does list I2C device support so the temp sensors may be OK. Saving a few inputs :D

Just to get an idea how much of the 128k did your example program take up?
I appreciate we can chop the program into sections but still interested.
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: Maximite Master

Postby GregsGarage » Sun Oct 16, 2011 10:40 pm

I was going to say I've got a spare SM1 I could send you, but if you've already ordered it...

The MEMORY command returns;
2kB ( 6%) Program memory used
1kB ( 7%) Variable memory used
0kB ( 1%) Array and string memory used

As far as the temp sensors go, at the moment they aren't supported. The Dallas 1 wire protocol of the sensors is different than the i2c protocol. But version 2.7 is due in a couple of weeks and the new features are being kept a secret as it will be launched in the Aussie mag Silicon Chip and he doesn't want to upset the publishers. So we may get 1 wire support yet. Another possibilty is a onboard RTC. The SM1 pcb is laid out for it, just needs software support. We will have to wait and see.

The idea of chopping the programs into sections was mainly to make coding easier. the charging program doesn't need to worry about the controller and the drive program doesn't need to worry about balancing the cells, etc. I am sure we could fit it all into one big program, but smaller programs are easier to follow and debug.

I've included some fuzzy pictures of my setup, sorry about the picture quality, snapped them with the built in webcam. First one shows my desktop setup. And inside the box is a breadboard for prototyping. I just need to make up a adapter so that I can plug in the 26 pin cable to the breadboard.
Attachments
2011-10-16-232643.jpg
Inside the box
2011-10-16-232643.jpg (74.71 KiB) Viewed 14369 times
2011-10-16-232804.jpg
Maximite "Desktop"
2011-10-16-232804.jpg (46.69 KiB) Viewed 14369 times
Greg Fordyce

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

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

Re: Maximite Master

Postby GregsGarage » Sun Oct 16, 2011 10:53 pm

Here's a snapshot of my SDCard. Not much at the moment but this may be a good way to release updates. I also have a EXAMPLES folder of other programs I have collected and use for ideas, but didn't include them here. This is a good place to start http://geoffg.net/Downloads/Maximite/MMBasic%20Library%20V1.5.zip

The MM supports up to 2Gb SD cards and I think larger ones are o.k. as well, but you only can access the first 2Gb. You could keep schematics and other documentation on there as well even though the MM can't access it.
Attachments
161011.zip
Snapshot of Greg's SDCard on 16-10-11
(16.84 KiB) Downloaded 547 times
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: Maximite Master

Postby retepsnikrep » Sun Oct 16, 2011 11:48 pm

I prob won't be doing much with it until after Christmas as I have a major OBDII project underway on the IC site, but I look forward to your progress and will chip in with stuff.

My first BMS using polled relays :shock: was written in GW Basic and had some nice bargraphs and other relevant code I'll try and find the source and upload 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.

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

Re: Maximite Master

Postby retepsnikrep » Wed Oct 19, 2011 5:18 am

For what it's worth the guts of my first BMS program for GWBasic and used a Velleman I/O K8000 board and a pic of my old display from 2004!!

OldBmsDisplay.jpg
OldBmsDisplay.jpg (110.72 KiB) Viewed 14346 times


REM *******************************************************************
REM SolarVan Control Program Version 2.0 Copyright Peter Perkins 010604
progstart:

REM SET ARRAYS AND VARIABLES
DIM cell(30, 240), bms(30), delay(30), ampstore(30)
count = 0: col = 4: soldata = 0: limit = 160: potlimit = 0: z = 0: ah = 0

REM PWRLEFT IS SET TO 100AH INITIALLY SUGGESTED MAX IS 150AH
pwrleft = 150: kw = 0

REM CONFIG VELLEMAN BOARD
Selecti2cprinterport 1: ConfigIOchipAsOutput 0: ConfigIOchipAsInput 1

REM CONFIG SCREEN FOR 640x480 VGA MODE
SCREEN 12: CLS

REM READ MILEAGE DATA FROM FLOPPY
OPEN "MILEAGE.DAT" FOR INPUT AS #1
total = VAL(INPUT$(5, 1))
CLOSE

REM SET UP SCREEN WITH LI-ION METER SCALES
GOSUB drawlion

REM ***********************************************************************
REM PROGRAM LOOPS AND REDRAWS SCREEN ONCE A SECOND APPROX
mainscreen:
LOCATE 2, 1
PRINT " SV * Trip"; INT(miles); "miles * Total"; INT(total + miles); "miles *";
PRINT INT(counter / 60); "Mins * Test Cell"; count; "* Data"; soldata
PRINT : z = mph * 6.66: y = 2: c = 14: GOSUB hbargraph
PRINT " 00^^05^^10^^15^^20^^25^^30^^35^^40^^45^^50^^55^^60 Speed MPH "; mph; " "
PRINT : z = rpm / 15: y = 4: c = 2: GOSUB hbargraph
PRINT " 00^^05^^10^^15^^20^^25^^30^^35^^40^^45^^50^^55^^60 Motor RPM "; rpm; " "
PRINT : z = ad%(3) * 1.77: y = 6: c = 3: GOSUB hbargraph
PRINT " 00^^^^50^^^100^^^150^^^200^^^250^^^300^^^350^^^400 Motor Amps "; CINT(z); " "
PRINT : camp = ad%(4) * .2225: z = camp * 10: y = 8: c = 4: GOSUB hbargraph
PRINT " 00^^^^05^^^^10^^^^15^^^^20^^^^25^^^^30^^^^35^^^^40 Charge Amps "; CINT(camp); " "
PRINT : btemp = 60 - (ad%(2) / 4): z = btemp * 6.66: y = 10: c = 5: GOSUB hbargraph
PRINT " 00^^05^^10^^15^^20^^25^^30^^35^^40^^45^^50^^55^^60 Battery Temp C"; CINT(btemp); " "
PRINT : z = soc * 4: y = 12: c = 6: GOSUB hbargraph
PRINT " E^^^10^^^20^^^30^^^40^^^50^^^60^^^70^^^80^^^90^^^F Charge State %"; soc; " "
PRINT : z = kw * 20: y = 14: c = 9: GOSUB hbargraph
PRINT " 00^^02^^^04^^^06^^^08^^^10^^^12^^^14^^^16^^^18^^20 Motor Power KW"; LEFT$(STR$(kw), 5); " "

minidist = 0: rpmflag = 0: rpmcounter = 0: starttime$ = TIME$

REM ***********************************************************************
REM FAST PROGRAM LOOP BELOW MAX SPEED REQD TO LIMIT CURRENT AND COUNT RPM
waitforkey:
readiochip 1: ReadADchip (0)

REM NEXT TWO LINES ARE MOTOR RPM COUNTER
IF io%(12) = 1 AND rpmflag = 1 THEN rpmflag = 0: rpmcounter = rpmcounter + 1
IF io%(12) = 0 AND rpmflag = 0 THEN rpmflag = 1

REM MOTOR CURRENT CONTROLLER ROUTINE ECONOMY/NORMAL/PERFORMANCE MODES
motoramps = ad%(3) * 1.77
IF motoramps >= limit THEN GOSUB reduceamps
IF motoramps < limit THEN GOSUB increaseamps

REM LOOP BELOW HAPPENS ONCE A SECOND
IF starttime$ = TIME$ GOTO waitforkey
GOSUB measurecell
GOSUB speedo

REM IF BUTTON (A) PRESSED CHANGE POWER MODE 60-160-400A
IF io%(10) = 1 THEN GOSUB changemode

REM IF BUTTON (B) PRESSED THEN ENTER EXTENDED DATA ANALYSIS MODE
IF io%(11) = 1 THEN GOTO dataanalysis

REM IF RED BUTTON PRESSED SAVE DATA AND EXIT PROGRAM
REM NOTE ON EXIT DOS BATCH FILE WILL RENAME "CELLDATA" TO TODAYS DATE
IF io%(9) = 1 THEN
GOSUB writesoldata: END
END IF

REM CALCULATE MOTOR POWER IN KW
kw = (motoramps * packvoltage) / 1000

GOTO mainscreen

REM *******************************************************************
REM count increments from 0 to 30 as each cell is measured
REM When count = 30 battery pack values are calulated and displayed

measurecell:
IF count = 0 THEN
setiochannel (1): setiochannel (2): cleariochannel (2): cleariochannel (1)
setiochannel (2): cleariochannel (2): count = count + 1: RETURN
END IF

REM ***********************************************************************
REM 30 SECOND LOOP ALL CELLS HAVE BEEN TESTED WHEN COUNT=31
IF count = 31 THEN
packvoltage = 0: highest = 0: lowest = 5: count = 0: col = 4: average = 0
FOR a = 1 TO 30: packvoltage = packvoltage + cell(a, soldata)
IF highest <= cell(a, soldata) THEN highest = cell(a, soldata)
IF lowest >= cell(a, soldata) THEN lowest = cell(a, soldata)
average = average + cell(a, soldata)
NEXT a
average = average / 30: diff = highest - lowest
LOCATE 22, 68: PRINT "PV>"; LEFT$(STR$(packvoltage), 6); " "
LOCATE 23, 68: PRINT "HC> "; LEFT$(STR$(highest), 5); " "
LOCATE 24, 68: PRINT "LC> "; LEFT$(STR$(lowest), 5); " "
LOCATE 25, 68: PRINT "AV> "; LEFT$(STR$(average), 5); " "
LOCATE 26, 68: PRINT "DF> "; LEFT$(STR$(diff), 5); " "

REM ONBOARD/SOLAR CHARGER AND BATTERY HEATER/COOLER STATUS CONTROL
LOCATE 20, 1

REM SOLAR CHARGER CONTROL
IF packvoltage < 124 AND highest < 4.15 AND btemp < 50 THEN
setiochannel (6): PRINT " Solar Charge On! ";
END IF

IF packvoltage > 127.5 OR highest > 4.27 OR btemp > 50 THEN
cleariochannel (6): PRINT " Solar Charge Off ";
END IF

REM MAINS CHARGER CONTROL
IF packvoltage < 124 AND highest < 4.1 AND btemp < 50 AND io%(16) = 0 THEN
setiochannel (7): PRINT " * AC Charge On! ";
END IF

IF packvoltage > 127.5 OR highest > 4.26 OR btemp > 50 OR io%(16) = 1 THEN
cleariochannel (7): PRINT " * AC Charge OFF ";
END IF

REM BATTERY HEATER CONTROL
IF btemp < 20 THEN
setiochannel (8): PRINT " * Bat Heater On!"
END IF

IF btemp > 25 THEN
cleariochannel (8): PRINT " * Bat Heater Off"
END IF

REM FUEL GAUGE CALCULATE AH USAGE/SOC AND DISPLAY
FOR a = 1 TO 30
ah = ah + ampstore(a)
NEXT a
ah = CINT(ah / 30): IF ah = 0 THEN ah = .5
pwrleft = (pwrleft - (ah / 120))

REM calculate miles remaining
pwrused = 150 - pwrleft
pwrpermile = pwrused / (miles + .0001)
milesleft = INT(pwrleft / pwrpermile)

LOCATE 18, 1
PRINT " Est"; milesleft; "miles *"; INT(pwrleft); "ah *"; INT((pwrleft / ah) * 60);
PRINT "mins remaining at"; ah; "ah drain "
cell(0, soldata) = ah: soc = INT((100 / 150) * pwrleft)

REM BMS ROUTINE NOT IMPLEMENTED YET
REM GOSUB bmsroutine

soldata = soldata + 1: RETURN
END IF

REM CELLDATA FOR EACH 2 HOURS IS RECORDED TO DISK
IF soldata = 240 THEN GOSUB writesoldata

REM READ THE CELL VOLTAGE AND DISPLAY USING BARGRAPH THEN INC CELL COUNTER
ReadADchip (0): cell(count, soldata) = .017647 * ad%(1)
bar = cell(count, soldata)
setiochannel (2): cleariochannel (2): GOSUB bargraph

REM STORE MOTOR CURRENT IN AMPSTORE ARRAY THEN INC CELL COUNTER & RETURN
ampstore(count) = motoramps
count = count + 1: RETURN

REM****************************************************************
REM Array bms (30) balancer status for each cell 1=on 0=off
REM Array delay(30) balancer timer status for each cell 120=1 hour

bmsroutine:
FOR a = 1 TO 30
IF cell(a, soldata) > 4.24 AND delay(a) = 0 AND btemp < 50 THEN
bms(a) = 1: delay(a) = 120
END IF

IF cell(a, soldata) < 4.23 AND delay(a) <> 0 AND btemp < 50 THEN
bms(a) = 1: delay(a) = delay(a) - 1
END IF

IF delay(a) = 0 OR btemp > 50 OR cell(a, soldata) < 3.8 THEN
bms(a) = 0: delay(a) = 0
END IF

NEXT a

FOR clock = 30 TO 1 STEP -1
IF bms(clock) = 1 THEN setiochannel (3) ELSE cleariochannel (3)
setiochannel (4): cleariochannel (4): NEXT clock
setiochannel (5): cleariochannel (5): RETURN

REM***************************************************************
REM Display BarGraph with Colour of bar depending on voltage
REM Also displays cell voltage in figures in bar itself!
REM This routine needs calling every time a cell is measured!
REM Variable ("bar" needs loading with cell voltage when called)
REM Variable ("col" is cursor column counter initial value 4)

bargraph:
c = 5: REM Purple Zone <2.8 Volts
IF bar > 2.8 THEN c = 14: REM Yellow Zone 2.8 to 3.4 Volts
IF bar > 3.4 THEN c = 2: REM Green Zone >3.4 Volts
IF bar > 4.27 THEN c = 4: REM Cell overvoltage Red Zone >4.27 Volts
length = 460 - (bar * 30): barwidth = 16 * count: FOR bardraw = 7 TO 16
LINE (bardraw + barwidth, 460)-(bardraw + barwidth, 325), 0
LINE (bardraw + barwidth, 460)-(bardraw + barwidth, length), c
NEXT bardraw: z$ = STR$(bar): LOCATE 26, col: PRINT MID$(z$, 2, 1)
LOCATE 27, col: PRINT MID$(z$, 3, 1): LOCATE 28, col: PRINT MID$(z$, 4, 1)
col = col + 2: RETURN

REM ***********************************************************************
speedo:
rpm = rpmcounter * 120: dist = dist + rpmcounter
minidist = minidist + rpmcounter / 2391
miles = dist / 2391
mph = INT((60 / 4782) * rpm)
counter = counter + 1: starttime$ = TIME$: RETURN

REM ***********************************************************************
REM WRITE 2 HOURLY CELL DATA TO DISK
writesoldata:
LOCATE 19, 45: PRINT "Saving Cell Data"
OPEN "CELLDATA.DAT" FOR OUTPUT AS #1
FOR c1 = 1 TO 240: FOR c2 = 0 TO 30
WRITE #1, cell(c2, c1): NEXT c2: NEXT c1
CLOSE : soldata = 0

REM WRITE MILEAGE DATA TO DISK
writemileage:
OPEN "MILEAGE.DAT" FOR OUTPUT AS #1
total = total + minidist: PRINT #1, STR$(total)
CLOSE : minidist = 0
LOCATE 19, 45: PRINT " "
RETURN

REM ***********************************************************************
REM HORIZONTAL BARGRAPH ROUTINE FOR SPEED,RPM,AMPS ETC
hbargraph:
REM Var Z = Length needs setting in range 0-400
REM Offset = start of graph on screen Horizontal position
REM Graph is 400 pixels long calculate length on screen vs voltage
IF z < 0 OR z > 400 THEN z = 0
offset = 8: length = offset + z
barwidth = 16 * y
FOR bardraw = 4 TO 13
LINE (offset, bardraw + barwidth)-(410, bardraw + barwidth), 0
LINE (offset, bardraw + barwidth)-(length, bardraw + barwidth), c
NEXT bardraw: RETURN

REM ***********************************************************************
REM DRAW LION SCALES ON SCREEN
drawlion:
REM Draw scale on li-ion bargraphs.
LOCATE 21, 64: PRINT "<"
LOCATE 22, 64: PRINT "4"
LOCATE 23, 64: PRINT "<"
LOCATE 24, 64: PRINT "3"
LOCATE 25, 64: PRINT "<"
LOCATE 26, 64: PRINT "2"
LOCATE 27, 64: PRINT "<"
LOCATE 28, 64: PRINT "1"
LOCATE 21, 2: PRINT ">"
LOCATE 22, 2: PRINT "4"
LOCATE 23, 2: PRINT ">"
LOCATE 24, 2: PRINT "3"
LOCATE 25, 2: PRINT ">"
LOCATE 26, 2: PRINT "2"
LOCATE 27, 2: PRINT ">"
LOCATE 28, 2: PRINT "1"
LOCATE 28, 67: PRINT "Normal 160A"
RETURN

REM ***********************************************************************
REM MOTOR CURRENT CONTROLLER ROUTINE
reduceamps:
IF potlimit <= 0 THEN RETURN
clearDACchannel (2): setDACchannel (3): clearDACchannel (3)
potlimit = potlimit - 1: RETURN

increaseamps:
IF potlimit >= 50 THEN RETURN
setDACchannel (2): setDACchannel (3): clearDACchannel (3)
potlimit = potlimit + 1: RETURN

REM ***********************************************************************
REM CHANGES POWER MODE MOTOR CURRENT LIMIT 60-160-400A
changemode:
LOCATE 28, 67

IF limit = 60 THEN
limit = 160: PRINT "Normal 160A": RETURN
END IF

IF limit = 160 THEN
limit = 400: PRINT "Power! 400A": RETURN
END IF

IF limit = 400 THEN
limit = 60: PRINT "Economy 60A": RETURN
END IF

GOTO changemode

REM ***********************************************************************
REM EXTENDED DATA ANALYSIS MODE
dataanalysis:
packvana = 0: highcell = 0: lowcell = 5: avecell = 0: CLS
PRINT " Solar Van Extended Data Analysis Mode. Ver 1.00 010604 P.Perkins"

FOR a1 = 1 TO 30: FOR a2 = 1 TO 240
IF highcell <= cell(a1, a2) THEN highcell = cell(a1, a2)
IF lowcell >= cell(a1, a2) THEN lowcell = cell(a1, a2)
avecell = avecell + cell(a1, a2)
NEXT a2
avecell = avecell / soldata
PRINT "Cell"; a1,
PRINT "HV>"; LEFT$(STR$(highcell), 5); " ";
PRINT "LV>"; LEFT$(STR$(lowcell), 5); " ";
PRINT "AV>"; LEFT$(STR$(avecell), 5); " ";
PRINT "DF>"; LEFT$(STR$(highcell - lowcell), 5); " "
NEXT a1

waithere:
readiochip (1)
IF io%(10) <> 1 THEN GOTO waithere:
CLS
GOSUB drawlion
GOTO mainscreen
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: Maximite Master

Postby GregsGarage » Wed Oct 19, 2011 9:04 am

Thanks Peter, had a quick look and it looks good. I will print it off and have a good look.
Greg Fordyce

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


Return to “BMS thread”

Who is online

Users browsing this forum: No registered users and 12 guests