Rewrite with central user settings file

This commit is contained in:
Daniel 2023-09-14 13:23:15 +03:00
parent 120fa9b5e7
commit eeefd20970
21 changed files with 72 additions and 89 deletions

View file

@ -100,8 +100,7 @@ void update_values_i3_battery()
CANstillAlive--; CANstillAlive--;
} }
if(printValues) #ifdef DEBUG_VIA_USB
{ //values heading towards the inverter
Serial.print("SOC% battery: "); Serial.print("SOC% battery: ");
Serial.print(Display_SOC); Serial.print(Display_SOC);
Serial.print(" SOC% sent to inverter: "); Serial.print(" SOC% sent to inverter: ");
@ -114,7 +113,7 @@ void update_values_i3_battery()
Serial.print(max_target_charge_power); Serial.print(max_target_charge_power);
Serial.print(" Max discharge power: "); Serial.print(" Max discharge power: ");
Serial.print(max_target_discharge_power); Serial.print(max_target_discharge_power);
} #endif
} }
void receive_can_i3_battery(CAN_frame_t rx_frame) void receive_can_i3_battery(CAN_frame_t rx_frame)

View file

@ -2,13 +2,10 @@
#define BMW_I3_BATTERY_H #define BMW_I3_BATTERY_H
#include <Arduino.h> #include <Arduino.h>
#include "ESP32CAN.h" #include "ESP32CAN.h"
#include "USER_SETTINGS.h"
#define BATTERY_WH_MAX 24000 //Battery size in Wh (Maximum value Fronius accepts is 60000 [60kWh] you can use larger batteries but do set value over 60000
#define ABSOLUTE_MAX_VOLTAGE 4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge) #define ABSOLUTE_MAX_VOLTAGE 4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge)
#define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled #define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled
#define MAXPERCENTAGE 800 //80.0% , Max percentage the battery will charge to (App will show 100% once this value is reached)
#define MINPERCENTAGE 200 //20.0% , Min percentage the battery will discharge to (App will show 0% once this value is reached)
static byte printValues = 1; //Should debug values be printed to serial output?
// These parameters need to be mapped for the inverter // These parameters need to be mapped for the inverter
extern uint16_t SOC; extern uint16_t SOC;

View file

@ -2,6 +2,7 @@
#define BYD_CAN_H #define BYD_CAN_H
#include <Arduino.h> #include <Arduino.h>
#include "ESP32CAN.h" #include "ESP32CAN.h"
#include "USER_SETTINGS.h"
extern uint16_t SOC; extern uint16_t SOC;
extern uint16_t StateOfHealth; extern uint16_t StateOfHealth;

View file

@ -85,8 +85,7 @@ void update_values_chademo_battery()
CANstillAlive--; CANstillAlive--;
} }
if(printValues) #ifdef DEBUG_VIA_USB
{ //values heading towards the modbus registers
if(errorCode > 0) if(errorCode > 0)
{ {
Serial.print("ERROR CODE ACTIVE IN SYSTEM. NUMBER: "); Serial.print("ERROR CODE ACTIVE IN SYSTEM. NUMBER: ");
@ -120,7 +119,7 @@ void update_values_chademo_battery()
Serial.println(temperature_min); Serial.println(temperature_min);
Serial.print("Temperature Max: "); Serial.print("Temperature Max: ");
Serial.println(temperature_max); Serial.println(temperature_max);
} #endif
} }
void receive_can_chademo_battery(CAN_frame_t rx_frame) void receive_can_chademo_battery(CAN_frame_t rx_frame)

View file

