'------ Li-Ion Battery Management System Watchdog Chip ------- '------ Picbasic Pro Compiler version PIC12F683 - 110610 - V02 Beta ---------- '------ This code is for the Watchdog chip on the Master boards '------ Please report any errors or problems. '------------------------------------------------------------------------------ '**************************** General Information ****************************** 'The BMS 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. '************************* Watchdog PIC12F683 Pinouts ************************** ' Top ' _____ '(+ Supply) +Ve -1| ^ |8- -Ve (- Supply) '(Not Used) Output 5 -2| 6 |7- Output 0 (Not Used) '(Watchdog Led Out) Output 4 -3| 8 |6- Output 1 (Audible Alarm Out) '(Pulse Count In) Input 3 -4| 3 |5- Output 2 (Master Reset Out) ' ----- '********************** Watchdog Module Specification ************************** 'Supply Voltage 5.00V DC same as Master 'Average Supply Current at 5.00v <100ua 'CPU Speed 4mhz with internal resonator '******************************************************************************* '********************** Program Size 961 out of 2048 Words ********************* '******************************************************************************* '------------------------------ General configuration -------------------------- @ DEVICE PIC12F683,MCLR_OFF @ DEVICE PIC12F683,BOD_OFF @ DEVICE PIC12F683,PROTECT_OFF @ DEVICE PIC12F683,WDT_ON 'osccon = %01000000 ' Osc set to 1 MHz 'osccon = %01010000 ' Osc set to 2 MHz 'osccon = %01100000 ' Osc set to 4 MHz (Default) 'osccon = %01110000 ' Osc set to 8 MHz Define OSC 4 'Set processor speed to 4 Mhz INTCON = %10001000 'Internal oscillator OSCCON = %01100111 'Sets internal osc to 4 Mhz (Default) and stable CMCON0 = %00000111 'Comparators off GPIO = %00000000 'Outputs low TRISIO = %00001000 'Set Pin GPIO.3 as Input ANSEL = %00000000 'Make sure Analog functions are turned OFF (should not be needed) ADCON0 = %00000000 'A/D off '******************************************************************************* 'Variables Constants and I/O definitions '------------------------ Variables 16bit -------------------------------------- Pulses var Word 'Number of WatchDog pulses received in 1 min '--------------------------- Constants ----------------------------------------- Time con 65500 'Timer set to 65 seconds approx MinPulses con 1 'Minimum number of pulses allowed '---------------- Pins used for I/O and designations ------------------------- '------------------ Digital high/low Inputs/Outputs ------------------------ Alarm var GPIO.1 'Audible Alarm Warning on Output 1 MasterReset var GPIO.2 'Master Reset on Output 2 Led var GPIO.4 'Warning Led on Output 4 '---------------- Analogue ADC Inputs ------------------------------ WatchDog var GPIO.3 'Watchdog pulses input on Input 3 '******************************************************************************* Start: high MasterReset 'Deactivate Master Reset Output [Pull High] (Note pcb jumper setting) count WatchDog, Time, Pulses 'Count Watchdog pulses recieved in 65 seconds if Pulses > MinPulses then Start 'If Pulses received > MinPulses then goto program start high Alarm 'Activate Audible alarm high Led 'Activate WatchDog alarm dashboard Led low MasterReset 'Activate Master Reset Output [Pull Low] (Note pcb jumper setting) pause 2000 'Pause for 2 seconds to allow Master Reset goto Start 'Goto program start