Dear all, I am designing an automated refrigirated system for car a/cs...
The user just places a gas cylinder on my load cell and then inputs the amount wanted (for example 500g using a keypad).
My problem is this:
I made an experimet, by placing the tank (empty) on the load cell, took its voltage o/p;i.e. entering ADC and succesfully monirtored the voltages by increasing 1kg, 1kg, 1kg, 1kg..to 20kgs(full cylinder)..
and monitored the ADC value (bit). And came up with this table:
ADC10BIT GRAMS
377 7585
400 8073
447 9073
494 10073
541 11073
587 12073
633 13073
680 14073
708 14673
727 15073
755 15673
800 16673
847 17673
893 18673
939 19673
986 20673
After I made a program to calibrate it accurately
#include <LiquidCrystal.h>
//#include <math.h>
#define powf
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
const int analogInPin = A0;
int count = 300;
double pow (double __x, double __y);
void setup()
{
lcd.begin(16,2); //initialise LCD
Serial.begin(9600);
setupA();
}
void loop()
{
}
void setupA()
{
lcd.print("TESTING"); //display on lcd
delay(2000);
digitalWrite(13,LOW); //RELAY CLOSED
read_average_analog(250); //NOTE ORIGNAL 250
}
/* Sample analog in pin a given number of times and
* return the floating point mean of the samples.
* The summing of samples is done using a long, which
* is subject to overflow for very large counts.
*/
double read_average_analog(int count)
{
int i;
long sum = 0;
float average;
float voltage;
float conversiontogas;
int gas_before;
float calibration;
sum = 0;
for (i = 0; i < count; i++)
{
sum += analogRead(analogInPin);
Serial.print(sum, 3);
Serial.print("\n");
}
average = ((sum)/(count));
int conv_average = average;
//voltage = average*(0.00469592);
Serial.print("A");
Serial.println(average +4, 3);
//Serial.println(voltage, 3);
//calibration = ((average)*(21.8115942) - (611.1594203));
if((conv_average >= 371) && (conv_average <= 400))
{
calibration = ((conv_average)*(21.217) - (413.96));
}
else if((conv_average > 400) && (conv_average <= 541))
{
calibration = ((conv_average + 4)*(21.277) - (437.64));
}
else if((conv_average > 541) && (conv_average <= 633))
{
calibration = ((conv_average)*(21.739) - (687.87));
}
else if((conv_average > 633) && (conv_average <= 680))
{
calibration = ((conv_average)*(21.277) - (395.09));
}
else if((conv_average > 680) && (conv_average <= 708))
{
calibration = ((conv_average)*(21.429) - (498.43));
}
else if((conv_average > 708) && (conv_average <= 727))
{
calibration = ((conv_average)*(21.053) - (232.26));
}
else if((conv_average > 727) && (conv_average <= 755))
{
calibration = ((conv_average)*(21.429) - (505.57));
}
else if((conv_average > 755) && (conv_average <= 800))
{
calibration = ((conv_average)*(22.222) - (1104.8));
}
else if((conv_average > 800) && (conv_average <= 847))
{
calibration = ((conv_average)*(21.277) - (348.28));
}
else if((conv_average > 847) && (conv_average <= 939))
{
calibration = ((conv_average)*(21.739) - (740.04));
}
else if((conv_average > 939) && (conv_average <= 986))
{
calibration = ((conv_average)*(21.277) - (305.72));
}
Serial.println(calibration);
gas_before = calibration;
lcd.setCursor(0, 1);
lcd.print(gas_before);
delay(100);
Serial.println(gas_before);
return gas_before;
}
Note the equations are all graphs between the values.
With this it all worked perfectly.
Now, I switch off the system, and switch it on again the next day and none of these values are the same. They changed and not linearly.
What can I do to calibrate the system automatically.
Pls help, I ve been on the same thing for a long time now.
tnx
