wildbill:
Not sure where the double issue comes in - can't tell from that fragment. In any event, float and double are the same for arduino. Does this work any better?
CoolingCalc = (float)Calc / 60.0 * 4.186 * ((float)Temp1in - (float)Temp2in); //Calculates cooling power
It didn't work either... so, the problem is, HOW do i get the temp.sensor values stored as variables so that i can use them in my cooling calculation?
#include <math.h>
double Temp1in(float RawADC) {
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15; // Convert Kelvin to Celcius
return Temp;
}
double Temp2in(float RawADC) {
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15; // Convert Kelvin to Celcius
return Temp;
}
These (Temp1in & Temp2in) are the ones that i need to work as variables for calculations.
Here's the whole code, still really messy and under construction:
#include <LiquidCrystal.h> // include the library code:
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); // initialize the library with the numbers of the interface pins
#include <math.h>
double Temp1in(float RawADC) {
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15; // Convert Kelvin to Celcius
return Temp;
}
double Temp2in(float RawADC) {
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15; // Convert Kelvin to Celcius
return Temp;
}
volatile int Flow1; //measuring the rising edges of the signal
float Calc;
float CoolingCalc;
int hallsensor = 2; //The pin location of the sensor
void rpm () //This is the function that the interupt calls
{
Flow1++; //This function measures the rising and falling edge of the hall effect sensors signal
}
void setup()
{
lcd.begin(16, 2); // set up the LCD's number of columns and rows:
Serial.begin(9600);
pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input
attachInterrupt(0, rpm, FALLING); //and the interrupt is attached
}
void loop()
{
Flow1 = 0; //Set Flow1 to 0 ready for calculations
sei(); //Enables interrupts
delay (1000); //Wait 1 second
cli(); //Disable interrupts
Calc = (float(Flow1 / 49.03 * 60 )); //(Pulse frequency / 49.03 pulses/ltr x 60 sec = ltr/min)
CoolingCalc = (Calc / 60 * 4.186 ); //Calculates cooling power
lcd.setCursor(0,0);
lcd.print(float(Calc),1); //Prints the number calculated above
lcd.setCursor(0,6);
lcd.print(float(CoolingCalc),1);
lcd.print('\n');
lcd.setCursor(0, 1);
lcd.print(float(Temp1in(analogRead(0))),1);
lcd.print(" ");
Serial.print("DATA,TIME,");
Serial.print(float(Temp1in(analogRead(0))),1); // display Celsius
Serial.print(",");
Serial.print((Calc),1);
Serial.print(",11,14,99,7");
Serial.print('\r');
delay(1000);
}
This code works. But what i'm looking for is to add the described lines to the 'CoolingCalc'-function, which just doesn't work. I know it's a little thing, maybe to define the Temp1in & Temp2in as different variables or so.
EDIT: Changing all the double types to float types still gives me an error "error: invalid operands of types 'double' and 'float ()(float)' to binary 'operator*'" as soon as i try to add one of the temperature variables to the calculation.