diff --git a/firmware/boards/f1_dual/board.h b/firmware/boards/f1_dual/board.h index c7e2df4..9e1b7a2 100644 --- a/firmware/boards/f1_dual/board.h +++ b/firmware/boards/f1_dual/board.h @@ -92,7 +92,7 @@ * PA15 - SPI_CS2 (output pushpull, 2 MHz) */ #define VAL_GPIOACRL 0x00000BB0 /* PA7...PA0 */ -#define VAL_GPIOACRH 0x288B88B2 /* PA15...PA8 */ +#define VAL_GPIOACRH 0x288B8892 /* PA15...PA8 */ #define VAL_GPIOAODR 0x0000FFFF /* diff --git a/firmware/boards/f1_dual/wideband_board_config.h b/firmware/boards/f1_dual/wideband_board_config.h index fadd12a..80e2e94 100644 --- a/firmware/boards/f1_dual/wideband_board_config.h +++ b/firmware/boards/f1_dual/wideband_board_config.h @@ -1,7 +1,7 @@ #pragma once // TS settings -#define TS_SIGNATURE "rusEFI 2022.05.29.wideband_dual" +#define TS_SIGNATURE "rusEFI 2022.12.02.wideband_dual" // This board implements two channels #define AFR_CHANNELS 2 diff --git a/firmware/boards/f1_rev2/wideband_board_config.h b/firmware/boards/f1_rev2/wideband_board_config.h index faa7a10..19db87f 100644 --- a/firmware/boards/f1_rev2/wideband_board_config.h +++ b/firmware/boards/f1_rev2/wideband_board_config.h @@ -1,7 +1,7 @@ #pragma once // TS settings -#define TS_SIGNATURE "rusEFI 2022.05.29.wideband_f1" +#define TS_SIGNATURE "rusEFI 2022.12.02.wideband_f1" // Fundamental board constants #define VCC_VOLTS (3.3f) diff --git a/firmware/boards/f1_rev3/wideband_board_config.h b/firmware/boards/f1_rev3/wideband_board_config.h index faa7a10..19db87f 100644 --- a/firmware/boards/f1_rev3/wideband_board_config.h +++ b/firmware/boards/f1_rev3/wideband_board_config.h @@ -1,7 +1,7 @@ #pragma once // TS settings -#define TS_SIGNATURE "rusEFI 2022.05.29.wideband_f1" +#define TS_SIGNATURE "rusEFI 2022.12.02.wideband_f1" // Fundamental board constants #define VCC_VOLTS (3.3f) diff --git a/firmware/boards/port.h b/firmware/boards/port.h index 398f721..a2dd258 100644 --- a/firmware/boards/port.h +++ b/firmware/boards/port.h @@ -18,6 +18,12 @@ struct AnalogResult AnalogResult AnalogSample(); +enum class SensorType : uint8_t { + LSU49 = 0, + LSU42 = 1, + LSUADV = 2, +}; + class Configuration { private: // Increment this any time the configuration format changes @@ -40,6 +46,8 @@ public: float auxOutBins[2][8]; float auxOutValues[2][8]; uint8_t auxInput[2]; + + SensorType sensorType; } __attribute__((packed)); // pad to 256 bytes including tag diff --git a/firmware/ini/rusefi_wb_f1.ini b/firmware/ini/rusefi_wb_f1.ini index f63295b..b8a9a76 100644 --- a/firmware/ini/rusefi_wb_f1.ini +++ b/firmware/ini/rusefi_wb_f1.ini @@ -12,12 +12,12 @@ enable2ndByteCanID = false [MegaTune] ; https://rusefi.com/forum/viewtopic.php?p=36201#p36201 - signature = "rusEFI 2022.05.29.wideband_rev2" + signature = "rusEFI 2022.12.02.wideband_rev2" [TunerStudio] queryCommand = "S" versionInfo = "V" ; firmware version for title bar. - signature = "rusEFI 2022.05.29.wideband_f1" ; signature is expected to be 7 or more characters. + signature = "rusEFI 2022.12.02.wideband_f1" ; signature is expected to be 7 or more characters. ; TS will try to use legacy temp units in some cases, showing "deg F" on a CLT gauge that's actually deg C useLegacyFTempUnits = false @@ -25,13 +25,9 @@ enable2ndByteCanID = false ; Optimize comms for fast rusEFI ECUs noCommReadDelay = true; - defaultRuntimeRecordPerSec = 100; + defaultRuntimeRecordPerSec = 50; maxUnusedRuntimeRange = 1000; - ; Set default IP/port to our IP/port - defaultIpAddress = 192.168.10.1; - defaultIpPort = 29000; - [Constants] ; new packet serial format with CRC messageEnvelopeFormat = msEnvelope_1.0 @@ -64,59 +60,26 @@ enable2ndByteCanID = false ; CONFIG_DEFINITION_START -pageSize = 128 +pageSize = 256 page = 1 -test = scalar, U08, 6, "test", 50.0, 0, 0, 20000, 2 - -; total TS size = 1 +; name = class, type, offset, [shape], units, scale, translate, min, max, digits +; First four bytes are used for internal tag. Should not be accessable from TS +LsuSensorType = bits, U08, 135, [0:2], "LSU 4.9", "LSU 4.2", "LSU ADV" [SettingContextHelp] -; SettingContextHelpEnd +[Tuning] [LoggerDefinition] -; valid logger types: composite, tooth, trigger, csv -; loggerDef = compositeLogger, "Primary Trigger Logger", tooth - loggerDef = compositeLogger, "Trigger Logger", composite - startCommand = "l\x01" - stopCommand = "l\x02" - dataReadCommand = "L" - dataReadTimeout = 10000 ; time in ms - dataReadyCondition = { toothLogReady } - continuousRead = true - ; each packet is 5 and we have 500 of those - dataLength = 1250 - - - ; recordDef = headerLen, footerLen, recordLen - recordDef = 0, 0, 5 - - ; these names are hard-coded inside TS - recordField = priLevel, "PriLevel", 0, 1, 1.0, "Flag" - recordField = secLevel, "SecLevel", 1, 1, 1.0, "Flag" - recordField = trigger, "Trigger", 2, 1, 1.0, "Flag" - recordField = sync, "Sync", 3, 1, 1.0, "Flag" - recordField = coil, "Coil", 4, 1, 1.0, "Flag" - recordField = inj, "Injector", 5, 1, 1.0, "Flag" - recordField = time, "Time", 8, 32, 0.001, "ms" - - ; it seems that TS also needs to know the diff.size of a tooth - calcField = toothTime, "ToothTime", "ms", { time - pastValue(time, 1) } - -; -; in order to add new TunerStudio gauge you need to chagne two places -; 1) add a line here in '[OutputChannels]' -; 2) in rusEFI firmware make a change to output_channels.txt [OutputChannels] ochGetCommand = "O%2o%2c" ; see TS_OUTPUT_SIZE in console source code - ochBlockSize = 1016 + ochBlockSize = 256 ; Common -TestValue = scalar, U32, 0, "na", 1, 0, 0, 65535, 0 -VBatt = scalar, F32, 4, "V", 1, 0, 0.0, 30.0, 2 +VBatt = scalar, F32, 0, "V", 1, 0, 0.0, 30.0, 2 ; AFR0 AFR0_in = scalar, F32, 32, "", 14.7, 0, 0.0, 20.0, 2 @@ -125,26 +88,39 @@ AFR0_Nernst = scalar, F32, 40, "V", 1, 0, 0.0, 1.0, 2 AFR0_PumpITarget = scalar, F32, 44, "mA", 1, 0, -5.0, 5.0, 2 AFR0_PumpIMeasure = scalar, F32, 48, "mA", 1, 0, -5.0, 5.0, 2 AFR0_HeaterDuty = scalar, F32, 52, "%", 100, 0, 0.0, 100.0, 0 +AFR0_fault = scalar, U08, 56, "", 1, 0, 0, 6, 0 +AFR0_heater = scalar, U08, 57, "", 1, 0, 0, 4, 0 + seconds = scalar, U32, 124, "sec", 1, 0 [PcVariables] + ; Keep in sync with Max31855State enum from max31855.h + EgtStatesList = bits, U08, [0:7], "Ok", "Open Circuit", "Short to GND", "Short to VCC", "No reply" + ; Keep in sync with WBO::Fault from ../for_rusefi/wideband_can.h + AfrFaultList = bits, U08, [0:7], "Ok", "Unk", "Unk", "Failed to heat", "Overheat", "Underheat", "No supply" + ; Keep in sync with HeaterState from heater_control.h + HeaterStatesList = bits, U08, [0:7], "Preheat", "Warmup", "Close loop", "Stopped", "No supply" [TableEditor] [GaugeConfigurations] -gaugeCategory = Test -; Name = Channel, Title, Units, Lo, Hi, LoD, LoW, HiW, HiD, vd, ld, Active -TestGauge = TestValue, "TestValue", "", -10000.0, 10000.0, -10000.0, 10000.0, -10000.0, 10000.0, 3, 3 -; Name = Channel, Title, Units, Lo, Hi, LoD, LoW, HiW, HiD, vd, ld, Active -VBattGauge = VBatt, "Battery", "V", 3.0, 24.0, 9.0, 11.0, 15.0, 16.0, 2, 2 -AFR0_Gauge = AFR0_in, "AFR", "", 6.5, 20.0, 9.0, 10.0, 16.0, 17.0, 2, 2 -AFR0_TempGauge = AFR0_temp, "AFR t", "C", 500, 1050, 500, 650, 800, 950, 2, 2 -AFR0_NernstGauge = AFR0_Nernst, "nernst", "V", 0.0, 1.0, 0.0, 0.0, 0.9, 0.95, 2, 2 -AFR0_HeaterDutyGauge = AFR0_HeaterDuty, "Heater", "%", 0.0, 100.0, 1.0, 3.0, 90, 95, 2, 2 -AFR0_PumpITargetGauge = AFR0_PumpITarget, "Ipump Target", "mA", -5.0, 5.0, -4.0, -3.0, 3.0, 4.0, 2, 2 -AFR0_PumpIMeasureGauge = AFR0_PumpIMeasure, "Ipump Actual", "mA", -5.0, 5.0, -4.0, -3.0, 3.0, 4.0, 2, 2 +gaugeCategory = Common +; Name = Channel, Title, Units, Lo, Hi, LoD, LoW, HiW, HiD, vd, ld, Active +VBattGauge = VBatt, "Battery", "V", 3.0, 24.0, 9.0, 11.0, 15.0, 16.0, 2, 2 + +; AFR0 +gaugeCategory = AFR channel 0 +; Name = Channel, Title, Units, Lo, Hi, LoD, LoW, HiW, HiD, vd, ld, Active +AFR0_Gauge = AFR0_in, "0: AFR", "", 6.5, 20.0, 9.0, 10.0, 16.0, 17.0, 2, 2 +AFR0_TempGauge = AFR0_temp, "0: AFR t", "C", 500, 1050, 500, 650, 800, 950, 2, 2 +AFR0_NernstGauge = AFR0_Nernst, "0: nernst", "V", 0.0, 1.0, 0.0, 0.0, 0.9, 0.95, 2, 2 +AFR0_HeaterDutyGauge = AFR0_HeaterDuty, "0: Heater", "%", 0.0, 100.0, 1.0, 3.0, 90, 95, 2, 2 +AFR0_PumpITargetGauge = AFR0_PumpITarget, "0: Ipump Target", "mA", -5.0, 5.0, -4.0, -3.0, 3.0, 4.0, 2, 2 +AFR0_PumpIMeasureGauge = AFR0_PumpIMeasure, "0: Ipump Actual", "mA", -5.0, 5.0, -4.0, -3.0, 3.0, 4.0, 2, 2 +AFR0_FaultGauge = AFR0_fault, "0: AFR fault", "", 0.0, 6.0, 0.0, 0.0, 0.5, 0.5, 2, 2 +AFR0_HeaterGauge = AFR0_heater, "0: AFR heater state", "", 0.0, 4.0, 0.0, 1.5, 2.5, 2.5, 2, 2 [FrontPage] @@ -160,14 +136,16 @@ AFR0_PumpIMeasureGauge = AFR0_PumpIMeasure, "Ipump Actual", "mA", -5.0 gauge5 = AFR0_NernstGauge gauge6 = AFR0_PumpITargetGauge gauge7 = AFR0_PumpIMeasureGauge - gauge8 = TestGauge + + indicator = { AFR0_fault }, "AFR0 ok", { AFR0: bitStringValue(AfrFaultList, AFR0_fault)}, green, black, red, black + indicator = { (AFR0_heater != 2) }, "AFR0 Heater CL", { AFR0 heater: bitStringValue(HeaterStatesList, AFR0_heater)}, green, black, red, black + [KeyActions] [Datalog] ; Channel Label Type Format entry = time, "Time", float, "%.3f" -entry = TestValue, "TestValue", int, "%d" [Menu] @@ -184,6 +162,8 @@ menuDialog = main menu = "&Idle" menu = "&View" + subMenu = sensor_settings, "Sensor settings" + menu = "&Advanced" diff --git a/firmware/ini/rusefi_wb_f1_dual.ini b/firmware/ini/rusefi_wb_f1_dual.ini index 7889662..8ffdee7 100644 --- a/firmware/ini/rusefi_wb_f1_dual.ini +++ b/firmware/ini/rusefi_wb_f1_dual.ini @@ -12,12 +12,12 @@ enable2ndByteCanID = false [MegaTune] ; https://rusefi.com/forum/viewtopic.php?p=36201#p36201 - signature = "rusEFI 2022.05.29.wideband_dual" + signature = "rusEFI 2022.12.02.wideband_dual" [TunerStudio] queryCommand = "S" versionInfo = "V" ; firmware version for title bar. - signature = "rusEFI 2022.05.29.wideband_dual" ; signature is expected to be 7 or more characters. + signature = "rusEFI 2022.12.02.wideband_dual" ; signature is expected to be 7 or more characters. ; TS will try to use legacy temp units in some cases, showing "deg F" on a CLT gauge that's actually deg C useLegacyFTempUnits = false @@ -25,13 +25,9 @@ enable2ndByteCanID = false ; Optimize comms for fast rusEFI ECUs noCommReadDelay = true; - defaultRuntimeRecordPerSec = 100; + defaultRuntimeRecordPerSec = 50; maxUnusedRuntimeRange = 1000; - ; Set default IP/port to our IP/port - defaultIpAddress = 192.168.10.1; - defaultIpPort = 29000; - [Constants] ; new packet serial format with CRC messageEnvelopeFormat = msEnvelope_1.0 @@ -49,7 +45,7 @@ enable2ndByteCanID = false retrieveConfigError = "e" ; communication settings - pageActivationDelay = 500 + pageActivationDelay = 500 ; Milliseconds delay after burn command. See https://sourceforge.net/p/rusefi/tickets/77/ ; e.g. put writeblocks off and add an interwrite delay writeBlocks = on interWriteDelay = 10 @@ -76,57 +72,21 @@ Aux0Out = array, F32, 69, [8], "V", 1, 0, 0, Aux1Out = array, F32, 101, [8], "V", 1, 0, 0, 5.0, 2 Aux0InputSel = bits, U08, 133, [0:3], "AFR 0", "AFR 1", "EGT 0", "EGT 1" Aux1InputSel = bits, U08, 134, [0:3], "AFR 0", "AFR 1", "EGT 0", "EGT 1" - -; total TS size = 1 +LsuSensorType = bits, U08, 135, [0:2], "LSU 4.9", "LSU 4.2", "LSU ADV" [SettingContextHelp] -; SettingContextHelpEnd - [Tuning] [LoggerDefinition] -; valid logger types: composite, tooth, trigger, csv -; loggerDef = compositeLogger, "Primary Trigger Logger", tooth - loggerDef = compositeLogger, "Trigger Logger", composite - startCommand = "l\x01" - stopCommand = "l\x02" - dataReadCommand = "L" - dataReadTimeout = 10000 ; time in ms - dataReadyCondition = { toothLogReady } - continuousRead = true - ; each packet is 5 and we have 500 of those - dataLength = 1250 - - - ; recordDef = headerLen, footerLen, recordLen - recordDef = 0, 0, 5 - - ; these names are hard-coded inside TS - recordField = priLevel, "PriLevel", 0, 1, 1.0, "Flag" - recordField = secLevel, "SecLevel", 1, 1, 1.0, "Flag" - recordField = trigger, "Trigger", 2, 1, 1.0, "Flag" - recordField = sync, "Sync", 3, 1, 1.0, "Flag" - recordField = coil, "Coil", 4, 1, 1.0, "Flag" - recordField = inj, "Injector", 5, 1, 1.0, "Flag" - recordField = time, "Time", 8, 32, 0.001, "ms" - - ; it seems that TS also needs to know the diff.size of a tooth - calcField = toothTime, "ToothTime", "ms", { time - pastValue(time, 1) } - -; -; in order to add new TunerStudio gauge you need to chagne two places -; 1) add a line here in '[OutputChannels]' -; 2) in rusEFI firmware make a change to output_channels.txt [OutputChannels] ochGetCommand = "O%2o%2c" ; see TS_OUTPUT_SIZE in console source code - ochBlockSize = 1016 + ochBlockSize = 256 ; Common -TestValue = scalar, U32, 0, "na", 1, 0, 0, 65535, 0 -VBatt = scalar, F32, 4, "V", 1, 0, 0.0, 30.0, 2 +VBatt = scalar, F32, 0, "V", 1, 0, 0.0, 30.0, 2 ; AFR0 AFR0_in = scalar, F32, 32, "", 14.7, 0, 0.0, 20.0, 2 @@ -197,8 +157,6 @@ Aux1InputSig = { (Aux1InputSel == 0) ? AFR0_in : ((Aux1InputSel == 1) ? AFR1_in gaugeCategory = Common ; Name = Channel, Title, Units, Lo, Hi, LoD, LoW, HiW, HiD, vd, ld, Active -TestGauge = TestValue, "TestValue", "", -10000.0, 10000.0, -10000.0, 10000.0, -10000.0, 10000.0, 3, 3 -; Name = Channel, Title, Units, Lo, Hi, LoD, LoW, HiW, HiD, vd, ld, Active VBattGauge = VBatt, "Battery", "V", 3.0, 24.0, 9.0, 11.0, 15.0, 16.0, 2, 2 ; AFR0 @@ -240,8 +198,8 @@ EGT1_ColdJunctionGauge = EGT1_coldJunction, "1: EGT CJ", "C", EGT1_StateGauge = EGT1_state, "1: EGT state", "", 0.0, 5.0, 0.0, 0.0, 0.5, 0.5, 2, 2 ; AUX outputs -Aux0InputGuge = { (Aux0InputSel == 0) ? AFR0_Gauge : ((Aux0InputSel == 1) ? AFR1_Gauge : ((Aux0InputSel == 2) ? EGT0_Gauge : EGT1_Gauge)) } -Aux1InputGuge = { (Aux1InputSel == 0) ? AFR0_Gauge : ((Aux1InputSel == 1) ? AFR1_Gauge : ((Aux1InputSel == 2) ? EGT0_Gauge : EGT1_Gauge)) } +Aux0InputGauge = { (Aux0InputSel == 0) ? AFR0_Gauge : ((Aux0InputSel == 1) ? AFR1_Gauge : ((Aux0InputSel == 2) ? EGT0_Gauge : EGT1_Gauge)) } +Aux1InputGauge = { (Aux1InputSel == 0) ? AFR0_Gauge : ((Aux1InputSel == 1) ? AFR1_Gauge : ((Aux1InputSel == 2) ? EGT0_Gauge : EGT1_Gauge)) } [FrontPage] ; Gauges are numbered left to right, top to bottom. @@ -256,7 +214,6 @@ Aux1InputGuge = { (Aux1InputSel == 0) ? AFR0_Gauge : ((Aux1InputSel == 1) ? AFR1 gauge5 = VBattGauge gauge6 = EGT0_Gauge gauge7 = EGT1_Gauge - gauge8 = TestGauge indicator = { EGT0_state }, "EGT0 ok", { EGT0: bitStringValue(EgtStatesList, EGT0_state)}, green, black, red, black indicator = { AFR0_fault }, "AFR0 ok", { AFR0: bitStringValue(AfrFaultList, AFR0_fault)}, green, black, red, black @@ -271,7 +228,6 @@ Aux1InputGuge = { (Aux1InputSel == 0) ? AFR0_Gauge : ((Aux1InputSel == 1) ? AFR1 [Datalog] ; Channel Label Type Format entry = time, "Time", float, "%.3f" -entry = TestValue, "TestValue", int, "%d" [Menu] @@ -288,7 +244,8 @@ menuDialog = main menu = "&Idle" menu = "&View" - subMenu = can_settings, "CAN Settings" + subMenu = sensor_settings, "Sensor settings" + subMenu = can_settings, "CAN settings" menu = "Outputs" subMenu = auxOut0, "AUX analog output 0" @@ -315,6 +272,9 @@ cmd_dfu = "Z\x00\xba\x00\x00" [UserDefined] +dialog = sensor_settings, "Sensor Settings" + field = "Sensor Type", LsuSensorType + dialog = can_settings, "CAN Settings" field = "CAN message ID offset", CanIndexOffset diff --git a/firmware/livedata.h b/firmware/livedata.h index 0a0af25..b4f5e3e 100644 --- a/firmware/livedata.h +++ b/firmware/livedata.h @@ -10,7 +10,6 @@ struct livedata_common_s { union { struct { - uint32_t test; float vbatt; }; uint8_t pad0[32];