Re: monitoring Dc help


Howard Dutton
 
Edited

...2.588 to 2.618 let call it 2.6V

Code goes like this...

#define STAT_DC_CURRENT_ANALOG A10

The analogRead(A10) returns a value 0 to 1023 which equals 0 to 5V so d is about 532.

#define ACS712_V_PER_A 0.1
double toDCAmps(double d) {
 double V = (d/1024.0)*5.0;
 double A = (2.5 - V)/ACS712_V_PER_A;
 return A;
}

// gets the floating point current in Amps
... f=toDCAmps(analogRead(STAT_DC_CURRENT_ANALOG));
strcpy_P(tem ...

V=(532.0/1024.0)*5.0 which returns 2.6
A=(2.5-2.6)/0.1 which is -1.0 Amp.

Change the last line in the function to return abs(A); to make all values positive.

Join onstep-ocs@onstep.groups.io to automatically receive all group messages.