Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Double LilyGo! #109

Merged
merged 16 commits into from
Dec 20, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add error handling write values to 0
dalathegreat committed Nov 25, 2023
commit 4f6aecfdb2888a278c36393ebf2cbd79fc8b92f7
22 changes: 7 additions & 15 deletions Software/Software.ino
Original file line number Diff line number Diff line change
@@ -16,7 +16,9 @@

// Interval settings
int intervalUpdateValues = 4800; // Interval at which to update inverter values / Modbus registers
const int interval1 = 1; // Interval for 1ms tasks
const int interval10 = 10; // Interval for 10ms tasks
unsigned long previousMillis1ms = 0;
unsigned long previousMillis10ms = 50;
unsigned long previousMillisUpdateVal = 0;

@@ -128,12 +130,9 @@ void loop() {
#ifdef DUAL_CAN
receive_can2();
#endif
<<<<<<< HEAD
#ifdef SERIAL_LINK_RECEIVER
receive_serial();
#endif
=======
>>>>>>> main

// Process
if (millis() - previousMillis10ms >= interval10) // Every 10ms
@@ -156,12 +155,9 @@ void loop() {
#ifdef DUAL_CAN
send_can2();
#endif
<<<<<<< HEAD
#ifdef SERIAL_LINK_TRANSMITTER
send_serial();
#endif
=======
>>>>>>> main
}

// Initialization functions
@@ -229,16 +225,13 @@ void init_modbus() {
pinMode(PIN_5V_EN, OUTPUT);
digitalWrite(PIN_5V_EN, HIGH);

<<<<<<< HEAD
#if defined(SERIAL_LINK_RECEIVER) || defined(SERIAL_LINK_TRANSMITTER)
Serial2.begin(9600, SERIAL_8N1, RS485_RX_PIN, RS485_TX_PIN); // If the Modbus RTU port will be used for serial link
#if defined(BYD_MODBUS) || defined(LUNA2000_MODBUS)
#error Modbus pins cannot be used for Serial and Modbus at the same time!
#endif
#endif

=======
>>>>>>> main
#ifdef BYD_MODBUS
// Init Static data to the RTU Modbus
handle_static_data_modbus_byd();
@@ -408,7 +401,6 @@ void send_can() {
#endif
}

<<<<<<< HEAD
#ifdef SERIAL_LINK_RECEIVER
//---- Receives serial data and transfers to the Inverter
void receive_serial() {
@@ -424,15 +416,15 @@ void receive_serial() {
//---- Gets data from Battery and serial Transmits the data to the Receiver
void send_serial() {
static unsigned long currentMillis = millis();
if (currentMillis - previousMillis1ms > interval1) { //--- try 2 second
previousMillis1ms = currentMillis;
manageSerialLinkTransmitter();
if (bms_status == ACTIVE) {
if (currentMillis - previousMillis1ms > interval1) { //--- try 2 second
previousMillis1ms = currentMillis;
manageSerialLinkTransmitter();
}
}
}
#endif

=======
>>>>>>> main
#ifdef DUAL_CAN
void receive_can2() { // This function is similar to receive_can, but just takes care of inverters in the 2nd bus.
// Depending on which inverter is selected, we forward this to their respective CAN routines
2 changes: 2 additions & 0 deletions Software/src/inverter/SERIAL-LINK-TRANSMITTER-INVERTER.cpp
Original file line number Diff line number Diff line change
@@ -82,6 +82,8 @@ void manageSerialLinkTransmitter() {
Serial.print(currentTime);
Serial.println(" - Transmit Failed : 60 seconds");
bms_status = 4; //FAULT
max_target_discharge_power = 0;
max_target_charge_power = 0;
LEDcolor = RED;
// throw error
}