Go Down

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

#### jetboatman

##### Jul 03, 2012, 09:56 am
Hi,
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

#1
##### Jul 03, 2012, 10:17 am
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 amLast 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

#3
##### Jul 03, 2012, 10:25 am
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

#4
##### Jul 03, 2012, 10:29 am
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

Please enter a valid email to subscribe