2022-12-24, 12:46 PM
(2022-12-23, 08:42 PM)Techstyle Wrote: 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:
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).
Hi Techstyle,
Many thanks for correcting this code, I've always had to add the extra 0 on the resistance value and assumed it was some sort of decimalisation that just wasn't documented. I'll update the code on my ESP and the code in my links so that if anyone else takes a copy of it, it's correct.
Wishing you a Merry Christmas/Happy holidays and fair winds for 2023.
Thanks,
Mat