ACS 712 calibration
Dear all,
I am trying to measure the current through 2 fans. Here i am attaching my code and I need to know how can i calibrate it.
I am using below 2 fans
http://www.mouser.in/ProductDetail/ADDA/AD0612HX-A71GL-LF/?qs=hTx6WCxFMbgcZc/FmemT9A==
http://www.mouser.in/ProductDetail/ADDA/AD0812XB-A73GL-LF/?qs=PieNiMrGZlqvWjV0xsttzA==
Using arduino UNo board for programming.
Results
I am trying to measure the current through 2 fans. Here i am attaching my code and I need to know how can i calibrate it.
I am using below 2 fans
http://www.mouser.in/ProductDetail/ADDA/AD0612HX-A71GL-LF/?qs=hTx6WCxFMbgcZc/FmemT9A==
http://www.mouser.in/ProductDetail/ADDA/AD0812XB-A73GL-LF/?qs=PieNiMrGZlqvWjV0xsttzA==
Using arduino UNo board for programming.
[COLOR=#000000][FONT=monospace]void CS_Output()[/FONT][/COLOR]
[COLOR=#000000][FONT=monospace]{[/FONT][/COLOR]
[COLOR=#000000][FONT=monospace] float average = 0;[/FONT][/COLOR]
[COLOR=#000000][FONT=monospace] for(int i = 0; i < 1000; i++) {[/FONT][/COLOR]
[COLOR=#000000][FONT=monospace] average = average + (.0264 * analogRead(A0) -13.51) / 1000;[/FONT][/COLOR]
[COLOR=#000000][FONT=monospace] delay(1);[/FONT][/COLOR]
[COLOR=#000000][FONT=monospace] }[/FONT][/COLOR]
[COLOR=#000000][FONT=monospace] Serial.print("before calibration:");[/FONT][/COLOR]
[COLOR=#000000][FONT=monospace] Serial.println(average);[/FONT][/COLOR]
[COLOR=#000000][FONT=monospace] average=average+0.07;[/FONT][/COLOR]
[COLOR=#000000][FONT=monospace] Serial.print("after calibration:");[/FONT][/COLOR]
[COLOR=#000000][FONT=monospace] Serial.println(average); [/FONT][/COLOR]
[COLOR=#000000][FONT=monospace]}[/FONT][/COLOR]
[COLOR=#000000][FONT=monospace]void setup() {[/FONT][/COLOR]
[COLOR=#000000][FONT=monospace]Serial.begin(9600);[/FONT][/COLOR]
[COLOR=#000000][FONT=monospace]}[/FONT][/COLOR]
[COLOR=#000000][FONT=monospace]void loop()[/FONT][/COLOR]
[COLOR=#000000][FONT=monospace]{[/FONT][/COLOR]
[COLOR=#000000][FONT=monospace]CS_Output();[/FONT][/COLOR]
[COLOR=#000000][FONT=monospace]delay(1000);[/FONT][/COLOR]
[COLOR=#000000][FONT=monospace]}[/FONT][/COLOR]
Results
Let know how can offset value to meet exact or close to actual_DC load current showing valueslno fans Actual_dc load Before_conversion after_ conversion
1 AD0612HX 0.15A 0.09a 0.15A
2 ADO812XB 0.40A 0.25A 0.32A
3 WHEN COMBINE 0.52A 0.35A 0.42A

Comments
To calibrate you would normally take a batch of readings at start up, and store their average, then
subtract from the actual reading:
const int num_readings = 10; float offSet = 2.44009; const int mad = 2.24; int readings[num_readings]; int index = 0; float sample2SolCrnt = 0.0; float solar_crnt = 0.0; // Solar panel current variable float solarCrntVal = 0.0; // Current callibration variable void setup() { // sets the serial port to 9600 Serial.begin(9600); } int average() { int total = 0; for(int i=0; i<num_readings; i++) total = total + readings[i]; return total/num_readings; } float standard_deviation(int avg) { int total = 0; for(int i=0; i<num_readings; i++) total = total + pow((avg - readings[i]), 2); return sqrt(total/num_readings); } void loop() { float sum=0.0; // read analog input pin 0 int reading = analogRead(A0); readings[index] = reading; // incrementing the index index = index + 1; // if have already been done 10 readings... if (index >= num_readings) { // set the index to 0 index = 0; // compute the average int avg = average(); // compute the standard deviation float std = standard_deviation(avg); float madstd = mad * std; float lowlimit = avg - madstd; float highlimit = avg + madstd; int count = 0; int total = 0; for(int i=0; i<num_readings; i++) { // Check if the values of the readings are within the limits. if(readings[i] >= lowlimit && readings[i] <= highlimit) { total = total + readings[i]; count = count + 1; } } // compute the new average int newaverage = total/count; // send it to the serial port (as ASCII digits) Serial.println(newaverage, DEC); sum=sum+(.0264 *newaverage -13.51); // float current= 0.0264*(newaverage-512); Serial.print("current is :"); Serial.println(sum); } // wait 1000/num_readings ms for next reading delay(int(1000/num_readings)); }2) A hall sensor is much noisier than a shunt sensor, but is isolated.