add timing for amp
This commit is contained in:
parent
e8e5e2728d
commit
22b36fbc01
26
can/can.ino
26
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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user