@ -2,13 +2,10 @@
#define CHADEMO_BATTERY_H #define CHADEMO_BATTERY_H
#include <Arduino.h> #include <Arduino.h>
#include "ESP32CAN.h" #include "ESP32CAN.h"
#include "USER_SETTINGS.h"
#define BATTERY_WH_MAX 24000 //Battery size in Wh (Maximum value Fronius accepts is 60000 [60kWh] you can use larger batteries but do set value over 60000
#define ABSOLUTE_MAX_VOLTAGE 4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge) #define ABSOLUTE_MAX_VOLTAGE 4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge)
#define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled #define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled
#define MAXPERCENTAGE 800 //80.0% , Max percentage the battery will charge to (App will show 100% once this value is reached)
#define MINPERCENTAGE 200 //20.0% , Min percentage the battery will discharge to (App will show 0% once this value is reached)
static byte printValues = 0; //Should debug values be printed to serial output?
// These parameters need to be mapped // These parameters need to be mapped
extern uint16_t SOC; extern uint16_t SOC;

View file

@ -73,15 +73,14 @@ void update_values_imiev_battery()
CANstillAlive--; CANstillAlive--;
} }
if(printValues) #ifdef DEBUG_VIA_USB
{ //values heading towards the modbus registers
Serial.print("BMU SOC: "); Serial.print("BMU SOC: ");
Serial.println(BMU_SOC); Serial.println(BMU_SOC);
Serial.print("BMU Current: "); Serial.print("BMU Current: ");
Serial.println(BMU_Current); Serial.println(BMU_Current);
Serial.print("BMU Battery Voltage: "); Serial.print("BMU Battery Voltage: ");
Serial.println(BMU_PackVoltage); Serial.println(BMU_PackVoltage);
} #endif
} }
void receive_can_imiev_battery(CAN_frame_t rx_frame) void receive_can_imiev_battery(CAN_frame_t rx_frame)

View file

@ -2,13 +2,10 @@
#define IMIEV_CZERO_ION_BATTERY_H #define IMIEV_CZERO_ION_BATTERY_H
#include <Arduino.h> #include <Arduino.h>
#include "ESP32CAN.h" #include "ESP32CAN.h"
#include "USER_SETTINGS.h"
#define BATTERY_WH_MAX 22000 //Battery size in Wh (Maximum value Fronius accepts is 60000 [60kWh] you can use larger batteries but do set value over 60000
#define ABSOLUTE_MAX_VOLTAGE 4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge) #define ABSOLUTE_MAX_VOLTAGE 4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge)
#define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled #define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled
#define MAXPERCENTAGE_ZOE 800 //80.0% , Max percentage the battery will charge to (App will show 100% once this value is reached)
#define MINPERCENTAGE_ZOE 200 //20.0% , Min percentage the battery will discharge to (App will show 0% once this value is reached)
static byte printValues = 1; //Should modbus values be printed to serial output?
// These parameters need to be mapped for the Gen24 // These parameters need to be mapped for the Gen24
extern uint16_t SOC; extern uint16_t SOC;

View file

@ -51,15 +51,14 @@ void update_values_kiaHyundai_64_battery()
CANstillAlive--; CANstillAlive--;
} }
if(printValues) #ifdef DEBUG_VIA_USB
{ //values heading towards the inverter
Serial.print("SOC% candidate 1: "); Serial.print("SOC% candidate 1: ");
Serial.println(SOC_1); Serial.println(SOC_1);
Serial.print("SOC% candidate 2: "); Serial.print("SOC% candidate 2: ");
Serial.println(SOC_2); Serial.println(SOC_2);
Serial.print("SOC% candidate 3: "); Serial.print("SOC% candidate 3: ");
Serial.println(SOC_3); Serial.println(SOC_3);
} #endif
} }
void receive_can_kiaHyundai_64_battery(CAN_frame_t rx_frame) void receive_can_kiaHyundai_64_battery(CAN_frame_t rx_frame)

View file

