#REM Honda Insight MK1 RS485 BATTSCI Interface System. By Peter Perkins Picaxe 18X PIC16F88 - 290909 - www.150mpg.co.uk - V01 Beta Fake BCM! ******************************** Disclaimer ********************************** These modules carry no warranty or guarantee of any kind! They are used at your own risk, and I make no claims as to their suitability for a particular function. Prospective users must evaluate the system before using it, and no liability will be entertained by myself in any shape or form whatsoever. The modules and software have been produced at low cost for the benefit of the EV & electronic community. The software is available free via the internet. Users may modify or adapt the system as they see fit. If you are not fully competent to work on potentially lethal battery systems and high voltages, then do not experiment with or use this system. Be aware that vehicle modifications can lead to invalidated insurance and warranty issues. You the end user remain fully liable for any modifications made to your vehicle. ***************************** Picaxe 18X Pinout ****************************** Top _____ (Adc Keys Input) Input 2 -01| ^ |18- Input 1 (Not Used) (Program Out) Txd -02| |17- Input 0 (BMS Serial In) (Program In) Rxd -03| |16- Input 7 (Not Used) (Reset) Reset -04| P |15- Input 6 (Not Used) (- Supply) Gnd 3 -05| 1 |14- +V (+ Supply) (BMS Serial Out) Output 0 -06| 8 |13- Output 7 (Not Used) (Not Used) Output 1 -07| X |12- Output 6 (Not Used) (Chip 1 RO Pin1) RS485 In Rxd -08| |11- RS485 Out Txd (Chip 2 DI Pin4) (Chip 1 RE Pin2) Output 3 -09| |10- Output 4 (Chip 2 DE Pin3) ----- **************************** Other IC's On Pcb ******************************** ****** BATTSCI RS485 Line Driver Linear 1487 Pinout Chip 1 Rxd from BCM ******* Top _____ (RO Rxd Output to Picaxe) RO -1| ^ |8- +V (+ Supply) (RE Rxd Enable Tied Low) RE -2| 4 |7- B (RS485 Bus B) (DE Txd Enable Tied Low) DE -3| 8 |6- A (RS485 Bus A) (DI Txd Input Not Used) DI -4| 5 |5- Gnd (- Supply) ----- ******** BATTSCI RS485 Line Driver Linear 1487 Pinout Chip 2 Txd to MCM ******* Top _____ (RO Rxd Output Not Used) RO -1| ^ |8- +V (+ Supply) (RE Rxd Enable Tied High) RE -2| 4 |7- B (RS485 Bus B) (DE Txd Enable Tied High) DE -3| 8 |6- A (RS485 Bus A) (DI Txd Input from Picaxe) DI -4| 5 |5- Gnd (- Supply) ----- ************************ RS485 Module Specification *************************** Board Supply Voltage 8.00-30.00V DC or as limited by 5.00V 78L05 regulator CPU Supply Voltage 5.00V CPU Speed 8mhz with internal resonator (Pic limit 8mhz) Average Board Supply Current at 12.00v <100ma ******************************************************************************* ********************** Program Size 129 out of 2048 Bytes ********************* ******************************************************************************* #ENDREM #picaxe 18x ;Set Picaxe type 18X for compiler/editor `Variables Constants and I/O definitions `Note Global variables must be preserved throughout the program `Note Local variables may be used at will within subroutines `Variables 8bit (Byte) symbol Char = b0 ;Character to be Txd/Rxd loaded into byte variable Char (b0) symbol Status = b1 ;Status register for Txd/Rxd 18X Asuart in byte variable Status (b1) symbol Counter1 = b2 ;Counter 0-255 (byte b2) symbol Counter2 = b3 ;Counter 0-255 (byte b3) symbol RCSTA_INIT = b4 ;Transmit Status Register (byte b4) symbol TXSTA_INIT = b5 ;Transmit Status Register (byte b5) `Constants ; Ports SYMBOL Shadow_TRISB = $AE ; Registers PICAXE-18X / 16F88 SFR Definitions SYMBOL PIR1 = $0C SYMBOL RCSTA = $18 SYMBOL TXREG = $19 SYMBOL RCREG = $1A SYMBOL TXSTA = $98 SYMBOL SPBRG = $99 ; TXSTA Bit Masks SYMBOL CSRC = %10000000 SYMBOL TX9 = %01000000 SYMBOL TXEN = %00100000 SYMBOL SYNC = %00010000 SYMBOL BRGH = %00000100 SYMBOL TRMT = %00000010 SYMBOL TX9D = %00000001 SYMBOL CSRC_BIT = bit15 SYMBOL TX9_BIT = bit14 SYMBOL TXEN_BIT = bit13 SYMBOL SYNC_BIT = bit12 SYMBOL BRGH_BIT = bit10 SYMBOL TRMT_BIT = bit9 SYMBOL TX9D_BIT = bit8 ; RCSTA Bit Masks SYMBOL SPEN = %10000000 SYMBOL RX9 = %01000000 SYMBOL SREN = %00100000 SYMBOL CREN = %00010000 SYMBOL ADDEN = %00001000 SYMBOL FERR = %00000100 SYMBOL OERR = %00000010 SYMBOL RX9D = %00000001 SYMBOL SPEN_BIT = bit15 SYMBOL RX9_BIT = bit14 SYMBOL SREN_BIT = bit13 SYMBOL CREN_BIT = bit12 SYMBOL ADDEN_BIT = bit11 SYMBOL FERR_BIT = bit10 SYMBOL OERR_BIT = bit9 SYMBOL RX9D_BIT = bit8 ; PIR1 Bit Masks SYMBOL ADIF = %01000000 SYMBOL RCIF = %00100000 SYMBOL TXIF = %00010000 SYMBOL SSPIF = %00001000 SYMBOL CCP1IF = %00000100 SYMBOL TMR2IF = %00000010 SYMBOL TMR1IF = %00000001 SYMBOL ADIF_BIT = bit14 SYMBOL RCIF_BIT = bit13 SYMBOL TXIF_BIT = bit12 SYMBOL SSPIF_BIT = bit11 SYMBOL CCP1IF_BIT = bit10 SYMBOL TMR2IF_BIT = bit9 SYMBOL TMR1IF_BIT = bit8 symbol SPBRG_INIT = 12 ;9600 baud @ 8MHz `Pins used for I/O and designations `*** Digital high/low Outputs *** symbol BmsOut = 0 ;Serial Data Out to BMS on Output 0 (9600,8,N,1) symbol NotUsedOut1 = 1 ;Not Used on Ouput 1 symbol RxdIn = 2 ;(Asuart RO Pin1) RS485 In Rxd (9600,8,E,1) Chip 1 symbol NotUsedOut3 = 3 ;Not Used on Ouput 4 symbol NotUsedOut4 = 4 ;Not Used on Ouput 5 symbol TxdOut = 5 ;(Asuart DI Pin4) RS485 Out Txd (9600,8,E,1) Chip 2 symbol NotUsedOut6 = 6 ;Not Used on Ouput 6 symbol NotUsedOut7 = 7 ;Not Used on Ouput 7 `*** Digital high/low Inputs *** symbol BmsIn = 0 ;Serial Data In from BMS on Input 0 (9600,8,N,1) symbol NotUsedIn1 = 1 ;Not Used on Input 1 symbol NotUsedIn6 = 6 ;Not Used on Input 6 symbol NotUsedIn7 = 7 ;Not Used on Input 7 `*** Analogue ADC Inputs *** symbol Buttons = 2 ;Adc Buttons input on Input 2 ;************************************** Memory Allocations for 18X ******************************************* ;************************************************************************************************************* ;**************** PICAXE-18X 96 Bytes RAM 80 to 127 ($50 to $7F), 192 to 239 ($C0 to $EF) ******************** ;************************************************************************************************************* ;******************************************* Main Eeprom ***************************************************** `****************** Eeprom Data Storage 0-255 bytes (This does not affect program memory) ****************** `Store 30 bytes of METSCI Zero (0) Bar Soc & Zero (0) Assist/Regen Dec data in Eeprom (Start at data byte 0) EEPROM 0,($e6,$40,$5A,$e1,$20,$7f,$e6,$40,$5A,$b4,$00,$4c,$e6,$40,$5A) ;Store data in Eeprom (Start of data byte 0) EEPROM 15,($b4,$00,$4c,$e6,$40,$5A,$b3,$04,$49,$e6,$40,$5A,$b4,$00,$4c) ;Store data in Eeprom (Start of data byte 15) #gosubs 16 ;Set maximum number of 'Gosubs' to 16 ;************************************************************************************************************* Start: ;Initialise Program. setfreq m8 ;Setfreq CPU Freq to 8mhz `Initialise Picaxe 18X onchip AUSART for Txd/Rxd comms at 9600,8,E,1 peek Shadow_TRISB, Char ;Peek Port B Shadow Register Char = Char OR %00000100 ;Set Output 2 as Input whilst leaving others unchanged poke Shadow_TRISB, Char ;Load Shadow Register poke SPBRG, SPBRG_INIT ;Initialise AUSART at baud rate 9600 8mhz TXSTA_INIT = TXEN | TX9 | BIT8 ;Bitwise OR (Sets Async Txd mode, 9 Bit Tx & Parity bit in bit8) poke TXSTA, TXSTA_INIT ;Initialise AUSART Transmit register RCSTA_INIT = SPEN | CREN | RX9 ;Bitwise OR (Sets Async Rxd mode, 9 Bit Rx & Parity bit in bit8) poke RCSTA, RCSTA_INIT ;Initialise AUSART Receive register MainLoop: RxdLoop1: ;Recieve data from BCM on BATTSCI Bus peek PIR1, status ;Test for RX byte Received if RCIF_BIT = 0 then RxdLoop1 ;No byte recieved peek RCREG, b6 ;AUSART Receive. Get the byte (Char) poke RCSTA, SPEN ;Clear any errors poke RCSTA, RCSTA_INIT ;Reset AUSART Receive Control Register if b6 <> then RxdLoop1: ;If b6 <> Start character then loop again poke 80, b6 ;Store b6 in RAM address 80 for Counter1 = 81 to 104 ;Receive 2 x 12 byte data packet RxdLoop2: peek PIR1, status ;Test for RX byte Received if RCIF_BIT = 0 then RxdLoop2 ;No byte recieved peek RCREG, b6 ;AUSART Receive. Get the byte (Char) poke RCSTA, SPEN ;Clear any errors poke RCSTA, RCSTA_INIT ;Reset AUSART Receive Control Register poke Counter1, b6 ;Store b6 in RAM addressed by Counter1 next Counter1 ;Repeat loop until 2 x 12 byte data packets received TxdLoop: ;Transmission Loop for Counter1 = 80 to 104 ;Transmit 2 x 12 byte data packet peek Counter1, Char ;Load Char from RAM addressed by Counter1 bit8 = bit7 ^ bit6 ^ bit5 ^ bit4 ^ bit3 ^ bit2 ^bit1 ^ bit0 ;Bitwise XOR (Calcs even parity & sets bit8 as reqd) TXSTA_INIT = TXEN | TX9 | BIT8 ;Bitwise OR (Sets Async Txd mode, 9 Bit Tx & Parity bit in bit8) poke TXSTA, TXSTA_INIT ;Set AUSART Transmit Control Register poke TXREG, Char ;AUSART Transmit. Send the byte (Char) next Counter1 ;Repeat loop until 2 x 12 byte data packets sent goto MainLoop #REM ****************************** ODD NOTES ********************************* METSCI DATA The entire 2 second 5-part cycle 19 bars (I think): 10 packets of 3 bytes 100ms apart. e6 40 5a e1 33 6c e6 40 5a b4 00 4c e6 40 5a b4 00 4c e6 40 5a b3 04 49 e6 40 5a b4 00 4c I think you just need the battery part (lower bars): e1 26 79 SOC E1 20 7F = 0 Bars 225, 32, 127 E1 21 7E = 1 Bars 225, 33, 126 E1 22 7D = 2 Bars 225, 34, 125 E1 23 7C = 3 Bars 225, 35, 124 E1 24 7B = 4 Bars 225, 36, 123 E1 25 7A = 5 Bars 225, 37, 122 E1 26 79 = 6 Bars 225, 38, 121 E1 27 78 = 7 Bars 225, 39, 120 E1 28 77 = 8 Bars 225, 40, 119 E1 29 76 = 9 Bars 225, 41, 118 E1 2A 75 = 10 Bars 225, 42, 117 E1 2B 74 = 11 Bars 225, 43, 116 E1 2C 73 = 12 Bars 225, 44, 115 E1 2D 72 = 13 Bars 225, 45, 114 E1 2E 71 = 14 Bars 225, 46, 113 E1 2F 70 = 15 Bars 225, 47, 112 E1 30 6F = 16 Bars 225, 48, 111 E1 31 6E = 17 Bars 225, 49, 110 E1 32 6D = 18 Bars 225, 50, 109 E1 33 6C = 19 Bars 225, 51, 108 E1 34 6B = 20 Bars 225, 52, 107 I believe the Assist/Regen Gauge is as follows E6 40 5A = No Assist or Regen E6 41 59 = 1 Bars Assist E6 42 58 = 2 Bars Assist E6 43 57 = 3 Bars Assist E6 44 56 = 4 Bars Assist E6 45 55 = 5 Bars Assist E6 46 54 = 6 Bars Assist E6 47 53 = 7 Bars Assist E6 48 52 = 8 Bars Assist E6 49 51 = 9 Bars Assist E6 4A 50 = 10 Bars Assist E6 4B 4F = 11 Bars Assist E6 4C 4E = 12 Bars Assist E6 4D 4D = 13 Bars Assist E6 4E 4C = 14 Bars Assist E6 4F 4B = 15 Bars Assist E6 50 4A = 16 Bars Assist E6 51 49 = 17 Bars Assist E6 52 48 = 18 Bars Assist E6 53 47 = 19 Bars Assist E6 54 46 = 20 Bars Assist E6 20 7F = 0 Bars Regen? E6 21 79 = 1 Bars Regen E6 22 78 = 2 Bars Regen E6 23 77 = 3 Bars Regen E6 24 76 = 4 Bars Regen E6 25 75 = 5 Bars Regen E6 26 74 = 6 Bars Regen E6 27 73 = 7 Bars Regen E6 28 72 = 8 Bars Regen E6 29 71 = 9 Bars Regen E6 2A 70 = 10 Bars Regen E6 2B 6F = 11 Bars Regen E6 2C 6E = 12 Bars Regen E6 2D 6D = 13 Bars Regen E6 2E 6C = 14 Bars Regen E6 2F 6B = 15 Bars Regen E6 30 6A = 16 Bars Regen E6 31 69 = 17 Bars Regen E6 32 68 = 18 Bars Regen E6 33 67 = 19 Bars Regen E6 34 66 = 20 Bars Regen *********************************************************************************************************************** RS485 Driver PIN FUNCTIONS RO (Pin 1): Receiver Output. If the receiver output is enabled (RE LOW), and A > B by 200mV, RO will be HIGH. If A < B by 200mV, then RO will be LOW. RE (Pin 2): Receiver Output Enable. A LOW enables the receiver output, RO. A HIGH input forces the receiver output into a high impedance state. DE (Pin 3): Driver Outputs Enable. A HIGH on DE enables the driver output. A and B and the chip will function as a line driver. A LOW input will force the driver outputs into a high impedance state and the chip will function as a line receiver. If RE is HIGH and DE is LOW, the part will enter a low power (1ľA) shutdown state. DI (Pin 4): Driver Input. If the driver outputs are enabled (DE HIGH) then a LOW on DI forces the outputs A LOW and B HIGH. A HIGH on DI with the driver outputs enabled will force A HIGH and B LOW. GND (Pin 5): Ground. A (Pin 6): Driver Output/Receiver Input. B (Pin 7): Driver Output/Receiver Input. VCC (Pin 8): Positive Supply. 4.75V < VCC < 5.25V. #ENDREM