mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 18:29:48 +02:00
Add interval defines for chargers
This commit is contained in:
parent
c9fe3168e1
commit
fd85a9ebb2
2 changed files with 8 additions and 13 deletions
|
@ -19,12 +19,9 @@
|
|||
*/
|
||||
|
||||
/* CAN cycles and timers */
|
||||
static const int interval30ms = 30; // 30ms cycle for keepalive frames
|
||||
static const int interval200ms = 200; // 200ms cycle for commanding I/V targets
|
||||
static const int interval5000ms = 5000; // 5s status printout to serial
|
||||
static unsigned long previousMillis30ms = 0;
|
||||
static unsigned long previousMillis200ms = 0;
|
||||
static unsigned long previousMillis5000ms = 0;
|
||||
static unsigned long previousMillis30ms = 0; // 30ms cycle for keepalive frames
|
||||
static unsigned long previousMillis200ms = 0; // 200ms cycle for commanding I/V targets
|
||||
static unsigned long previousMillis5000ms = 0; // 5s status printout to serial
|
||||
|
||||
/* voltage and current settings. Validation performed to set ceiling of 3300w vol*cur */
|
||||
extern volatile float charger_setpoint_HV_VDC;
|
||||
|
@ -125,7 +122,7 @@ void send_can_chevyvolt_charger() {
|
|||
uint8_t charger_mode = MODE_DISABLED;
|
||||
|
||||
/* Send keepalive with mode every 30ms */
|
||||
if (currentMillis - previousMillis30ms >= interval30ms) {
|
||||
if (currentMillis - previousMillis30ms >= INTERVAL_30_MS) {
|
||||
previousMillis30ms = currentMillis;
|
||||
|
||||
if (charger_HV_enabled) {
|
||||
|
@ -148,7 +145,7 @@ void send_can_chevyvolt_charger() {
|
|||
}
|
||||
|
||||
/* Send current targets every 200ms */
|
||||
if (currentMillis - previousMillis200ms >= interval200ms) {
|
||||
if (currentMillis - previousMillis200ms >= INTERVAL_200_MS) {
|
||||
previousMillis200ms = currentMillis;
|
||||
|
||||
/* These values should be and are validated elsewhere, but adjust if needed
|
||||
|
@ -186,7 +183,7 @@ void send_can_chevyvolt_charger() {
|
|||
|
||||
#ifdef DEBUG_VIA_USB
|
||||
/* Serial echo every 5s of charger stats */
|
||||
if (currentMillis - previousMillis5000ms >= interval5000ms) {
|
||||
if (currentMillis - previousMillis5000ms >= INTERVAL_5_S) {
|
||||
previousMillis5000ms = currentMillis;
|
||||
Serial.printf("Charger AC in IAC=%fA VAC=%fV\n", charger_stat_ACcur, charger_stat_ACvol);
|
||||
Serial.printf("Charger HV out IDC=%fA VDC=%fV\n", charger_stat_HVcur, charger_stat_HVvol);
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
*/
|
||||
|
||||
/* CAN cycles and timers */
|
||||
static const uint8_t interval10ms = 10;
|
||||
static const uint8_t interval100ms = 100;
|
||||
static unsigned long previousMillis10ms = 0;
|
||||
static unsigned long previousMillis100ms = 0;
|
||||
|
||||
|
@ -184,7 +182,7 @@ void send_can_nissanleaf_charger() {
|
|||
unsigned long currentMillis = millis();
|
||||
|
||||
/* Send keepalive with mode every 10ms */
|
||||
if (currentMillis - previousMillis10ms >= interval10ms) {
|
||||
if (currentMillis - previousMillis10ms >= INTERVAL_10_MS) {
|
||||
previousMillis10ms = currentMillis;
|
||||
|
||||
mprun10++;
|
||||
|
@ -251,7 +249,7 @@ void send_can_nissanleaf_charger() {
|
|||
}
|
||||
|
||||
/* Send messages every 100ms here */
|
||||
if (currentMillis - previousMillis100ms >= interval100ms) {
|
||||
if (currentMillis - previousMillis100ms >= INTERVAL_100_MS) {
|
||||
previousMillis100ms = currentMillis;
|
||||
|
||||
mprun100++;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue