-
Notifications
You must be signed in to change notification settings - Fork 0
/
config
128 lines (100 loc) · 3.83 KB
/
config
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
bool loadState = false;
bool switch_load = true ;
bool init_off = false;
bool block_off = false;
bool enable_isr = true;
// Pins
#define MAX485_DE 5 // data or
#define MAX485_RE 6 // recv enable
#define wakePin 2 // int 0 used for control input
#define ledPin 13 // int 0 used for control input
// ModBus Register Locations
#define LIVE_DATA 0x3100 // start of live-data
#define LIVE_DATA_CNT 16 // 16 regs
#define DEBOUNCE_DELAY 1800 // in ms
uint32_t last_interrupt_time = 0;
uint8_t led_status = 0;
#define PANEL_VOLTS 0x00
#define PANEL_AMPS 0x01
#define PANEL_POWER_L 0x02
#define PANEL_POWER_H 0x03
#define BATT_VOLTS 0x04
#define BATT_AMPS 0x05
#define BATT_POWER_L 0x06
#define BATT_POWER_H 0x07
#define LOAD_VOLTS 0x0C
#define LOAD_AMPS 0x0D
#define LOAD_POWER_L 0x0E
#define LOAD_POWER_H 0x0F
//#define CCMODEL 0x2b
#define RTC_CLOCK 0x9013 // D7-0 Sec, D15-8 Min : D7-0 Hour, D15-8 Day : D7-0 Month, D15-8 Year
#define RTC_CLOCK_CNT 3 // 3 regs
//#define BATTERY_SOC 0x311A // State of Charge in percent, 1 reg
#define BATTERY_CURRENT_L 0x331B // Battery current L
#define BATTERY_CURRENT_H 0x331C // Battery current H
#define STATISTICS 0x3300 // start of statistical data
#define STATISTICS_CNT 22 // 22 regs
// just for reference, not used in code
#define PV_MAX 0x00 // Maximum input volt (PV) today
#define PV_MIN 0x01 // Minimum input volt (PV) today
#define BATT_MAX 0x02 // Maximum battery volt today
#define BATT_MIN 0x03 // Minimum battery volt today
#define CONS_ENERGY_DAY_L 0x04 // Consumed energy today L
#define CONS_ENGERY_DAY_H 0x05 // Consumed energy today H
#define CONS_ENGERY_MON_L 0x06 // Consumed energy this month L
#define CONS_ENGERY_MON_H 0x07 // Consumed energy this month H
#define CONS_ENGERY_YEAR_L 0x08 // Consumed energy this year L
#define CONS_ENGERY_YEAR_H 0x09 // Consumed energy this year H
#define CONS_ENGERY_TOT_L 0x0A // Total consumed energy L
#define CONS_ENGERY_TOT_H 0x0B // Total consumed energy H
#define GEN_ENERGY_DAY_L 0x0C // Generated energy today L
#define GEN_ENERGY_DAY_H 0x0D // Generated energy today H
#define GEN_ENERGY_MON_L 0x0E // Generated energy this month L
#define GEN_ENERGY_MON_H 0x0F // Generated energy this month H
#define GEN_ENERGY_YEAR_L 0x10 // Generated energy this year L
#define GEN_ENERGY_YEAR_H 0x11 // Generated energy this year H
#define GEN_ENERGY_TOT_L 0x12 // Total generated energy L
#define GEN_ENERGY_TOT_H 0x13 // Total Generated energy H
#define CO2_REDUCTION_L 0x14 // Carbon dioxide reduction L
#define CO2_REDUCTION_H 0x15 // Carbon dioxide reduction H
#define LOAD_STATE 0x02 // r/w load switch state
#define STATUS_FLAGS 0x3200
#define STATUS_BATTERY 0x00 // Battery status register
#define STATUS_CHARGER 0x01 // Charging equipment status register
#define BATTERY_TYPE 0x9000 // Battery Type 0001H- Sealed , 0002H- GEL, 0003H- Flooded, 0000H- User defined
#define BATTERY_CAPACITY 0x9001 // Rated capacity of the battery in Ah
#define HIGH_VOLTAGE_DISCONNECT 0x9003 //
#define CHARGING_LIMIT_VOLT 0x9004 //
#define EQ_CHARGE_VOLT 0x9006
uint8_t i, result;
uint16_t ErrorCounter=0;
// datastructures, also for buffer to values conversion
//
// clock
union {
struct {
uint8_t s;
uint8_t m;
uint8_t h;
uint8_t d;
uint8_t M;
uint8_t y;
} r;
uint16_t buf[3];
} rtc ;
// live data
union {
struct {
int16_t pV;
int16_t pI;
int32_t pP;
int16_t bV;
int16_t bI;
int32_t bP;
uint16_t dummy[4];
int16_t lV;
int16_t lI;
int32_t lP;
} l;
uint16_t buf[16];
} live;