mirror of https://github.com/rusefi/8Ch-EGT.git
Add fault detection and error codes
This commit is contained in:
parent
63be5d81bb
commit
e51b079d96
|
@ -88,6 +88,7 @@ void CANInit(enum BITRATE bitrate)
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
pinMode(LED_BUILTIN, OUTPUT);
|
||||||
MAX31855_OK_bits = 0;
|
MAX31855_OK_bits = 0;
|
||||||
Serial.begin(115200); //debug
|
Serial.begin(115200); //debug
|
||||||
Serial3.begin(115200); //data to speeduino
|
Serial3.begin(115200); //data to speeduino
|
||||||
|
@ -195,7 +196,32 @@ void loop() {
|
||||||
for (int i=0; i<8; i++) {
|
for (int i=0; i<8; i++) {
|
||||||
if (bitRead(MAX31855_OK_bits, i) == 1){
|
if (bitRead(MAX31855_OK_bits, i) == 1){
|
||||||
rawData[i] = MAX31855_chips[i].readRawData();
|
rawData[i] = MAX31855_chips[i].readRawData();
|
||||||
EGT[i] = (MAX31855_chips[i].getTemperature(rawData[i]));
|
Serial.print("EGT");
|
||||||
|
Serial.print(i+1);
|
||||||
|
switch (MAX31855_chips[i].detectThermocouple(rawData[i]))
|
||||||
|
{
|
||||||
|
case MAX31855_THERMOCOUPLE_OK:
|
||||||
|
EGT[i] = (MAX31855_chips[i].getTemperature(rawData[i]));
|
||||||
|
Serial.print(" Temp: ");
|
||||||
|
Serial.println(EGT[i]);
|
||||||
|
break;
|
||||||
|
case MAX31855_THERMOCOUPLE_SHORT_TO_VCC:
|
||||||
|
Serial.println(" SHORT TO VCC");
|
||||||
|
EGT[i] = 2000;
|
||||||
|
break;
|
||||||
|
case MAX31855_THERMOCOUPLE_SHORT_TO_GND:
|
||||||
|
Serial.println(" SHORT TO GND");
|
||||||
|
EGT[i] = 3000;
|
||||||
|
break;
|
||||||
|
case MAX31855_THERMOCOUPLE_NOT_CONNECTED:
|
||||||
|
Serial.println(" NOT CONNECTED");
|
||||||
|
EGT[i] = 4000;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Serial.println(" MAX31855 ERROR");
|
||||||
|
EGT[i] = 5000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
ColdJunction[i] = (MAX31855_chips[i].getColdJunctionTemperature(rawData[i]));
|
ColdJunction[i] = (MAX31855_chips[i].getColdJunctionTemperature(rawData[i]));
|
||||||
if (i < 4){
|
if (i < 4){
|
||||||
CAN_msg_14.data[2*i] = lowByte(uint16_t(EGT[i]));
|
CAN_msg_14.data[2*i] = lowByte(uint16_t(EGT[i]));
|
||||||
|
@ -214,14 +240,11 @@ void loop() {
|
||||||
else{
|
else{
|
||||||
CANSend(&CAN_msg_58);
|
CANSend(&CAN_msg_58);
|
||||||
}
|
}
|
||||||
Serial.print("EGT");
|
|
||||||
Serial.print(i+1);
|
|
||||||
Serial.print(" Temp: ");
|
|
||||||
Serial.println(EGT[i]);
|
|
||||||
Serial.print("Cold Junction");
|
Serial.print("Cold Junction");
|
||||||
Serial.print(i+1);
|
Serial.print(i+1);
|
||||||
Serial.print(" Temp: ");
|
Serial.print(" Temp: ");
|
||||||
Serial.println(ColdJunction[i]);
|
Serial.println(ColdJunction[i]);
|
||||||
|
if (i == 1){ digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); } // Just flash bluilt in led in bluepill to see that the whole thing is working
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue