2022-12-23, 08:42 PM
I was looking more at your Temp sender code and couldn't work it out, but I think I found an error, that you may have corrected with your R1 value:
the "analog input" is measured in Bits from 0-1024, this is then translated to Voltage by the "AnalogVoltage" transform, but this calculation gets you the percentage of the max voltage, not the actual voltage, therefore the rest of the calcs don't work out correctly - this had me stumped for a bit but if you change that line to:
then it worked out, the first "Vin" sets the max voltage to the input voltage you have stated above and then the second "Vin" is the multiplier to get it back to voltage from percentage. Now my R1 could be set to its actual resistance in ohms (47 in my case).
Code:
//// Engine Temp Config ////
const float Vin = 3.3;
const float R1 = 1000.0;
auto* analog_input = new AnalogInput(36, 2000);
analog_input->connect_to(new AnalogVoltage())
->connect_to(new VoltageDividerR2(R1, Vin, "/Engine Temp/sender"))
->connect_to(new TemperatureInterpreter("/Engine Temp/curve"))
->connect_to(new Linear(1.0, 0.0, "/Engine Temp/calibrate"))
->connect_to(new SKOutputFloat("propulsion.engine.temperature", "/Engine Temp/sk_path"));
the "analog input" is measured in Bits from 0-1024, this is then translated to Voltage by the "AnalogVoltage" transform, but this calculation gets you the percentage of the max voltage, not the actual voltage, therefore the rest of the calcs don't work out correctly - this had me stumped for a bit but if you change that line to:
Code:
analog_input->connect_to(new AnalogVoltage(Vin,Vin))
then it worked out, the first "Vin" sets the max voltage to the input voltage you have stated above and then the second "Vin" is the multiplier to get it back to voltage from percentage. Now my R1 could be set to its actual resistance in ohms (47 in my case).