@ -2,13 +2,10 @@
#define KIA_HYUNDAI_64_BATTERY_H #define KIA_HYUNDAI_64_BATTERY_H
#include <Arduino.h> #include <Arduino.h>
#include "ESP32CAN.h" #include "ESP32CAN.h"
#include "USER_SETTINGS.h"
#define BATTERY_WH_MAX 60000 //Battery size in Wh (Maximum value Fronius accepts is 60000 [60kWh] you can use larger batteries but do set value over 60000
#define ABSOLUTE_MAX_VOLTAGE 4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge) #define ABSOLUTE_MAX_VOLTAGE 4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge)
#define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled #define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled
#define MAXPERCENTAGE 800 //80.0% , Max percentage the battery will charge to (App will show 100% once this value is reached)
#define MINPERCENTAGE 200 //20.0% , Min percentage the battery will discharge to (App will show 0% once this value is reached)
static byte printValues = 1; //Should debug values be printed to serial output?
// These parameters need to be mapped for the Gen24 // These parameters need to be mapped for the Gen24
extern uint16_t SOC; extern uint16_t SOC;

View file

@ -293,8 +293,7 @@ void update_values_leaf_battery()
} }
/*Finally print out values to serial if configured to do so*/ /*Finally print out values to serial if configured to do so*/
if(printValues) #ifdef DEBUG_VIA_USB
{
if(errorCode > 0) if(errorCode > 0)
{ {
Serial.print("ERROR CODE ACTIVE IN SYSTEM. NUMBER: "); Serial.print("ERROR CODE ACTIVE IN SYSTEM. NUMBER: ");
@ -350,7 +349,7 @@ void update_values_leaf_battery()
Serial.print(Battery_current_1); Serial.print(Battery_current_1);
Serial.print(" Current 2: "); Serial.print(" Current 2: ");
Serial.println(Battery_current_2); Serial.println(Battery_current_2);
} #endif
} }
void receive_can_leaf_battery(CAN_frame_t rx_frame) void receive_can_leaf_battery(CAN_frame_t rx_frame)

View file

@ -2,14 +2,10 @@
#define NISSAN_LEAF_BATTERY_H #define NISSAN_LEAF_BATTERY_H
#include <Arduino.h> #include <Arduino.h>
#include "ESP32CAN.h" #include "ESP32CAN.h"
#include "USER_SETTINGS.h"
#define BATTERY_WH_MAX 30000 //Battery size in Wh (Maximum value Fronius accepts is 60000 [60kWh] you can use larger batteries but do set value over 60000
#define ABSOLUTE_MAX_VOLTAGE 4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge) #define ABSOLUTE_MAX_VOLTAGE 4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge)
#define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled #define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled
#define MAXPERCENTAGE 800 //80.0% , Max percentage the battery will charge to (App will show 100% once this value is reached)
#define MINPERCENTAGE 200 //20.0% , Min percentage the battery will discharge to (App will show 0% once this value is reached)
//#define INTERLOCK_REQUIRED //Uncomment this line to skip requiring both high voltage connectors to be seated on the LEAF battery
static byte printValues = 0; //Should modbus values be printed to serial output?
// These parameters need to be mapped for the Gen24 // These parameters need to be mapped for the Gen24
extern uint16_t SOC; extern uint16_t SOC;

View file

@ -2,6 +2,7 @@
#define PYLON_CAN_H #define PYLON_CAN_H
#include <Arduino.h> #include <Arduino.h>
#include "ESP32CAN.h" #include "ESP32CAN.h"
#include "USER_SETTINGS.h"
extern uint16_t SOC; extern uint16_t SOC;
extern uint16_t StateOfHealth; extern uint16_t StateOfHealth;

View file

