diff --git a/firmware/console/binary/tunerstudio_configuration.h b/firmware/console/binary/tunerstudio_configuration.h index eac7637971..a43e878cb6 100644 --- a/firmware/console/binary/tunerstudio_configuration.h +++ b/firmware/console/binary/tunerstudio_configuration.h @@ -126,7 +126,8 @@ typedef struct { float speedToRpmRatio; // 232 int warningCounter; // 236 int lastErrorCode; // 240 - int unused3[8]; + float inrernalMcuTemperature; // 244 + int unused3[7]; } TunerStudioOutputChannels; #endif /* TUNERSTUDIO_CONFIGURATION_H_ */ diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 43481196b4..2de54aa875 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -675,6 +675,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->checkEngine = hasErrorCodes(); #if EFI_PROD_CODE || defined(__DOXYGEN__) + tsOutputChannels->inrernalMcuTemperature = getMCUInternalTemperature(); tsOutputChannels->idlePosition = getIdlePosition(); tsOutputChannels->isTriggerError = isTriggerErrorNow(); diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index d66f5d1388..33f7851fc1 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -439,6 +439,7 @@ typedef enum { EFI_ADC_14 = 14, // PC4 EFI_ADC_15 = 15, // PC5 + // todo: bad choice of value since now we have ADC_CHANNEL_SENSOR and could end up with 17 and 18 also EFI_ADC_NONE = 16, EFI_ADC_ERROR = 999, diff --git a/firmware/hw_layer/adc_inputs.cpp b/firmware/hw_layer/adc_inputs.cpp index f7e666c94c..6d16c7b53d 100644 --- a/firmware/hw_layer/adc_inputs.cpp +++ b/firmware/hw_layer/adc_inputs.cpp @@ -103,10 +103,12 @@ ADC_TwoSamplingDelay_20Cycles, // cr1 ADC_SMPR1_SMP_AN12(ADC_SAMPLING_SLOW) | ADC_SMPR1_SMP_AN13(ADC_SAMPLING_SLOW) | ADC_SMPR1_SMP_AN14(ADC_SAMPLING_SLOW) | - ADC_SMPR1_SMP_AN15(ADC_SAMPLING_SLOW) + ADC_SMPR1_SMP_AN15(ADC_SAMPLING_SLOW) | + ADC_SMPR1_SMP_SENSOR(ADC_SAMPLE_144) , // sample times for channels 10...18 ADC_SMPR2_SMP_AN0(ADC_SAMPLING_SLOW) | ADC_SMPR2_SMP_AN1(ADC_SAMPLING_SLOW) | + ADC_SMPR2_SMP_AN2(ADC_SAMPLING_SLOW) | ADC_SMPR2_SMP_AN3(ADC_SAMPLING_SLOW) | ADC_SMPR2_SMP_AN4(ADC_SAMPLING_SLOW) | ADC_SMPR2_SMP_AN5(ADC_SAMPLING_SLOW) | @@ -203,6 +205,15 @@ static void pwmpcb_fast(PWMDriver *pwmp) { #endif } +float getMCUInternalTemperature(void) { + float TemperatureValue = adcToVolts(slowAdc.getAdcValueByHwChannel(ADC_CHANNEL_SENSOR)); + TemperatureValue -= 0.760; // Subtract the reference voltage at 25°C + TemperatureValue /= .0025; // Divide by slope 2.5mV + + TemperatureValue += 25.0; // Add the 25°C + return TemperatureValue; +} + int getInternalAdcValue(const char *msg, adc_channel_e hwChannel) { if (hwChannel == EFI_ADC_NONE) { warning(CUSTOM_OBD_38, "ADC: %s input is not configured", msg); @@ -544,6 +555,7 @@ void initAdcInputs(bool boardTestMode) { */ adcStart(&ADC_SLOW_DEVICE, NULL); adcStart(&ADC_FAST_DEVICE, NULL); + adcSTM32EnableTSVREFE(); // Internal temperature sensor for (int adc = 0; adc < HW_MAX_ADC_INDEX; adc++) { adc_channel_mode_e mode = adcHwChannelEnabled[adc]; @@ -558,6 +570,8 @@ void initAdcInputs(bool boardTestMode) { } } + // Internal temperature sensor, Available on ADC1 only + slowAdc.enableChannel((adc_channel_e)ADC_CHANNEL_SENSOR); slowAdc.init(); pwmStart(EFI_INTERNAL_SLOW_ADC_PWM, &pwmcfg_slow); diff --git a/firmware/hw_layer/adc_inputs.h b/firmware/hw_layer/adc_inputs.h index aee6074dcc..b10d3d4aa9 100644 --- a/firmware/hw_layer/adc_inputs.h +++ b/firmware/hw_layer/adc_inputs.h @@ -26,6 +26,7 @@ int getAdcHardwareIndexByInternalIndex(int index); void printFullAdcReportIfNeeded(void); int getInternalAdcValue(const char *msg, adc_channel_e index); +float getMCUInternalTemperature(void); // max(ADC_BUF_DEPTH_SLOW, ADC_BUF_DEPTH_FAST) #define MAX_ADC_GRP_BUF_DEPTH 8 diff --git a/java_console/models/src/com/rusefi/core/Sensor.java b/java_console/models/src/com/rusefi/core/Sensor.java index 4fd4f8ad89..ae8024e039 100644 --- a/java_console/models/src/com/rusefi/core/Sensor.java +++ b/java_console/models/src/com/rusefi/core/Sensor.java @@ -125,6 +125,7 @@ public enum Sensor { RPM(SensorCategory.SENSOR_INPUTS, FieldType.INT, 0, BackgroundColor.RED, 0, 8000), TIME_SECONDS(SensorCategory.OPERATIONS, FieldType.INT, 224, BackgroundColor.MUD, 0, 5), SPEED2RPM(SensorCategory.SENSOR_INPUTS, FieldType.FLOAT, 232, BackgroundColor.MUD, 0, 5), + INT_TEMP(SensorCategory.OPERATIONS, FieldType.FLOAT, 244, BackgroundColor.MUD, 0, 5), INJ_1_2_DELTA("inj 1-2 delta", SensorCategory.SNIFFING), INJ_3_4_DELTA("inj 3-4 delta", SensorCategory.SNIFFING), diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index 5f84e57cf6..6ecd3256bf 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -39,7 +39,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; * @see EngineSnifferPanel */ public class Launcher { - public static final int CONSOLE_VERSION = 20160716; + public static final int CONSOLE_VERSION = 20160719; public static final boolean SHOW_STIMULATOR = false; private static final String TAB_INDEX = "main_tab"; protected static final String PORT_KEY = "port";