played around with it and got the speedo input and wh/mile calculations working. it should be accurate to 1 mile/hour right now, but i have to test the VSS sender and see if it's supplying 2 pulses per revolution, or four. might also mount the VSS to the motor tailshaft instead of to the drive shaft: it's a single speed transmission with a 22:64 ratio, so it should be about 3 times more accurate reading from the motor instead of the drive shaft.
turns out the vehicle's stock gauges don't work at all without the onboard computer that came with the vehicle, so i'll probably end up not using them at all. instead, i was thinking i could re-allocate some space on the screen, and make the numbers bigger for the speedometer.
i'll have to go look and see if i can find greg's "big numbers" code and see if it will do it
Old BMS Software Thread
Moderators: GregsGarage, retepsnikrep
-
- Posts: 100
- Joined: Sun Apr 03, 2011 7:41 pm
speedometer fix
the speed sensor pin needs to be configured slightly differently in order for the speed sensing features to work. here's the changes we made
this is the block of code that was changed,
the specific line is:
the old line was:
hope this helps!
this is the block of code that was changed,
Define OSC 8 'Set PicBasic Pro processor speed to 8 Mhz (Must match oscillator value)
OSCCON = %01110101 'Internal 8 mhz Osc and stable
CM1CON0 = 0 'Comparator Off
CM2CON0 = 0 'Comparator Off
T1CON = %00110001 'Enables and Starts Timer1 prescale 1:8 internal clock source 262ms at 8mhz
TRISA = %11111111 'SET PORTA AS INPUTS
TRISB = %00000000 'SET PORTB AS OUTPUTS
TRISC = %10011111 'SET PORTC AS INPUTS EXCEPT PORTS C5,C6
ANSEL = %00001111 'SET INPUTS AN0-AN3 AS ANALOG INPUTS
ANSELH = %00000000 'Disable PortB AD
ADCON0 = %01000001 'SETUP ADC CONVERTER MODULE FOSC/8 & ENABLE ADC MODULE on AD0
ADCON1 = %10000000 'SETUP ADC RIGHT JUSTIFY SET REFV to VDD & VSS
the specific line is:
T1CON = %00110001 'Enables and Starts Timer1 prescale 1:8 internal clock source 262ms at 8mhz
the old line was:
T1CON = %00111001 'Enables and Starts Timer1 prescale 1:8 internal clock source 262ms at 8mhz
hope this helps!
-
- Posts: 100
- Joined: Sun Apr 03, 2011 7:41 pm
Re: Old BMS Software Thread
oops! we used up all of the space on the pic....
probably the right thing to do is to go through and tidy it all up and delete stuff it doesn't need, but most of the stuff is needed for making the screen look nice.
wonder if there's another pic that would be compatible with more memory?
probably the right thing to do is to go through and tidy it all up and delete stuff it doesn't need, but most of the stuff is needed for making the screen look nice.
wonder if there's another pic that would be compatible with more memory?
- retepsnikrep
- Posts: 1387
- Joined: Sat May 26, 2007 4:50 pm
- Location: North Yorkshire England
- Contact:
Re: Old BMS Software Thread
'** PIC 16F886 Pinouts FLASH 8192 (words) SRAM 368 (bytes) EEPROM 256 (bytes) **
'** PIC 18F2620 Pinouts FLASH 32768 (words) SRAM 3968 (bytes) EEPROM 1024 (bytes) **
This shows the compatible chips however significant changes would be needed to the CONFIG section for the 18F2620 as the two pics have different settings but same pinout and functions. Please post your results details of Config changes.
'** PIC 18F2620 Pinouts FLASH 32768 (words) SRAM 3968 (bytes) EEPROM 1024 (bytes) **
This shows the compatible chips however significant changes would be needed to the CONFIG section for the 18F2620 as the two pics have different settings but same pinout and functions. Please post your results details of Config changes.
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.
- hohisilver
- Posts: 114
- Joined: Mon Jan 24, 2011 10:17 pm
- Location: Wells, Somerset
Re: Old BMS Software Thread
I'm using the PIC18F2680 as a drop-in replacement and managed to sort out the config - it's in C but I could let you have the settings if it helps?
Ian.
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
-
- Posts: 100
- Joined: Sun Apr 03, 2011 7:41 pm
Re: Old BMS Software Thread
thanks guys! i think i'll order up some new pics. at least that would give extra overhead in the future, if nothing else.
i think the config lines you're using would be VERY helpful! my buddy that's handling most of the programming is actually a lot more familiar with C so i'm sure he will be able to sort out what needs to be changed between the two to make it work.
i'll post some pics of my wiring nightmare in the hardware section
i think the config lines you're using would be VERY helpful! my buddy that's handling most of the programming is actually a lot more familiar with C so i'm sure he will be able to sort out what needs to be changed between the two to make it work.
i'll post some pics of my wiring nightmare in the hardware section
- hohisilver
- Posts: 114
- Joined: Mon Jan 24, 2011 10:17 pm
- Location: Wells, Somerset
Re: Old BMS Software Thread
These are my config settings; I may have reassigned some pins from the original PBP code so they may not be totally correct but at least you might avoid some of the "trial-and-error" I had to go through. I was intending to fit a ceramic resonator at some point hence the "#if" but I haven't done much on this project for a while so mine's still running at 8MHz internal. If you fit a resonator you'll need to reassign the pins as we are currently using them for other purposes:
#if _XTAL_FREQ == 8000000 // 8MHz internal
__CONFIG(1, FCMEN_OFF & IESO_OFF & OSC_IRCIO67);
#else
__CONFIG(1, FCMEN_OFF & IESO_OFF & OSC_HS);
#endif
__CONFIG(2, BOREN_BOHW & BORV_3 & PWRT_OFF & WDT_OFF & WDTPS_4096);
__CONFIG(3, PBADEN_OFF & LPT1OSC_OFF & MCLRE_ON);
__CONFIG(4, LVP_OFF & STVREN_OFF & BBSIZ_1024 & XINST_OFF & DEBUG_OFF);
__CONFIG(5, CP0_OFF & CP1_OFF & CP2_OFF & CP3_OFF & CPB_OFF & CPD_OFF);
__CONFIG(6, WRT0_OFF & WRT1_OFF & WRT2_OFF & WRT3_OFF & WRTC_OFF & WRTB_OFF & WRTD_OFF);
__CONFIG(7, EBTR0_OFF & EBTR1_OFF & EBTR2_OFF & EBTR3_OFF & EBTRB_OFF);
#if _XTAL_FREQ == 8000000 // 8MHz internal
__CONFIG(1, FCMEN_OFF & IESO_OFF & OSC_IRCIO67);
#else
__CONFIG(1, FCMEN_OFF & IESO_OFF & OSC_HS);
#endif
__CONFIG(2, BOREN_BOHW & BORV_3 & PWRT_OFF & WDT_OFF & WDTPS_4096);
__CONFIG(3, PBADEN_OFF & LPT1OSC_OFF & MCLRE_ON);
__CONFIG(4, LVP_OFF & STVREN_OFF & BBSIZ_1024 & XINST_OFF & DEBUG_OFF);
__CONFIG(5, CP0_OFF & CP1_OFF & CP2_OFF & CP3_OFF & CPB_OFF & CPD_OFF);
__CONFIG(6, WRT0_OFF & WRT1_OFF & WRT2_OFF & WRT3_OFF & WRTC_OFF & WRTB_OFF & WRTD_OFF);
__CONFIG(7, EBTR0_OFF & EBTR1_OFF & EBTR2_OFF & EBTR3_OFF & EBTRB_OFF);
Ian.
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
-
- Posts: 100
- Joined: Sun Apr 03, 2011 7:41 pm
Re: Old BMS Software Thread
thanks! we are gonna try to implement this as soon as the new pics get here...friday hopefully
- retepsnikrep
- Posts: 1387
- Joined: Sat May 26, 2007 4:50 pm
- Location: North Yorkshire England
- Contact:
Re: Old BMS Software Thread
Here is a config I have written for the 18F2620, I have not tested it.
'------------------------------ General 18F2620 configuration --------------------------
#CONFIG
__CONFIG _CONFIG1H, _OSC_INTIO67_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOREN_OFF_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_OFF_3H
__CONFIG _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
#ENDCONFIG
'------------------------------ General 18F2620 configuration --------------------------
#CONFIG
__CONFIG _CONFIG1H, _OSC_INTIO67_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOREN_OFF_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_OFF_3H
__CONFIG _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
#ENDCONFIG
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.
- retepsnikrep
- Posts: 1387
- Joined: Sat May 26, 2007 4:50 pm
- Location: North Yorkshire England
- Contact:
Re: Old BMS Software Thread
Improving Slave Cell Voltage Resolution.
http://www.darreltaylor.com/DT_Analog/
Interesting method of getting 12bit or higher resolution from the 10bit adc.
As the slaves sit around most of the time doing nothing anyway it might be a good idea to move to the 12bit method. Thoughts?
http://www.darreltaylor.com/DT_Analog/
Interesting method of getting 12bit or higher resolution from the 10bit adc.
As the slaves sit around most of the time doing nothing anyway it might be a good idea to move to the 12bit method. Thoughts?
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.
Who is online
Users browsing this forum: No registered users and 12 guests