@ -33,7 +33,7 @@ void update_values_zoe_battery()
StateOfHealth = (LB_SOH * 100); //Increase range from 99% -> 99.00% StateOfHealth = (LB_SOH * 100); //Increase range from 99% -> 99.00%
//Calculate the SOC% value to send to Fronius //Calculate the SOC% value to send to Fronius
LB_SOC = LB_MIN_SOC + (LB_MAX_SOC - LB_MIN_SOC) * (LB_SOC - MINPERCENTAGE_ZOE) / (MAXPERCENTAGE_ZOE - MINPERCENTAGE_ZOE); LB_SOC = LB_MIN_SOC + (LB_MAX_SOC - LB_MIN_SOC) * (LB_SOC - MINPERCENTAGE) / (MAXPERCENTAGE - MINPERCENTAGE);
if (LB_SOC < 0) if (LB_SOC < 0)
{ //We are in the real SOC% range of 0-20%, always set SOC sent to Fronius as 0% { //We are in the real SOC% range of 0-20%, always set SOC sent to Fronius as 0%
LB_SOC = 0; LB_SOC = 0;
@ -98,8 +98,7 @@ void update_values_zoe_battery()
temperature_min; temperature_min;
temperature_max; temperature_max;
if(printValues) #ifdef DEBUG_VIA_USB
{ //values heading towards the modbus registers
Serial.print("BMS Status (3=OK): "); Serial.print("BMS Status (3=OK): ");
Serial.println(bms_status); Serial.println(bms_status);
Serial.print("Max discharge power: "); Serial.print("Max discharge power: ");
@ -118,7 +117,7 @@ void update_values_zoe_battery()
Serial.println(temperature_min); Serial.println(temperature_min);
Serial.print("Temperature Max: "); Serial.print("Temperature Max: ");
Serial.println(temperature_max); Serial.println(temperature_max);
} #endif
} }
void receive_can_zoe_battery(CAN_frame_t rx_frame) void receive_can_zoe_battery(CAN_frame_t rx_frame)

View file

@ -2,13 +2,10 @@
#define RENAULT_ZOE_BATTERY_H #define RENAULT_ZOE_BATTERY_H
#include <Arduino.h> #include <Arduino.h>
#include "ESP32CAN.h" #include "ESP32CAN.h"
#include "USER_SETTINGS.h"
#define BATTERY_WH_MAX 22000 //Battery size in Wh (Maximum value Fronius accepts is 60000 [60kWh] you can use larger batteries but do set value over 60000
#define ABSOLUTE_MAX_VOLTAGE 4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge) #define ABSOLUTE_MAX_VOLTAGE 4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge)
#define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled #define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled
#define MAXPERCENTAGE_ZOE 800 //80.0% , Max percentage the battery will charge to (App will show 100% once this value is reached)
#define MINPERCENTAGE_ZOE 200 //20.0% , Min percentage the battery will discharge to (App will show 0% once this value is reached)
static byte printValues = 1; //Should modbus values be printed to serial output?
// These parameters need to be mapped for the Gen24 // These parameters need to be mapped for the Gen24
extern uint16_t SOC; extern uint16_t SOC;

View file

@ -30,7 +30,7 @@ CAN_frame_t SOLAX_100A001 = {.FIR = {.B = {.DLC = 0,.FF = CAN_frame_ext,}},.MsgI
void CAN_WriteFrame(CAN_frame_t* tx_frame) void CAN_WriteFrame(CAN_frame_t* tx_frame)
{ {
if(dual_can){ #ifdef DUAL_CAN
CANMessage MCP2515Frame; //Struct with ACAN2515 library format, needed to use the MCP2515 library CANMessage MCP2515Frame; //Struct with ACAN2515 library format, needed to use the MCP2515 library
MCP2515Frame.id = tx_frame->MsgID; MCP2515Frame.id = tx_frame->MsgID;
MCP2515Frame.ext = tx_frame->FIR.B.FF; MCP2515Frame.ext = tx_frame->FIR.B.FF;
@ -39,10 +39,9 @@ if(dual_can){
MCP2515Frame.data[i] = tx_frame->data.u8[i]; MCP2515Frame.data[i] = tx_frame->data.u8[i];
} }
can.tryToSend(MCP2515Frame); can.tryToSend(MCP2515Frame);
} #else
else{
ESP32Can.CANWriteFrame(tx_frame); ESP32Can.CANWriteFrame(tx_frame);
} #endif
} }
void update_values_can_solax() void update_values_can_solax()

View file

