how to cut amps off?

Hello everyone,

Im busy with a arduino project where i want to stop a motor with a to high off amps.
I bought a ACS721 current sensor where i can read the amps with. i looked all over they internet to find a movie or instruction how i can put this in a arduino sketch but found nothing. My plan was to turn the motor on till the amps rise and then cut the motor off bye him self. Can someone help me with my project?

Thanks,

I think you mean ACS712, not ACS721.

Try to read the sensor and display the current in the serial monitor before you combine it with your motor code.
Enter "ACS712" in the search box on top of this page.
Leo..

yes i mean ASC712 :slight_smile:

i have read the sensor in the serial monitor till there everything went ok.
But the next step to stop the motor i don't get that done if i slow the motor i see the amps rise but can not find a code who also shut the motor off

vrossi46:
yes i mean ASC712 :slight_smile:

i have read the sensor in the serial monitor till there everything went ok.
But the next step to stop the motor i don't get that done if i slow the motor i see the amps rise but can not find a code who also shut the motor off

What was the A/D value.
Those sensors come in one-way and bi-current.
Was the value ~100, or ~512.

A simple "if" statement could stop the motor.

if (analogRead(A0) > 650) {
motorPin = LOW
digitalWrite(motorpin, LOW);

}

Show us the motor code you already have (inside code tags).
Leo..

till now i have this but it still doesn't work

void setup() {

Serial. begin (9600);
int motorPin = 0;
}

void loop() {

int sensorValue = analogRead (A0) ;
Serial.println( 511 - sensorValue);
delay(250);

if (analogRead(A0) > ) {
int motorPin = LOW;
}
}

I have my ACS712 connect on:
the VCC on 5v from my board
the OUT on 0 from my arduino
the GND on gnd from my board
Then 5v from my board to my ACS712 to my motor and then connect with ground from my board.

Do you have a motor. How big is is (voltage, stall current).
How do you supply the Arduino and the motor (different supplies?)
How do you control it (you wanted the Arduino to be able to turn it off).
What is the current rating of the ACS712.
Previous qestion: what is the A/D value of the sensor without motor current.

Some untested example code.
Leo..

int sensorValue; // holds A/D readings
int offset = 511; // sensor zero current offset | adjust value if needed
int motorPin = 10; // the pin the motor driver is connected to

void setup() {
  pinMode(motorPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  digitalWrite(motorPin, HIGH); // start the motor
  delay(500); // wait untill the motor has started up
  sensorValue = analogRead(A0); // read the sensor
  Serial.println(sensorValue - offset); // print the value
  if (sensorValue > 123) { // if the motor current rises above this A/D value...
    digitalWrite (motorPin, LOW); // switch motor off
    delay(5000); // for 5 seconds
  }
}

motorPin = LOW; // switch motor off

won't do what you want.

You need

digitalWrite(motorPin, LOW); // switch motor off

vrossi46:
till now i have this but it still doesn't work

void setup() {

Serial. begin (9600);
int motorPin = 0;
}

void loop() {

int sensorValue = analogRead (A0) ;
Serial.println( 511 - sensorValue);
delay(250);

if (analogRead(A0) > ) {
int motorPin = LOW;
}
}

And your code (quoted above) doesn't even compile. The compiler chokes at one obvious problem.

My previous post describes another problem with your code and Wawa's.

And, it seems odd to declare motorPin as a local variable in setup(), and then declare it again as a local variable in loop(). Suggested reading.

Furthermore, for better readability, use Auto Format (ctrl - T) to clean up your code.

Lastly, when you post code, use the code tags.

Wawa
Its just the normal DC motor who you get with your arduino starterskit.
The A/D value is around 512
i connect the motor at the arduino on the most simple way 5V from arduino to my ACS712 to my motor to -

how i connect the ACS712 with my arduino:
the VCC 5v from my board
the OUT on 0 from my arduino
the GND on gnd from my board
Then 5v go out my board to my first pin from my ACS712 then a cable goes from my second pin to my motor and then connect with ground from my board.

I want to do the same as this: Arduino Current Feedback Motor Torque Control - YouTube

Start with some motor tutorials.
Here's one.

Leo..

But do you know how i can get this in my code ? Arduino Current Feedback Motor Torque Control - YouTube
I get everything with this code my current is almost 0:
void setup() {
// put your setup code here, to run once:
Serial. begin (9600);

}

void loop() {
// put your main code here, to run repeatedly:
int sensorValue = analogRead (A0) ;
Serial.println( 511 - sensorValue);
delay(250);

and if i hold the motor i see the current rise but i don't now or can find a code where i let the motor stop. on like current 5

Use code tags, so your code appears in a box.

Did you read and understand the code in post#7
Leo..