Go Down

Topic: understanding amp check code (Read 421 times) previous topic - next topic

jetboatman

Hi,
I was reading over this instructable:http://www.instructables.com/id/Tankbot-Internet-Controlled-Tank-Robot/step4/Tank-Load-Code/
and came across this code: http://www.instructables.com/files/orig/FLU/K0YM/H0K52XTJ/FLUK0YMH0K52XTJ.ino

I don't quite understand how he is measure the amount of current the motors are pulling. The code is below, but I don't understand how it is working, nor do I understand what sensA and sensB would be connected to. Can someone please clarify?



Code: [Select]
void ampCheck() { //Check to see how much power we are pulling, shut down if we pull more than 2A
  ampA=0;
  ampB=0;
  for (int i=0; i < 25; i++) {
    ampA=ampA + analogRead(sensA);
    ampB=ampB + analogRead(sensB);
    delay(5);
  }
  ampA=(ampA/25);
  ampB=(ampB/25);
  if (ampA > 1000 || ampB > 1000) {
    analogWrite(motorA, 0);
    analogWrite(motorB, 0);
    delay(1000);
  }
}

dxw00d

It's using the Arduino motor shield - http://arduino.cc/en/Main/ArduinoMotorShieldR3. It provides current sensing output.

AWOL

#2
Jul 03, 2012, 10:20 am Last Edit: Jul 03, 2012, 10:22 am by AWOL Reason: 1
http://arduino.cc/en/Main/ArduinoMotorShieldR3


Why have ampA and ampB both got global scope?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

jetboatman

Oh wow, I had assumed it was in the shield and had looked, but I guess I was looking at the wrong motor shield.
Any idea on how I could do something similar for my arbitary high speed/amp/voltage motor? I'd love to get a reading of how much current is being pulled.

AWOL

If you look at the schematic, there's a couple of 150mOhm resistors  (R1 & R2).
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up