@ -3,10 +3,10 @@
#include <Arduino.h> #include <Arduino.h>
#include "ESP32CAN.h" #include "ESP32CAN.h"
#include "config.h" #include "config.h"
#include "USER_SETTINGS.h"
#include "ACAN2515.h" #include "ACAN2515.h"
extern ACAN2515 can; extern ACAN2515 can;
extern bool dual_can;
extern uint16_t SOC; extern uint16_t SOC;
extern uint16_t StateOfHealth; extern uint16_t StateOfHealth;

View file

@ -1,28 +1,9 @@
/* Select battery used */
#define BATTERY_TYPE_LEAF // See NISSAN-LEAF-BATTERY.h for more LEAF battery settings
//#define TESLA_MODEL_3_BATTERY // See TESLA-MODEL-3-BATTERY.h for more Tesla battery settings
//#define RENAULT_ZOE_BATTERY // See RENAULT-ZOE-BATTERY.h for more Zoe battery settings
//#define BMW_I3_BATTERY // See BMW-I3-BATTERY.h for more i3 battery settings
//#define IMIEV_ION_CZERO_BATTERY // See IMIEV-CZERO-ION-BATTERY.h for more triplet battery settings
//#define KIA_HYUNDAI_64_BATTERY // See KIA-HYUNDAI-64-BATTERY.h for more battery settings
//#define CHADEMO // See CHADEMO.h for more Chademo related settings
/* Select inverter communication protocol. See Wiki for which to use with your inverter: https://github.com/dalathegreat/BYD-Battery-Emulator-For-Gen24/wiki */
#define MODBUS_BYD //Enable this line to emulate a "BYD 11kWh HVM battery" over Modbus RTU
//#define CAN_BYD //Enable this line to emulate a "BYD Battery-Box Premium HVS" over CAN Bus
//#define SOLAX_CAN //Enable this line to emulate a "SolaX Triple Power LFP" over CAN bus
//#define PYLON_CAN //Enable this line to emulate a "Pylontech battery" over CAN bus
/* Other options */
#define CONTACTOR_CONTROL //Enable this line to have pins 25,32,33 handle precharge/contactor+/contactor- closing sequence
//#define PWM_CONTACTOR_CONTROL //Enable this line to use PWM logic for contactors, which lower power consumption and heat generation
//#define DUAL_CAN //Enable this line to activate an isolated secondary CAN Bus using add-on MCP2515 controller (Needed for FoxESS inverters)
/* Do not change any code below this line unless you are sure what you are doing */ /* Do not change any code below this line unless you are sure what you are doing */
/* Only change battery specific settings and limits in their respective .h files */ /* Only change battery specific settings in "USER_SETTINGS.h" and limits in their respective .h files */
#include <Arduino.h> #include <Arduino.h>
#include "HardwareSerial.h" #include "HardwareSerial.h"
#include "USER_SETTINGS.h"
#include "config.h" #include "config.h"
#include "Logging.h" #include "Logging.h"
#include "mbServerFCs.h" #include "mbServerFCs.h"
@ -38,13 +19,10 @@ CAN_device_t CAN_cfg; // CAN Config
const int rx_queue_size = 10; // Receive Queue size const int rx_queue_size = 10; // Receive Queue size
#ifdef DUAL_CAN #ifdef DUAL_CAN
bool dual_can = 1;
#include "ACAN2515.h" #include "ACAN2515.h"
static const uint32_t QUARTZ_FREQUENCY = 8UL * 1000UL * 1000UL ; // 8 MHz static const uint32_t QUARTZ_FREQUENCY = 8UL * 1000UL * 1000UL ; // 8 MHz
ACAN2515 can(MCP2515_CS, SPI, MCP2515_INT); ACAN2515 can(MCP2515_CS, SPI, MCP2515_INT);
static ACAN2515_Buffer16 gBuffer; static ACAN2515_Buffer16 gBuffer;
#else
bool dual_can = 0;
#endif #endif
//Interval settings //Interval settings

View file

