ACS 712 current sensor on dc motor

Hello,

Currently I'm making a dyno for RC-cars. With this dyno I want to measure the current that the battery deliveres to the motor so I can calculate the engine power and torque.
I'm using the ACS 712 sensor and the sensor doesn't give a clear value. A current clamp says that the battery deliveres around 18 Amps when the motor is running but the arduino says it only delivers around 0.9 Amps.
Has this to do with my code, with the sensor or can't te ACS 712 measure from a brushed DC motor?

This is my code:



int mVperAmp = 185;

const int sensorIn1 = A8;

double Voltage1 = 0;
double VRMS1 = 0;
double AmpsRMS1 = 0;

void setup() {
  Serial.begin(9600); //Start Serial Monitor to display current read value on Serial monitor
}

void loop() {
 Voltage1 = getVPP1();
 VRMS1 = (Voltage1/2.0) *0.707; 
 AmpsRMS1 = (VRMS1 * 1000)/mVperAmp;

Serial.print(AmpsRMS1); 
}

float getVPP1()
{
  float result1;
  
  int readValue1;             //value read from the sensor
  int maxValue1 = 0;          // store max value here
  int minValue1 = 1024;          // store min value here
  
   uint32_t start_time1 = millis();
   while((millis()-start_time1) < 250) //sample for 0.250 Sec
   {
       readValue1 = analogRead(sensorIn1);
       // see if you have a new maxValue
       if (readValue1 > maxValue1) 
       {
           /*record the maximum sensor value*/
           maxValue1 = readValue1;
       }
       if (readValue1 < minValue1) 
       {
           /*record the maximum sensor value*/
           minValue1 = readValue1;
       }
   }
   
   // Subtract min from max
   result1 = ((maxValue1 - minValue1) * 5.0)/1024.0;
      
   return result1;
 }

What does that mean? Have you looked at the raw ADC values and checked them manually to see if they are correct?

Or, are you only looking at calculated values, in which case your calculations or logic might be incorrect?

the calculated values seem incorrect, it calculates a value between 0 and 4 Amps while a current clamp calculates values between 0 and 18 ams.

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project :wink: See About the Installation & Troubleshooting category.

... but you won't know if that is because of your calculations, or because of the input values, until you look at them.

have a look at post current-sensor-acs712-with-arduino

To check the signal i did some tests with the following code:


void setup() {
  Serial.begin(9600);
}

void loop() {
Serial.print("\t signal voltage = ");
Serial.println(5/1024.0*analogRead(A8),2);
delay(500);
}

During this test the current clamp measured between the 10 and 12 Amps. the results from the arduino are below, the ACS 712 has a max Amp rate of 20 Amps

how do the Arduino readings compare with the current clamp?
The current clamps I have only measure AC - what is your clamp to measure DC?
do you have a standard ammeter which can fit in the supply cable?

the clamp I use is a ZETEK KM041, this clamp can measure AC and DC

so first, the ACS712 is at 2.5 V if it doesn't measure any current. it goes below 2.5 for negative current of AC.

In your test sketch do

Serial.println(analogRead(A8));

Your code in post#1 is for AC, and won't work for DC.
This test sketch should work with a 5volt-logic Arduino and a 20Amp ACS712.
If the readout from this sketch is not correct, then it could be PWM of the motor/driver.
That can be fixed with smoothing code (multiple samples).
Leo..

void setup() {
  Serial.begin(9600);
}

void loop() {
  float current = (analogRead(A0) - 512)  * 0.04878; // read sensor

  Serial.print("Current: ");
  Serial.print(current);
  Serial.println(" Amp)");
  delay(250);
}
1 Like

Are you clamping only over a SINGLE wire?

Yes, only over the positive wire, the ACS712 is also only connected in the positive wire circuit

Hello snagkuul

Take some time and read the datasheet:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.