I have read this somewhere in the past before attempting to do this but now for the life of me I can't seem to find that previous post that I read. So here it is in a new post.
I'm trying to write a calibration procedure and want to calculate a decimal value to use as a float which I want to multiply with an integer value after that. The problem that I'm picking up is that the float is rounding off downwards, i.e. if I am expecting a result of 0.1 or 0.55 or 0.99 the result will always be 0.00
Likewise if I expect a result of 1.15, 1.67 or 1.97 the calculation only yields 1.
Is there a way of getting around this so that I can get the 1.67 value or something similar? I then want to use my float value as a multiplication factor that will act as a calibration factor. When the float is multiplied with an Integer I understand that the Integers in the formula are converted floats for the duration of the calculation and then the result is converted back to a Integer again?
The code is as follows:
Calibration_Factor1 = Ref_Temp1 / Temp_Before; // calculate the temperature value Temp_After = (Raw_Value2 / 3.755) * Calibration_Factor1;
Calibration_Factor1 is the factor needed to shift the current Temperature reading (Temp_Before) to the applied temperature reading (Ref_Temp1) Calibration_Factor1 is a Float.
Ref_Temp1 is the temperature value inserted by the user, temperature value applied to the sensor. [Integer]
Temp_Before is the analog value read / 3.755 to get the temperature value (The 3.755 since the thermocouple ic is giving 10mV per degree Celsius out - approximate value. [Integer]
Temp_After is the adjusted temperature so that the formula compensates for an inaccurate reading to represent the actual temperature applied to the sensor. [Integer]
Raw_Value2 is the analog value converted to a digital value i.e. the value read from the analog input. [Integer]
So in other terms:
Float = Interger / Interger; // calculate the temperature value Interger = (Interger / 3.755) * Float;
Thanks in advance for the help, it is much appreciated.