@ -126,8 +126,7 @@ void update_values_tesla_model_3_battery()
stillAliveCAN--; stillAliveCAN--;
} }
if(printValues) #ifdef DEBUG_VIA_USB
{
if (packCtrsClosingAllowed == 0) if (packCtrsClosingAllowed == 0)
{ {
Serial.println("Check high voltage connectors and interlock circuit! Closing contactor not allowed! Values: "); Serial.println("Check high voltage connectors and interlock circuit! Closing contactor not allowed! Values: ");
@ -207,7 +206,7 @@ void update_values_tesla_model_3_battery()
Serial.print(temperature_max); Serial.print(temperature_max);
Serial.print(" Min temperature (C): "); Serial.print(" Min temperature (C): ");
Serial.println(temperature_min); Serial.println(temperature_min);
} #endif
} }
void receive_can_tesla_model_3_battery(CAN_frame_t rx_frame) void receive_can_tesla_model_3_battery(CAN_frame_t rx_frame)

View file

@ -2,17 +2,14 @@
#define TESLA_MODEL_3_BATTERY_H #define TESLA_MODEL_3_BATTERY_H
#include <Arduino.h> #include <Arduino.h>
#include "ESP32CAN.h" #include "ESP32CAN.h"
#include "USER_SETTINGS.h"
/* User definable settings for the Tesla Model 3 battery */ /* User definable settings for the Tesla Model 3 battery */
//#define HVIL_OMITTED //Uncomment this line to allow battery to function without HVIL condition fulfilled. NOTE: Some values not available in this mode, see wiki //#define HVIL_OMITTED //Uncomment this line to allow battery to function without HVIL condition fulfilled. NOTE: Some values not available in this mode, see wiki
// NOTE: Omitting this has consequences, battery cannot request a stop incase a cell over/undercharges!!! So try to fix HVIL as soon as possible // NOTE: Omitting this has consequences, battery cannot request a stop incase a cell over/undercharges!!! So try to fix HVIL as soon as possible
#define BATTERY_WH_MAX 60000 //Battery size in Wh (Maximum value Fronius accepts is 60000 [60kWh] you can use larger 65/75/90 batteries but do set value over 60000!
#define ABSOLUTE_MAX_VOLTAGE 4030 // 403.0V,if battery voltage goes over this, charging is not possible (goes into forced discharge) #define ABSOLUTE_MAX_VOLTAGE 4030 // 403.0V,if battery voltage goes over this, charging is not possible (goes into forced discharge)
#define ABSOLUTE_MIN_VOLTAGE 2450 // 245.0V if battery voltage goes under this, discharging further is disabled #define ABSOLUTE_MIN_VOLTAGE 2450 // 245.0V if battery voltage goes under this, discharging further is disabled
#define MAXPERCENTAGE 950 //95.0% , Max percentage the battery will charge to (App will show 100% once this value is reached)
#define MINPERCENTAGE 150 //15.0% , Min percentage the battery will discharge to (App will show 0% once this value is reached)
static byte printValues = 1; //Should modbus values be printed to serial output?
// These parameters need to be mapped for the Gen24 // These parameters need to be mapped for the Gen24
extern uint16_t SOC; extern uint16_t SOC;

35
Software/USER_SETTINGS.h Normal file
View file

