Revised CAN Broadcast system. Added Haltech dash protocol
This commit is contained in:
parent
7c14269fc3
commit
ad93a801c4
|
@ -475,8 +475,7 @@ page = 1
|
|||
idleAdvVss = scalar, U08, 124, "km/h", 1, 0.0, 0.0, 255, 0
|
||||
mapSwitchPoint = scalar, U08, 125, "RPM", 100, 0.0, 0.0, 16320, 0
|
||||
|
||||
canBMWCluster = bits, U08, 126, [0:0], "Off", "On"
|
||||
canVAGCluster = bits, U08, 126, [1:1], "Off", "On"
|
||||
unused0_126 = bits, U08, 126, [0:2]
|
||||
;These are reserved for future use, in case of more CAN broadcasting features are added
|
||||
canWBO = bits, U08, 126, [2:3], "Off", "rusEFI WBO", "INVALID", "INVALID"
|
||||
vssAuxCh = bits, U08, 126, [4:7], "Aux0", "Aux1", "Aux2", "Aux3", "Aux4", "Aux5", "Aux6", "Aux7", "Aux8", "Aux9", "Aux10", "Aux11", "Aux12", "Aux13", "Aux14", "Aux15"
|
||||
|
@ -618,7 +617,8 @@ page = 4
|
|||
vvt2PWMdir = bits, U08, 123, [0:0], "Advance", "Retard"
|
||||
inj4CylPairing = bits, U08, 123, [1:2], "1+3 & 2+4", "1+4 & 2+3", "INVALID", "INVALID"
|
||||
dwellErrCorrect = bits, U08, 123, [3:3], "Off", "On"
|
||||
unusedBits4_123 = bits, U08, 123, [4:7]
|
||||
CANBroadcastProt= bits, U08, 123, [4:6], "Off", "BMW", "VAG", "Haltech", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
unusedBits4_123 = bits, U08, 123, [7:7]
|
||||
ANGLEFILTER_VVT = scalar, U08, 124, "%", 1.0, 0.0, 0, 100, 0
|
||||
FILTER_FLEX = scalar, U08, 125, "%", 1.0, 0.0, 0, 240, 0
|
||||
|
||||
|
@ -2440,8 +2440,7 @@ menuDialog = main
|
|||
dwellTable = "Sets the dwell time in milliseconds based on RPM/load. This can be used to reduce stress/wear on ignition system where long dwell is not needed. And other areas can use longer dwell value if needed for stronger spark. Battery voltage correction is applied for these dwell values."
|
||||
useDwellMap = "In normal operation mode this is set to No and speeduino will use fixed running dwell value. But if different dwell values are required across engine RPM/load range, this can be set to Yes and separate Dwell table defines running dwell value."
|
||||
tachoMode = "The output mode for the tacho pulse. Fixed timing will produce a pulse that is always of the same duration, which works better with mode modern digital tachos. Dwell based output creates a pulse that is matched to the coil/s dwell time. If enabled the tacho pulse duration and timing is same as coil dwell and the number of pulses is same as number of ignition events. This can work better on some styles of tacho but note that the pulse duration might become problem on higher cylinder number engines."
|
||||
canBMWCluster = "Enables CAN broadcasting for BMW E46, E39 and E38 instrument clusters with message ID's 0x316, 0x329 and 0x545"
|
||||
canVAGCluster = "Enables CAN broadcasting for VAG instrument clusters with message ID's 0x280 and 0x5A0"
|
||||
CANBroadcastProt= "The CAN Broadast protocol that should be used for outputing system values to other devices (Eg Dash Clusters)"
|
||||
canWBO = "Enables to recive AFR via CAN for supported controllers"
|
||||
caninputEndianess= "Byte ordering for values with two bytes."
|
||||
|
||||
|
@ -3595,8 +3594,7 @@ menuDialog = main
|
|||
commandButton = "Reboot to bootloader", cmdstm32bootloader
|
||||
|
||||
dialog = CanBcast, "CAN Broadcasting menu"
|
||||
field = "BMW Instrument Cluster Broadcast", canBMWCluster
|
||||
field = "VAG Instrument Cluster Broadcast", canVAGCluster
|
||||
field = "CAN Broadcast Protocol", CANBroadcastProt
|
||||
|
||||
dialog = Auxin_north
|
||||
displayOnlyField = !"Secondary Serial DISABLED", blankfield, {enable_secondarySerial == 0},{enable_secondarySerial == 0}
|
||||
|
|
|
@ -57,25 +57,74 @@ void CAN_write()
|
|||
Can0.write(outMsg);
|
||||
}
|
||||
|
||||
void sendBMWCluster()
|
||||
void sendCANBroadcast(uint8_t frequency)
|
||||
{
|
||||
outMsg.flags.extended = 0; //Make sure to set this to standard
|
||||
DashMessage(CAN_BMW_DME1);
|
||||
Can0.write(outMsg);
|
||||
DashMessage(CAN_BMW_DME2);
|
||||
Can0.write(outMsg);
|
||||
DashMessage(CAN_BMW_DME4);
|
||||
Can0.write(outMsg);
|
||||
switch(configPage4.CANBroadcastProtocol)
|
||||
{
|
||||
case CAN_BROADCAST_PROTOCOL_OFF:
|
||||
break;
|
||||
case CAN_BROADCAST_PROTOCOL_BMW:
|
||||
if(frequency == 30)
|
||||
{
|
||||
outMsg.flags.extended = 0; //Make sure to set this to standard
|
||||
DashMessage(CAN_BMW_DME1);
|
||||
Can0.write(outMsg);
|
||||
DashMessage(CAN_BMW_DME2);
|
||||
Can0.write(outMsg);
|
||||
}
|
||||
else if(frequency == 10)
|
||||
{
|
||||
outMsg.flags.extended = 0; //Make sure to set this to standard
|
||||
DashMessage(CAN_BMW_DME4);
|
||||
Can0.write(outMsg);
|
||||
}
|
||||
break;
|
||||
case CAN_BROADCAST_PROTOCOL_VAG:
|
||||
//All VAG broadcasts are at 30Hz
|
||||
if(frequency == 30)
|
||||
{
|
||||
outMsg.flags.extended = 0; //Make sure to set this to standard
|
||||
DashMessage(CAN_VAG_RPM);
|
||||
Can0.write(outMsg);
|
||||
DashMessage(CAN_VAG_VSS);
|
||||
Can0.write(outMsg);
|
||||
}
|
||||
break;
|
||||
case CAN_BROADCAST_PROTOCOL_HALTECH:
|
||||
//Haltech has broadcasts over multiple frequencies
|
||||
if(frequency == 50)
|
||||
{
|
||||
DashMessage(CAN_HALTECH_DATA1);
|
||||
Can0.write(outMsg);
|
||||
DashMessage(CAN_HALTECH_DATA2);
|
||||
Can0.write(outMsg);
|
||||
DashMessage(CAN_HALTECH_DATA3);
|
||||
Can0.write(outMsg);
|
||||
DashMessage(CAN_HALTECH_PW);
|
||||
Can0.write(outMsg);
|
||||
}
|
||||
else if(frequency == 15)
|
||||
{
|
||||
//Note: Haltech lists these as being 20Hz messages, but as we don't have a 20Hz flag we'll use 15Hz instead
|
||||
DashMessage(CAN_HALTECH_LAMBDA);
|
||||
Can0.write(outMsg);
|
||||
DashMessage(CAN_HALTECH_TRIGGER);
|
||||
Can0.write(outMsg);
|
||||
}
|
||||
else if(frequency == 10)
|
||||
{
|
||||
DashMessage(CAN_HALTECH_DATA4);
|
||||
Can0.write(outMsg);
|
||||
DashMessage(CAN_HALTECH_DATA5);
|
||||
Can0.write(outMsg);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void sendVAGCluster()
|
||||
{
|
||||
outMsg.flags.extended = 0; //Make sure to set this to standard
|
||||
DashMessage(CAN_VAG_RPM);
|
||||
Can0.write(outMsg);
|
||||
DashMessage(CAN_VAG_VSS);
|
||||
Can0.write(outMsg);
|
||||
}
|
||||
void receiveCANwbo()
|
||||
{
|
||||
// Currently only RusEFI CAN Wideband supported: https://github.com/mck1117/wideband
|
||||
|
@ -114,16 +163,29 @@ void receiveCANwbo()
|
|||
}
|
||||
}
|
||||
}
|
||||
// switch case for gathering all data to message based on CAN Id.
|
||||
|
||||
// All supported definitions/protocols for CAN Dash broadcasts
|
||||
void DashMessage(uint16_t DashMessageID)
|
||||
{
|
||||
uint16_t temp_TPS;
|
||||
uint16_t temp_MAP;
|
||||
uint16_t temp_Baro;
|
||||
uint16_t temp_CLT;
|
||||
uint16_t temp_IAT;
|
||||
uint16_t temp_fuelLoad;
|
||||
uint16_t temp_fuelTemp;
|
||||
int16_t temp_Advance;
|
||||
uint16_t temp_DutyCycle;
|
||||
uint16_t temp_Lambda;
|
||||
uint16_t temp_BoostTarget;
|
||||
|
||||
outMsg.id = DashMessageID;
|
||||
switch (DashMessageID)
|
||||
{
|
||||
case CAN_BMW_DME1:
|
||||
uint32_t temp_RPM;
|
||||
temp_RPM = currentStatus.RPM * 64; //RPM conversion is currentStatus.RPM * 6.4, but this does it without floats.
|
||||
temp_RPM = temp_RPM / 10;
|
||||
outMsg.id = DashMessageID;
|
||||
temp_RPM = currentStatus.RPM * 64UL; //RPM conversion is currentStatus.RPM * 6.4, but this does it without floats.
|
||||
temp_RPM = temp_RPM / 10U;
|
||||
outMsg.len = 8;
|
||||
outMsg.buf[0] = 0x05; //bitfield, Bit0 = 1 = terminal 15 on detected, Bit2 = 1 = the ASC message ASC1 was received within the last 500 ms and contains no plausibility errors
|
||||
outMsg.buf[1] = 0x0C; //Indexed Engine Torque in % of C_TQ_STND TBD do torque calculation.
|
||||
|
@ -136,29 +198,23 @@ void DashMessage(uint16_t DashMessageID)
|
|||
break;
|
||||
|
||||
case CAN_BMW_DME2:
|
||||
uint8_t temp_TPS;
|
||||
uint8_t temp_BARO;
|
||||
uint16_t temp_CLT;
|
||||
temp_TPS = map(currentStatus.TPS, 0, 200, 1, 254);//TPS value conversion (from 0x01 to 0xFE)
|
||||
temp_CLT = (((currentStatus.coolant - CALIBRATION_TEMPERATURE_OFFSET) + 48)*4/3); //CLT conversion (actual value to add is 48.373, but close enough)
|
||||
if (temp_CLT > 255) { temp_CLT = 255; } //CLT conversion can yield to higher values than what fits to byte, so limit the maximum value to 255.
|
||||
temp_BARO = currentStatus.baro;
|
||||
|
||||
outMsg.id = DashMessageID;
|
||||
outMsg.len = 7;
|
||||
outMsg.len = 8;
|
||||
outMsg.buf[0] = 0x11; //Multiplexed Information
|
||||
outMsg.buf[1] = temp_CLT;
|
||||
outMsg.buf[2] = temp_BARO;
|
||||
outMsg.buf[2] = currentStatus.baro;
|
||||
outMsg.buf[3] = 0x08; //bitfield, Bit0 = 0 = Clutch released, Bit 3 = 1 = engine running
|
||||
outMsg.buf[4] = 0x00; //TPS_VIRT_CRU_CAN (Not used)
|
||||
outMsg.buf[5] = temp_TPS;
|
||||
outMsg.buf[5] = (uint8_t)temp_TPS;
|
||||
outMsg.buf[6] = 0x00; //bitfield, Bit0 = 0 = brake not actuated, Bit1 = 0 = brake switch system OK etc...
|
||||
outMsg.buf[7] = 0x00; //not used, but set to zero just in case.
|
||||
break;
|
||||
|
||||
case 0x545: //fuel consumption and CEl light for BMW e46/e39/e38 instrument cluster
|
||||
case CAN_BMW_DME4: //fuel consumption and CEl light for BMW e46/e39/e38 instrument cluster
|
||||
//fuel consumption calculation not implemented yet. But this still needs to be sent to get rid of the CEL and EML fault lights on the dash.
|
||||
outMsg.id = DashMessageID;
|
||||
outMsg.len = 5;
|
||||
outMsg.buf[0] = 0x00; //Check engine light (binary 10), Cruise light (binary 1000), EML (binary 10000).
|
||||
outMsg.buf[1] = 0x00; //LSB Fuel consumption
|
||||
|
@ -168,9 +224,8 @@ void DashMessage(uint16_t DashMessageID)
|
|||
outMsg.buf[4] = 0x7E; //this is oil temp
|
||||
break;
|
||||
|
||||
case 0x280: //RPM for VW instrument cluster
|
||||
case CAN_VAG_RPM: //RPM for VW instrument cluster
|
||||
temp_RPM = currentStatus.RPM * 4; //RPM conversion
|
||||
outMsg.id = DashMessageID;
|
||||
outMsg.len = 8;
|
||||
outMsg.buf[0] = 0x49;
|
||||
outMsg.buf[1] = 0x0E;
|
||||
|
@ -182,10 +237,9 @@ void DashMessage(uint16_t DashMessageID)
|
|||
outMsg.buf[7] = 0x0E;
|
||||
break;
|
||||
|
||||
case 0x5A0: //VSS for VW instrument cluster
|
||||
case CAN_VAG_VSS: //VSS for VW instrument cluster
|
||||
uint16_t temp_VSS;
|
||||
temp_VSS = currentStatus.vss * 133; //VSS conversion
|
||||
outMsg.id = DashMessageID;
|
||||
temp_VSS = currentStatus.vss * 133U; //VSS conversion
|
||||
outMsg.len = 8;
|
||||
outMsg.buf[0] = 0xFF;
|
||||
outMsg.buf[1] = lowByte(temp_VSS);
|
||||
|
@ -197,6 +251,106 @@ void DashMessage(uint16_t DashMessageID)
|
|||
outMsg.buf[7] = 0xAD;
|
||||
break;
|
||||
|
||||
case CAN_HALTECH_DATA1:
|
||||
temp_MAP = currentStatus.MAP * 10U;
|
||||
temp_TPS = currentStatus.TPS * 5U; //TPS value to 0.1. TPS is already in 0.5 increments, so multiply by 5
|
||||
outMsg.len = 8;
|
||||
outMsg.buf[0] = lowByte(currentStatus.RPM);
|
||||
outMsg.buf[1] = highByte(currentStatus.RPM);
|
||||
outMsg.buf[2] = lowByte(temp_MAP);
|
||||
outMsg.buf[3] = highByte(temp_MAP);
|
||||
outMsg.buf[4] = lowByte(temp_TPS);
|
||||
outMsg.buf[5] = highByte(temp_TPS);
|
||||
//Next 2 bytes are coolant pressure, not supported
|
||||
outMsg.buf[6] = 0x00;
|
||||
outMsg.buf[7] = 0x00;
|
||||
break;
|
||||
|
||||
case CAN_HALTECH_DATA2:
|
||||
temp_fuelLoad = currentStatus.fuelLoad * 10U;
|
||||
outMsg.len = 8;
|
||||
outMsg.buf[0] = 0x00; //Fuel pressure
|
||||
outMsg.buf[1] = 0x00;
|
||||
outMsg.buf[2] = 0x00; //Oil Pressure
|
||||
outMsg.buf[3] = 0x00;
|
||||
outMsg.buf[4] = lowByte(temp_fuelLoad);
|
||||
outMsg.buf[5] = highByte(temp_fuelLoad);
|
||||
outMsg.buf[6] = 0x00; //Wastegate pressure
|
||||
outMsg.buf[7] = 0x00;
|
||||
break;
|
||||
|
||||
case CAN_HALTECH_DATA3:
|
||||
temp_Advance = currentStatus.advance * 10U; //Note: Signed value
|
||||
//Convert PW into duty cycle
|
||||
temp_DutyCycle = (currentStatus.PW1 * 100UL * currentStatus.nSquirts) / revolutionTime;
|
||||
if (configPage2.strokes == FOUR_STROKE) { temp_DutyCycle = temp_DutyCycle / 2U; }
|
||||
|
||||
outMsg.len = 8;
|
||||
outMsg.buf[0] = lowByte(temp_DutyCycle);
|
||||
outMsg.buf[1] = highByte(temp_DutyCycle);
|
||||
outMsg.buf[2] = 0x00; //TODO: Staging Duty Cycle.
|
||||
outMsg.buf[3] = 0x00;
|
||||
outMsg.buf[4] = lowByte(temp_Advance);
|
||||
outMsg.buf[5] = highByte(temp_Advance);
|
||||
outMsg.buf[6] = 0x00; //Unused
|
||||
outMsg.buf[7] = 0x00; //Unused
|
||||
break;
|
||||
|
||||
case CAN_HALTECH_PW:
|
||||
outMsg.len = 8;
|
||||
outMsg.buf[0] = lowByte(currentStatus.PW1);
|
||||
outMsg.buf[1] = highByte(currentStatus.PW1);
|
||||
outMsg.buf[2] = lowByte(currentStatus.PW2);
|
||||
outMsg.buf[3] = highByte(currentStatus.PW2);
|
||||
outMsg.buf[4] = lowByte(currentStatus.PW3);
|
||||
outMsg.buf[5] = highByte(currentStatus.PW3);
|
||||
outMsg.buf[6] = lowByte(currentStatus.PW4);
|
||||
outMsg.buf[7] = highByte(currentStatus.PW4);
|
||||
break;
|
||||
|
||||
case CAN_HALTECH_LAMBDA:
|
||||
temp_Lambda = (currentStatus.O2 * 1000U) / configPage2.stoich;
|
||||
outMsg.len = 8;
|
||||
outMsg.buf[0] = lowByte(temp_Lambda);
|
||||
outMsg.buf[1] = highByte(temp_Lambda);
|
||||
temp_Lambda = (currentStatus.O2_2 * 1000U) / configPage2.stoich;
|
||||
outMsg.buf[2] = lowByte(temp_Lambda);
|
||||
outMsg.buf[3] = highByte(temp_Lambda);
|
||||
outMsg.buf[4] = 0x00; //Lambda 3
|
||||
outMsg.buf[5] = 0x00; //Lambda 3
|
||||
outMsg.buf[6] = 0x00; //Lambda 4
|
||||
outMsg.buf[7] = 0x00; //Lambda 4
|
||||
break;
|
||||
|
||||
case CAN_HALTECH_DATA4:
|
||||
temp_BoostTarget = currentStatus.boostTarget * 10U;
|
||||
temp_Baro = currentStatus.baro * 10U;
|
||||
outMsg.len = 8;
|
||||
outMsg.buf[0] = currentStatus.battery10;
|
||||
outMsg.buf[1] = 0x00; //High byte for battery voltage, which is not used (Max battery voltage is 25.5 or 255)
|
||||
outMsg.buf[2] = 0x00; //Unused
|
||||
outMsg.buf[3] = 0x00; //Unused
|
||||
outMsg.buf[4] = lowByte(temp_BoostTarget);
|
||||
outMsg.buf[5] = highByte(temp_BoostTarget);
|
||||
outMsg.buf[6] = lowByte(temp_Baro);
|
||||
outMsg.buf[7] = highByte(temp_Baro);
|
||||
break;
|
||||
|
||||
case CAN_HALTECH_DATA5:
|
||||
temp_CLT = (currentStatus.coolant + 273U) * 10U; //Convert to Kelvin and adjust to 0.1
|
||||
temp_IAT = (currentStatus.IAT + 273U) * 10U; //Convert to Kelvin and adjust to 0.1
|
||||
temp_fuelTemp = (currentStatus.fuelTemp + 273U) * 10U; //Convert to Kelvin and adjust to 0.1
|
||||
outMsg.len = 8;
|
||||
outMsg.buf[0] = lowByte(temp_CLT);
|
||||
outMsg.buf[1] = highByte(temp_CLT);
|
||||
outMsg.buf[2] = lowByte(temp_IAT);
|
||||
outMsg.buf[3] = highByte(temp_IAT);
|
||||
outMsg.buf[4] = lowByte(temp_fuelTemp);
|
||||
outMsg.buf[5] = highByte(temp_fuelTemp);
|
||||
outMsg.buf[6] = 0x00; //Oil Temperature
|
||||
outMsg.buf[7] = 0x00; //Oil Temperature
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,22 @@
|
|||
#define CAN_VAG_RPM 0x280
|
||||
#define CAN_VAG_VSS 0x5A0
|
||||
|
||||
//For Haltech IC-7 and IC-10 digital dashes
|
||||
#define CAN_HALTECH_DATA1 0x360 //RPM, MAP, TPS, Coolant Pressure. 50Hz
|
||||
#define CAN_HALTECH_DATA2 0x361 //Fuel Pressure, Oil Pressure, Load, Wastegate Pressure. 50Hz
|
||||
#define CAN_HALTECH_DATA3 0x362 //Advance, INJ Stage 1/2 duty cycles. 50Hz
|
||||
#define CAN_HALTECH_PW 0x364 //Pulsewidth 1-4. 50Hz
|
||||
#define CAN_HALTECH_LAMBDA 0x368 //Lambda 1-4. 20Hz
|
||||
#define CAN_HALTECH_TRIGGER 0x369 //Trigger Counter, sync level, sync error count. 20Hz
|
||||
#define CAN_HALTECH_DATA4 0x372 //Baro, BatteryV, Target boost. 10Hz
|
||||
#define CAN_HALTECH_DATA5 0x3E0 //IAT, CLT, Fuel Temp, Oil Temp. 10Hz
|
||||
|
||||
#define CAN_BROADCAST_PROTOCOL_OFF 0
|
||||
#define CAN_BROADCAST_PROTOCOL_BMW 1
|
||||
#define CAN_BROADCAST_PROTOCOL_VAG 2
|
||||
#define CAN_BROADCAST_PROTOCOL_HALTECH 3
|
||||
|
||||
|
||||
#define CAN_WBO_RUSEFI 1
|
||||
|
||||
#define TS_CAN_OFFSET 0x100
|
||||
|
@ -21,8 +37,7 @@
|
|||
void initCAN();
|
||||
int CAN_read();
|
||||
void CAN_write();
|
||||
void sendBMWCluster();
|
||||
void sendVAGCluster();
|
||||
void sendCANBroadcast(uint8_t);
|
||||
void receiveCANwbo();
|
||||
void DashMessages(uint16_t DashMessageID);
|
||||
void can_Command(void);
|
||||
|
|
|
@ -174,6 +174,7 @@
|
|||
#define BIT_TIMER_10HZ 2
|
||||
#define BIT_TIMER_15HZ 3
|
||||
#define BIT_TIMER_30HZ 4
|
||||
#define BIT_TIMER_50HZ 5
|
||||
#define BIT_TIMER_200HZ 6
|
||||
#define BIT_TIMER_1KHZ 7
|
||||
|
||||
|
@ -862,8 +863,8 @@ struct config2 {
|
|||
byte idleAdvVss;
|
||||
byte mapSwitchPoint;
|
||||
|
||||
byte canBMWCluster : 1;
|
||||
byte canVAGCluster : 1;
|
||||
byte unused1_126_1 : 1;
|
||||
byte unused1_126_2 : 1;
|
||||
byte canWBO : 2 ;
|
||||
byte vssAuxCh : 4;
|
||||
|
||||
|
@ -972,7 +973,8 @@ struct config4 {
|
|||
byte vvt2PWMdir : 1;
|
||||
byte inj4cylPairing : 2;
|
||||
byte dwellErrCorrect : 1;
|
||||
byte unusedBits4 : 4;
|
||||
byte CANBroadcastProtocol : 3;
|
||||
byte unusedBits4 : 1;
|
||||
byte ANGLEFILTER_VVT;
|
||||
byte FILTER_FLEX;
|
||||
byte vvtMinClt;
|
||||
|
|
|
@ -208,7 +208,44 @@ void loop(void)
|
|||
BIT_SET(ADCSRA,ADIE); //Enable ADC interrupt
|
||||
#endif
|
||||
}
|
||||
|
||||
if(BIT_CHECK(LOOP_TIMER, BIT_TIMER_50HZ)) //50 hertz
|
||||
{
|
||||
BIT_CLEAR(TIMER_mask, BIT_TIMER_50HZ);
|
||||
|
||||
#if defined(NATIVE_CAN_AVAILABLE)
|
||||
sendCANBroadcast(50);
|
||||
#endif
|
||||
|
||||
}
|
||||
if(BIT_CHECK(LOOP_TIMER, BIT_TIMER_30HZ)) //30 hertz
|
||||
{
|
||||
BIT_CLEAR(TIMER_mask, BIT_TIMER_30HZ);
|
||||
//Most boost tends to run at about 30Hz, so placing it here ensures a new target time is fetched frequently enough
|
||||
boostControl();
|
||||
//VVT may eventually need to be synced with the cam readings (ie run once per cam rev) but for now run at 30Hz
|
||||
vvtControl();
|
||||
//Water methanol injection
|
||||
wmiControl();
|
||||
#if TPS_READ_FREQUENCY == 30
|
||||
readTPS();
|
||||
#endif
|
||||
if (configPage2.canWBO == 0)
|
||||
{
|
||||
readO2();
|
||||
readO2_2();
|
||||
}
|
||||
|
||||
#if defined(NATIVE_CAN_AVAILABLE)
|
||||
sendCANBroadcast(30);
|
||||
#endif
|
||||
|
||||
#ifdef SD_LOGGING
|
||||
if(configPage13.onboard_log_file_rate == LOGGER_RATE_30HZ) { writeSDLogEntry(); }
|
||||
#endif
|
||||
|
||||
//Check for any outstanding EEPROM writes.
|
||||
if( (isEepromWritePending() == true) && (serialStatusFlag == SERIAL_INACTIVE) && (micros() > deferEEPROMWritesUntil)) { writeAllConfig(); }
|
||||
}
|
||||
if (BIT_CHECK(LOOP_TIMER, BIT_TIMER_15HZ)) //Every 32 loops
|
||||
{
|
||||
BIT_CLEAR(TIMER_mask, BIT_TIMER_15HZ);
|
||||
|
@ -225,11 +262,12 @@ void loop(void)
|
|||
|
||||
checkLaunchAndFlatShift(); //Check for launch control and flat shift being active
|
||||
|
||||
#if defined(NATIVE_CAN_AVAILABLE)
|
||||
sendCANBroadcast(15);
|
||||
#endif
|
||||
|
||||
//And check whether the tooth log buffer is ready
|
||||
if(toothHistoryIndex > TOOTH_LOG_SIZE) { BIT_SET(currentStatus.status1, BIT_STATUS1_TOOTHLOG1READY); }
|
||||
|
||||
|
||||
|
||||
}
|
||||
if(BIT_CHECK(LOOP_TIMER, BIT_TIMER_10HZ)) //10 hertz
|
||||
{
|
||||
|
@ -244,38 +282,14 @@ void loop(void)
|
|||
currentStatus.vss = getSpeed();
|
||||
currentStatus.gear = getGear();
|
||||
|
||||
#if defined(NATIVE_CAN_AVAILABLE)
|
||||
sendCANBroadcast(10);
|
||||
#endif
|
||||
|
||||
#ifdef SD_LOGGING
|
||||
if(configPage13.onboard_log_file_rate == LOGGER_RATE_10HZ) { writeSDLogEntry(); }
|
||||
#endif
|
||||
}
|
||||
if(BIT_CHECK(LOOP_TIMER, BIT_TIMER_30HZ)) //30 hertz
|
||||
{
|
||||
BIT_CLEAR(TIMER_mask, BIT_TIMER_30HZ);
|
||||
//Most boost tends to run at about 30Hz, so placing it here ensures a new target time is fetched frequently enough
|
||||
boostControl();
|
||||
//VVT may eventually need to be synced with the cam readings (ie run once per cam rev) but for now run at 30Hz
|
||||
vvtControl();
|
||||
//Water methanol injection
|
||||
wmiControl();
|
||||
#if defined(NATIVE_CAN_AVAILABLE)
|
||||
if (configPage2.canBMWCluster == true) { sendBMWCluster(); }
|
||||
if (configPage2.canVAGCluster == true) { sendVAGCluster(); }
|
||||
#endif
|
||||
#if TPS_READ_FREQUENCY == 30
|
||||
readTPS();
|
||||
#endif
|
||||
if (configPage2.canWBO == 0)
|
||||
{
|
||||
readO2();
|
||||
readO2_2();
|
||||
}
|
||||
#ifdef SD_LOGGING
|
||||
if(configPage13.onboard_log_file_rate == LOGGER_RATE_30HZ) { writeSDLogEntry(); }
|
||||
#endif
|
||||
|
||||
//Check for any outstanding EEPROM writes.
|
||||
if( (isEepromWritePending() == true) && (serialStatusFlag == SERIAL_INACTIVE) && (micros() > deferEEPROMWritesUntil)) { writeAllConfig(); }
|
||||
}
|
||||
if (BIT_CHECK(LOOP_TIMER, BIT_TIMER_4HZ))
|
||||
{
|
||||
BIT_CLEAR(TIMER_mask, BIT_TIMER_4HZ);
|
||||
|
|
|
@ -27,6 +27,7 @@ Timers are typically low resolution (Compared to Schedulers), with maximum frequ
|
|||
|
||||
volatile uint16_t lastRPM_100ms; //Need to record this for rpmDOT calculation
|
||||
volatile byte loop5ms;
|
||||
volatile byte loop20ms;
|
||||
volatile byte loop33ms;
|
||||
volatile byte loop66ms;
|
||||
volatile byte loop100ms;
|
||||
|
@ -50,6 +51,7 @@ void initialiseTimers(void)
|
|||
{
|
||||
lastRPM_100ms = 0;
|
||||
loop5ms = 0;
|
||||
loop20ms = 0;
|
||||
loop33ms = 0;
|
||||
loop66ms = 0;
|
||||
loop100ms = 0;
|
||||
|
@ -79,6 +81,7 @@ void oneMSInterval(void) //Most ARM chips can simply call a function
|
|||
|
||||
//Increment Loop Counters
|
||||
loop5ms++;
|
||||
loop20ms++;
|
||||
loop33ms++;
|
||||
loop66ms++;
|
||||
loop100ms++;
|
||||
|
@ -164,11 +167,18 @@ void oneMSInterval(void) //Most ARM chips can simply call a function
|
|||
}
|
||||
|
||||
//200Hz loop
|
||||
if (loop5ms == 5)
|
||||
if(loop5ms == 5)
|
||||
{
|
||||
loop5ms = 0; //Reset counter
|
||||
BIT_SET(TIMER_mask, BIT_TIMER_200HZ);
|
||||
}
|
||||
}
|
||||
|
||||
//50Hz loop
|
||||
if(loop20ms == 20)
|
||||
{
|
||||
loop20ms = 0; //Reset counter
|
||||
BIT_SET(TIMER_mask, BIT_TIMER_50HZ);
|
||||
}
|
||||
|
||||
//30Hz loop
|
||||
if (loop33ms == 33)
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "sensors.h"
|
||||
#include "updates.h"
|
||||
#include "pages.h"
|
||||
#include "comms_CAN.h"
|
||||
#include EEPROM_LIB_H //This is defined in the board .h files
|
||||
|
||||
void doUpdates(void)
|
||||
|
@ -623,8 +624,7 @@ void doUpdates(void)
|
|||
configPage6.tachoMode = 0;
|
||||
|
||||
//CAN broadcast introduced
|
||||
configPage2.canBMWCluster = 0;
|
||||
configPage2.canVAGCluster = 0;
|
||||
configPage4.CANBroadcastProtocol = CAN_BROADCAST_PROTOCOL_OFF;
|
||||
|
||||
configPage15.boostDCWhenDisabled = 0;
|
||||
configPage15.boostControlEnable = EN_BOOST_CONTROL_BARO;
|
||||
|
@ -757,6 +757,11 @@ void doUpdates(void)
|
|||
//202405
|
||||
configPage10.knock_mode = KNOCK_MODE_OFF;
|
||||
|
||||
//Change the CAN Broadcast settings to be a selection
|
||||
//Note that 1 preference will be lost if both BMW AND VAG protocols were enabled, but that is not a likely combination.
|
||||
if(configPage2.unused1_126_1 == true) { configPage4.CANBroadcastProtocol = CAN_BROADCAST_PROTOCOL_BMW; } //unused1_126_1 was canBMWCluster
|
||||
if(configPage2.unused1_126_2 == true) { configPage4.CANBroadcastProtocol = CAN_BROADCAST_PROTOCOL_VAG; } //unused1_126_2 was canVAGCluster
|
||||
|
||||
writeAllConfig();
|
||||
storeEEPROMVersion(24);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue