From 22b36fbc0181d8f81c6ba3e8a9060e8b02284151 Mon Sep 17 00:00:00 2001 From: smayzy Date: Thu, 12 Mar 2026 17:35:40 +0100 Subject: [PATCH] add timing for amp --- can/can.ino | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/can/can.ino b/can/can.ino index 14b2ee1..7bf4131 100644 --- a/can/can.ino +++ b/can/can.ino @@ -10,14 +10,18 @@ MCP_CAN CAN(CAN_CS); const byte NODE_ID = 0x01; // Change to your Sevcon node ID const unsigned long timing = 500; +const unsigned long timing_c = 10; unsigned long previous_time = 0; unsigned long current_time = 0; +unsigned long previous_time_c = 0; int16_t rpm = 0; int16_t ubat = 0; int v = 0; int ubatr = 0; +int current = 0; +int c_max = 0; void setup() { lcd.init(); @@ -80,5 +84,27 @@ void loop() { lcd.print(" V "); Serial.print("Tension = "); 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; + }; } }