add timing for amp

This commit is contained in:
smayzy 2026-03-12 17:35:40 +01:00
parent e8e5e2728d
commit 22b36fbc01

View File

@ -10,14 +10,18 @@ MCP_CAN CAN(CAN_CS);
const byte NODE_ID = 0x01; // Change to your Sevcon node ID const byte NODE_ID = 0x01; // Change to your Sevcon node ID
const unsigned long timing = 500; const unsigned long timing = 500;
const unsigned long timing_c = 10;
unsigned long previous_time = 0; unsigned long previous_time = 0;
unsigned long current_time = 0; unsigned long current_time = 0;
unsigned long previous_time_c = 0;
int16_t rpm = 0; int16_t rpm = 0;
int16_t ubat = 0; int16_t ubat = 0;
int v = 0; int v = 0;
int ubatr = 0; int ubatr = 0;
int current = 0;
int c_max = 0;
void setup() { void setup() {
lcd.init(); lcd.init();
@ -80,5 +84,27 @@ void loop() {
lcd.print(" V "); lcd.print(" V ");
Serial.print("Tension = "); Serial.print("Tension = ");
Serial.println(ubatr); Serial.println(ubatr);
lcd.setCursor(0, 2);
lcd.print("current = ");
lcd.print(current);
lcd.print(" A ");
Serial.print("Current = ");
Serial.println(current);
lcd.setCursor(0, 3);
lcd.print("current_max = ");
lcd.print(c_max);
lcd.print(" A ");
Serial.print("current max = ");
Serial.println(c_max);
}
if (current_time - previous_time_c >= timing) {
previous_time_c = current_time;
current = (analogRead(A0) * 3);
if (current > c_max) {
c_max = current;
};
} }
} }