-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmasterBPS.def
More file actions
113 lines (88 loc) · 3.11 KB
/
masterBPS.def
File metadata and controls
113 lines (88 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#ifndef _masterBPS_definitions_JF
#define _masterBPS_definitions_JF
///////////////////////////////////////////////////
//LED configuration
//not sure where the LED is at the moment
#define led1 LATCbits.LATC0 //1 for on 0 for off
//#define led2 LATAbits.LATA5 //1 for on 0 for off
#define LEDON 1
#define LEDOFF 0
//TRISC &= 0b11111110;//RC0 is the LED (set to output (0))
/////////////////////////////////////////////////////
//DIP Switch Configuration
#define switch1 PORTDbits.RD2
#define switch2 PORTDbits.RD3
#define switch3 PORTCbits.RC5
#define switch4 PORTDbits.RD4
#define switch5 PORTDbits.RD5
#define switch6 PORTDbits.RD6
#define SWITCHOFF 1
#define SWITCHON 0
////////////////////////////////////////////////////
//current sensor stuff
//assuming current sensor is on AN0
//external voltage referencing (RA2 -> AN2 -> VREF-) (RA3 -> AN3 -> VREF+)
#define VREF_PLUS 4.5
#define VREF_MINUS 0
////////////////////////////////////////////////////
//relay configuration
#define precharge LATCbits.LATC1
#define mainrelay LATCbits.LATC3
#define arrayrelay LATCbits.LATC2
#define RELAYON 0
#define RELAYOFF 1
#define PRECHARGETIME 600000
#define MAINWAITTIME 100000
//TRISC &= 0b11110001;//RC1,2,3 are the relay drive lines (set to output (0))
////////////////////////////////////////////////////
//Interrupt configuration
//right now I am not planning on any interrupts but I wanted to make it easy to change that later
// If interrups are desired then change INTERRUPTENABLE to 1
#define GLOBALINTERRUPTS INTCONbits.GIE
#define INTERRUPTENABLE 1
#define INTERRUPTDISABLE 0
////////////////////////////////////////////////////
//CAN message configuration
//CAN message identifiers are 11 bits long
#define MASK_BPS_SLAVE 0b00011111100
#define MASK_BPS_READING 0b00000000001
#define MASK_ENERGY 0b01000000000
#define MASK_CBS 0b00000000010
#define MASK_BPS_MASTER 0b00100000000
#define MASK_BPS_SLAVE_READING 0b00011111101
#define MASK_MASTER_SHUTDOWN 0b00100000011
#define MPPT_CONTROLLER 0b01111111111
#define SLAVE_BIT_OFFSET 2 //this is the number of bits right of where the slave address starts
#define BALANCEON 0xFF
#define BALANCEOFF 0x00
#define MODULE_ID_NULL 255
////////////////////////////////////////////////////
//BPS management Config options
#define BPSSENDRATE 50
#define SLAVETIMEOUT 6
#define CHECKINTIMEOUT 200
#define RECEIVETIMEOUT 200
//battery voltage cutoff points (in Volts * 10000)
#define CUTOFF_VOLTAGE_HIGH 37000
#define CUTOFF_VOLTAGE_LOW 25000
//#define CUTOFF_VOLTAGE_LOW 0
//#define CUTOFF_VOLTAGE_HIGH 50000
//battery current cutoff points (in milli-Amps)
#define CUTOFF_CURRENT_HIGH 40000
#define CUTOFF_CURRENT_LOW -40000
//battery temperature cutoff point (in Celcius)
#define CUTOFF_TEMP_HIGH 47
//array cutoff point (in Volts * 10000)
#define ARRAY_CUTON 37700
#define ARRAY_CUTOFF 38500
//ERROR CONFIG OPTIONS
#define NOERR 0
#define BPSERR 1
#define CURRENTERR 2
#define SHUTDOWN 3
//locations of the items in EEPROM remember 1 int = 2 char = 2 bytes
#define LOCATION_ERRTYPE 0x00
#define LOCATION_INTVAL0 0x01
#define LOCATION_INTVAL1 0x02
#define LOCATION_CHARVAL 0x03
#endif