@ -0,0 +1,35 @@
#ifndef __USER_SETTINGS_H__
#define __USER_SETTINGS_H__
/* This file contains all the user configurable settings for the Battery-Emulator software */
/* To switch between batteries/inverters, uncomment a line to enable, comment out to disable. */
/* There are also some options for battery limits and extra functionality */
/* Select battery used */
#define BATTERY_TYPE_LEAF
//#define TESLA_MODEL_3_BATTERY
//#define RENAULT_ZOE_BATTERY
//#define BMW_I3_BATTERY
//#define IMIEV_ION_CZERO_BATTERY
//#define KIA_HYUNDAI_64_BATTERY
//#define CHADEMO
/* Select inverter communication protocol. See Wiki for which to use with your inverter: https://github.com/dalathegreat/BYD-Battery-Emulator-For-Gen24/wiki */
#define MODBUS_BYD //Enable this line to emulate a "BYD 11kWh HVM battery" over Modbus RTU
//#define CAN_BYD //Enable this line to emulate a "BYD Battery-Box Premium HVS" over CAN Bus
//#define SOLAX_CAN //Enable this line to emulate a "SolaX Triple Power LFP" over CAN bus
//#define PYLON_CAN //Enable this line to emulate a "Pylontech battery" over CAN bus
/* Battery settings */
#define BATTERY_WH_MAX 30000 //Battery size in Wh (Maximum value for most inverters is 60000 [60kWh], you can use larger batteries but do set value over 60000!
#define MAXPERCENTAGE 800 //80.0% , Max percentage the battery will charge to (App will show 100% once this value is reached)
#define MINPERCENTAGE 200 //20.0% , Min percentage the battery will discharge to (App will show 0% once this value is reached)
//define INTERLOCK_REQUIRED //Nissan LEAF specific setting, if enabled requires both high voltage conenctors to be seated before starting
/* Other options */
#define DEBUG_VIA_USB //Enable this line to have the USB port output serial diagnostic data while program runs
//#define CONTACTOR_CONTROL //Enable this line to have pins 25,32,33 handle automatic precharge/contactor+/contactor- closing sequence
//#define PWM_CONTACTOR_CONTROL //Enable this line to use PWM logic for contactors, which lower power consumption and heat generation
//#define DUAL_CAN //Enable this line to activate an isolated secondary CAN Bus using add-on MCP2515 controller (Needed for FoxESS inverters)
#endif

View file

@ -1,13 +1,17 @@
#ifndef __CONFIG_H__ #ifndef __CINFIG_H__
#define __CONFIG_H__ #define __CONFIG_H__
// PIN // PIN mappings, do not change these unless you are adding on extra hardware to the PCB
#define PIN_5V_EN 16 #define PIN_5V_EN 16
#define CAN_TX_PIN 27 #define CAN_TX_PIN 27
#define CAN_RX_PIN 26 #define CAN_RX_PIN 26
#define CAN_SE_PIN 23 #define CAN_SE_PIN 23
#define RS485_EN_PIN 17 // 17 /RE
#define RS485_TX_PIN 22 // 21
#define RS485_RX_PIN 21 // 22
#define RS485_SE_PIN 19 // 22 /SHDN
#ifdef DUAL_CAN #ifdef DUAL_CAN
#define MCP2515_SCK 12 // SCK input of MCP2515 #define MCP2515_SCK 12 // SCK input of MCP2515
#define MCP2515_MOSI 5 // SDI input of MCP2515 #define MCP2515_MOSI 5 // SDI input of MCP2515
@ -16,11 +20,6 @@
#define MCP2515_INT 35 // INT output of MCP2515 | | Pin 35 is input only, without pullup/down resistors #define MCP2515_INT 35 // INT output of MCP2515 | | Pin 35 is input only, without pullup/down resistors
#endif #endif
#define RS485_EN_PIN 17 // 17 /RE
#define RS485_TX_PIN 22 // 21
#define RS485_RX_PIN 21 // 22
#define RS485_SE_PIN 19 // 22 /SHDN
#ifdef CONTACTOR_CONTROL #ifdef CONTACTOR_CONTROL
#define POSITIVE_CONTACTOR_PIN 32 #define POSITIVE_CONTACTOR_PIN 32
#define NEGATIVE_CONTACTOR_PIN 33 #define NEGATIVE_CONTACTOR_PIN 33
@ -31,7 +30,6 @@
#define SD_MOSI_PIN 15 #define SD_MOSI_PIN 15
#define SD_SCLK_PIN 14 #define SD_SCLK_PIN 14
#define SD_CS_PIN 13 #define SD_CS_PIN 13
#define WS2812_PIN 4 #define WS2812_PIN 4
#endif #endif