mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 01:39:30 +02:00
Make Pylon/Solxpow/Ferroamp inverters use the new settings in COMMON_IMAGE mode
This commit is contained in:
parent
2f1ff9950c
commit
efd6ca1349
8 changed files with 122 additions and 11 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include "FERROAMP-CAN.h"
|
#include "FERROAMP-CAN.h"
|
||||||
#include "../communication/can/comm_can.h"
|
#include "../communication/can/comm_can.h"
|
||||||
#include "../datalayer/datalayer.h"
|
#include "../datalayer/datalayer.h"
|
||||||
|
#include "../inverter/INVERTERS.h"
|
||||||
|
|
||||||
//#define SEND_0 //If defined, the messages will have ID ending with 0 (useful for some inverters)
|
//#define SEND_0 //If defined, the messages will have ID ending with 0 (useful for some inverters)
|
||||||
#define SEND_1 //If defined, the messages will have ID ending with 1 (useful for some inverters)
|
#define SEND_1 //If defined, the messages will have ID ending with 1 (useful for some inverters)
|
||||||
|
@ -364,3 +365,38 @@ void FerroampCanInverter::send_system_data() { //System equipment information
|
||||||
transmit_can_frame(&PYLON_4291);
|
transmit_can_frame(&PYLON_4291);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FerroampCanInverter::setup() {
|
||||||
|
if (user_selected_inverter_cells > 0) {
|
||||||
|
PYLON_7320.data.u8[0] = user_selected_inverter_cells & 0xff;
|
||||||
|
PYLON_7320.data.u8[1] = (uint8_t)(user_selected_inverter_cells >> 8);
|
||||||
|
PYLON_7321.data.u8[0] = user_selected_inverter_cells & 0xff;
|
||||||
|
PYLON_7321.data.u8[1] = (uint8_t)(user_selected_inverter_cells >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user_selected_inverter_modules > 0) {
|
||||||
|
PYLON_7320.data.u8[2] = user_selected_inverter_modules;
|
||||||
|
PYLON_7321.data.u8[2] = user_selected_inverter_modules;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user_selected_inverter_cells_per_module > 0) {
|
||||||
|
PYLON_7320.data.u8[3] = user_selected_inverter_cells_per_module;
|
||||||
|
PYLON_7321.data.u8[3] = user_selected_inverter_cells_per_module;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user_selected_inverter_voltage_level > 0) {
|
||||||
|
PYLON_7320.data.u8[4] = user_selected_inverter_voltage_level & 0xff;
|
||||||
|
PYLON_7320.data.u8[5] = (uint8_t)(user_selected_inverter_voltage_level >> 8);
|
||||||
|
PYLON_7321.data.u8[4] = user_selected_inverter_voltage_level & 0xff;
|
||||||
|
PYLON_7321.data.u8[5] = (uint8_t)(user_selected_inverter_voltage_level >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user_selected_inverter_ah_capacity > 0) {
|
||||||
|
PYLON_7320.data.u8[6] = user_selected_inverter_ah_capacity & 0xff;
|
||||||
|
PYLON_7320.data.u8[7] = (uint8_t)(user_selected_inverter_ah_capacity >> 8);
|
||||||
|
PYLON_7321.data.u8[6] = user_selected_inverter_ah_capacity & 0xff;
|
||||||
|
PYLON_7321.data.u8[7] = (uint8_t)(user_selected_inverter_ah_capacity >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
class FerroampCanInverter : public CanInverterProtocol {
|
class FerroampCanInverter : public CanInverterProtocol {
|
||||||
public:
|
public:
|
||||||
const char* name() override { return Name; }
|
const char* name() override { return Name; }
|
||||||
|
bool setup() override;
|
||||||
void update_values();
|
void update_values();
|
||||||
void transmit_can(unsigned long currentMillis);
|
void transmit_can(unsigned long currentMillis);
|
||||||
void map_can_frame_to_variable(CAN_frame rx_frame);
|
void map_can_frame_to_variable(CAN_frame rx_frame);
|
||||||
|
|
|
@ -4,6 +4,17 @@ InverterProtocol* inverter = nullptr;
|
||||||
|
|
||||||
InverterProtocolType user_selected_inverter_protocol = InverterProtocolType::BydModbus;
|
InverterProtocolType user_selected_inverter_protocol = InverterProtocolType::BydModbus;
|
||||||
|
|
||||||
|
// Some user-configurable settings that can be used by inverters. These
|
||||||
|
// inverters should use sensible defaults if the corresponding user_selected
|
||||||
|
// value is zero.
|
||||||
|
uint16_t user_selected_inverter_cells = 0;
|
||||||
|
uint16_t user_selected_inverter_modules = 0;
|
||||||
|
uint16_t user_selected_inverter_cells_per_module = 0;
|
||||||
|
uint16_t user_selected_inverter_voltage_level = 0;
|
||||||
|
uint16_t user_selected_inverter_ah_capacity = 0;
|
||||||
|
uint16_t user_selected_inverter_battery_type = 0;
|
||||||
|
bool user_selected_inverter_ignore_contactors = false;
|
||||||
|
|
||||||
std::vector<InverterProtocolType> supported_inverter_protocols() {
|
std::vector<InverterProtocolType> supported_inverter_protocols() {
|
||||||
std::vector<InverterProtocolType> types;
|
std::vector<InverterProtocolType> types;
|
||||||
|
|
||||||
|
@ -90,15 +101,6 @@ extern const char* name_for_inverter_type(InverterProtocolType type) {
|
||||||
#error "Compile time SELECTED_INVERTER_CLASS should not be defined with COMMON_IMAGE"
|
#error "Compile time SELECTED_INVERTER_CLASS should not be defined with COMMON_IMAGE"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Some settings that can be used by inverters
|
|
||||||
uint16_t user_selected_inverter_cells = 0;
|
|
||||||
uint16_t user_selected_inverter_modules = 0;
|
|
||||||
uint16_t user_selected_inverter_cells_per_module = 0;
|
|
||||||
uint16_t user_selected_inverter_voltage_level = 0;
|
|
||||||
uint16_t user_selected_inverter_ah_capacity = 0;
|
|
||||||
uint16_t user_selected_inverter_battery_type = 0;
|
|
||||||
bool user_selected_inverter_ignore_contactors = false;
|
|
||||||
|
|
||||||
bool setup_inverter() {
|
bool setup_inverter() {
|
||||||
if (inverter) {
|
if (inverter) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -36,7 +36,6 @@ extern InverterProtocol* inverter;
|
||||||
// Call to initialize the build-time selected inverter. Safe to call even though inverter was not selected.
|
// Call to initialize the build-time selected inverter. Safe to call even though inverter was not selected.
|
||||||
bool setup_inverter();
|
bool setup_inverter();
|
||||||
|
|
||||||
#ifdef COMMON_IMAGE
|
|
||||||
extern uint16_t user_selected_inverter_cells;
|
extern uint16_t user_selected_inverter_cells;
|
||||||
extern uint16_t user_selected_inverter_modules;
|
extern uint16_t user_selected_inverter_modules;
|
||||||
extern uint16_t user_selected_inverter_cells_per_module;
|
extern uint16_t user_selected_inverter_cells_per_module;
|
||||||
|
@ -44,6 +43,5 @@ extern uint16_t user_selected_inverter_voltage_level;
|
||||||
extern uint16_t user_selected_inverter_ah_capacity;
|
extern uint16_t user_selected_inverter_ah_capacity;
|
||||||
extern uint16_t user_selected_inverter_battery_type;
|
extern uint16_t user_selected_inverter_battery_type;
|
||||||
extern bool user_selected_inverter_ignore_contactors;
|
extern bool user_selected_inverter_ignore_contactors;
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "PYLON-CAN.h"
|
#include "PYLON-CAN.h"
|
||||||
#include "../communication/can/comm_can.h"
|
#include "../communication/can/comm_can.h"
|
||||||
#include "../datalayer/datalayer.h"
|
#include "../datalayer/datalayer.h"
|
||||||
|
#include "../inverter/INVERTERS.h"
|
||||||
|
|
||||||
#define SEND_0 //If defined, the messages will have ID ending with 0 (useful for some inverters)
|
#define SEND_0 //If defined, the messages will have ID ending with 0 (useful for some inverters)
|
||||||
//#define SEND_1 //If defined, the messages will have ID ending with 1 (useful for some inverters)
|
//#define SEND_1 //If defined, the messages will have ID ending with 1 (useful for some inverters)
|
||||||
|
@ -351,3 +352,38 @@ void PylonInverter::send_system_data() { //System equipment information
|
||||||
transmit_can_frame(&PYLON_4291);
|
transmit_can_frame(&PYLON_4291);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PylonInverter::setup() {
|
||||||
|
if (user_selected_inverter_cells > 0) {
|
||||||
|
PYLON_7320.data.u8[0] = user_selected_inverter_cells & 0xff;
|
||||||
|
PYLON_7320.data.u8[1] = (uint8_t)(user_selected_inverter_cells >> 8);
|
||||||
|
PYLON_7321.data.u8[0] = user_selected_inverter_cells & 0xff;
|
||||||
|
PYLON_7321.data.u8[1] = (uint8_t)(user_selected_inverter_cells >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user_selected_inverter_modules > 0) {
|
||||||
|
PYLON_7320.data.u8[2] = user_selected_inverter_modules;
|
||||||
|
PYLON_7321.data.u8[2] = user_selected_inverter_modules;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user_selected_inverter_cells_per_module > 0) {
|
||||||
|
PYLON_7320.data.u8[3] = user_selected_inverter_cells_per_module;
|
||||||
|
PYLON_7321.data.u8[3] = user_selected_inverter_cells_per_module;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user_selected_inverter_voltage_level > 0) {
|
||||||
|
PYLON_7320.data.u8[4] = user_selected_inverter_voltage_level & 0xff;
|
||||||
|
PYLON_7320.data.u8[5] = (uint8_t)(user_selected_inverter_voltage_level >> 8);
|
||||||
|
PYLON_7321.data.u8[4] = user_selected_inverter_voltage_level & 0xff;
|
||||||
|
PYLON_7321.data.u8[5] = (uint8_t)(user_selected_inverter_voltage_level >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user_selected_inverter_ah_capacity > 0) {
|
||||||
|
PYLON_7320.data.u8[6] = user_selected_inverter_ah_capacity & 0xff;
|
||||||
|
PYLON_7320.data.u8[7] = (uint8_t)(user_selected_inverter_ah_capacity >> 8);
|
||||||
|
PYLON_7321.data.u8[6] = user_selected_inverter_ah_capacity & 0xff;
|
||||||
|
PYLON_7321.data.u8[7] = (uint8_t)(user_selected_inverter_ah_capacity >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
class PylonInverter : public CanInverterProtocol {
|
class PylonInverter : public CanInverterProtocol {
|
||||||
public:
|
public:
|
||||||
const char* name() override { return Name; }
|
const char* name() override { return Name; }
|
||||||
|
bool setup() override;
|
||||||
void update_values();
|
void update_values();
|
||||||
void transmit_can(unsigned long currentMillis);
|
void transmit_can(unsigned long currentMillis);
|
||||||
void map_can_frame_to_variable(CAN_frame rx_frame);
|
void map_can_frame_to_variable(CAN_frame rx_frame);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "SOLXPOW-CAN.h"
|
#include "SOLXPOW-CAN.h"
|
||||||
#include "../communication/can/comm_can.h"
|
#include "../communication/can/comm_can.h"
|
||||||
#include "../datalayer/datalayer.h"
|
#include "../datalayer/datalayer.h"
|
||||||
|
#include "../inverter/INVERTERS.h"
|
||||||
|
|
||||||
#define SEND_0 //If defined, the messages will have ID ending with 0 (useful for some inverters)
|
#define SEND_0 //If defined, the messages will have ID ending with 0 (useful for some inverters)
|
||||||
//#define SEND_1 //If defined, the messages will have ID ending with 1 (useful for some inverters)
|
//#define SEND_1 //If defined, the messages will have ID ending with 1 (useful for some inverters)
|
||||||
|
@ -353,3 +354,38 @@ void SolxpowInverter::send_system_data() { //System equipment information
|
||||||
transmit_can_frame(&SOLXPOW_4291);
|
transmit_can_frame(&SOLXPOW_4291);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SolxpowInverter::setup() {
|
||||||
|
if (user_selected_inverter_cells > 0) {
|
||||||
|
SOLXPOW_7320.data.u8[0] = user_selected_inverter_cells & 0xff;
|
||||||
|
SOLXPOW_7320.data.u8[1] = (uint8_t)(user_selected_inverter_cells >> 8);
|
||||||
|
SOLXPOW_7321.data.u8[0] = user_selected_inverter_cells & 0xff;
|
||||||
|
SOLXPOW_7321.data.u8[1] = (uint8_t)(user_selected_inverter_cells >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user_selected_inverter_modules > 0) {
|
||||||
|
SOLXPOW_7320.data.u8[2] = user_selected_inverter_modules;
|
||||||
|
SOLXPOW_7321.data.u8[2] = user_selected_inverter_modules;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user_selected_inverter_cells_per_module > 0) {
|
||||||
|
SOLXPOW_7320.data.u8[3] = user_selected_inverter_cells_per_module;
|
||||||
|
SOLXPOW_7321.data.u8[3] = user_selected_inverter_cells_per_module;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user_selected_inverter_voltage_level > 0) {
|
||||||
|
SOLXPOW_7320.data.u8[4] = user_selected_inverter_voltage_level & 0xff;
|
||||||
|
SOLXPOW_7320.data.u8[5] = (uint8_t)(user_selected_inverter_voltage_level >> 8);
|
||||||
|
SOLXPOW_7321.data.u8[4] = user_selected_inverter_voltage_level & 0xff;
|
||||||
|
SOLXPOW_7321.data.u8[5] = (uint8_t)(user_selected_inverter_voltage_level >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user_selected_inverter_ah_capacity > 0) {
|
||||||
|
SOLXPOW_7320.data.u8[6] = user_selected_inverter_ah_capacity & 0xff;
|
||||||
|
SOLXPOW_7320.data.u8[7] = (uint8_t)(user_selected_inverter_ah_capacity >> 8);
|
||||||
|
SOLXPOW_7321.data.u8[6] = user_selected_inverter_ah_capacity & 0xff;
|
||||||
|
SOLXPOW_7321.data.u8[7] = (uint8_t)(user_selected_inverter_ah_capacity >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
class SolxpowInverter : public CanInverterProtocol {
|
class SolxpowInverter : public CanInverterProtocol {
|
||||||
public:
|
public:
|
||||||
const char* name() override { return Name; }
|
const char* name() override { return Name; }
|
||||||
|
bool setup() override;
|
||||||
void update_values();
|
void update_values();
|
||||||
void transmit_can(unsigned long currentMillis);
|
void transmit_can(unsigned long currentMillis);
|
||||||
void map_can_frame_to_variable(CAN_frame rx_frame);
|
void map_can_frame_to_variable(CAN_frame rx_frame);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue