Go Down

Topic: Project FIVE tutorial - UNO KIT - ServoMotor Power (Read 159 times) previous topic - next topic

flavios

Feb 13, 2020, 06:17 pm Last Edit: Feb 13, 2020, 09:16 pm by flavios
I have an overload problem on the Surface when I run the sketch to use a Servo motor. Suppose it is the motor requiring more power than available. This happens at one extreme of the potentiometer range. Am I right?

Is there a solution? Perhaps a separately powered HUB?

Thank you
Flavio

Robin2

This happens at one extreme of the potentiometer range.
That makes me wonder if you are trying to drive the servo past its internal end stop. Doing that is bad for the servo - it may damage the gears or burn out the motor. Many servos cannot move a full 180 degrees. You need to experiment to find the limits for your servo.

People here are not generally familiar with the tutorials in any kit. Please post the program you are trying and tell us in more detail what happens when you run it and what you want it to do that is different.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

flavios

Yes, sorry. The 5th Project was "coupling" the movement of the motor with that of the potenziometer via analog port A0.

What really happens is that the motor doesn't move but I was just looking at the serial print that relies the values raw and as an angle.

I suppose your preliminary idea is to the point. I was already trying to limit the pot range but I panic with the message from the PC because I would rather not damage the ONLY USB port I have on the Surface (and the UNO!). You'll find the sketch attached.

Many thanks
Flavio

Robin2

Code from Reply #2 so others don't have to download it -  See How to use the Forum
Code: [Select]
// Sketch PROGETTO 4 - FS20200212

#include <Servo.h>;
Servo myServo;

int const potPin = A0;
int potVal;
int angle;

void setup() {
  myServo.attach(9);
  Serial.begin(9600);
}

void loop() {
  potVal = analogRead(potPin);
  Serial.print("potVal:  ");
  Serial.print(potVal);
 
  angle = map(potVal,0,1023,0,179);
  Serial.print("     angle:  ");
  Serial.println(angle);

  myServo.write(angle);
  delay(15);
}


...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Robin2

To start with change this line
Code: [Select]
angle = map(potVal,0,1023,0,179);
to
Code: [Select]
angle = map(potVal, 0, 1023, 50, 130);
which will greatly reduce the range of movement. If that works without problems you can gradually change the values back towards the original - testing after each change.

Quote
but I panic with the message from the PC
You have not posted the message

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

flavios


zoomkat

Simple servo test code you might use to determine the command values at which the servo starts to hit the internal mechanical stops.

Code: [Select]
// zoomkat 7-30-10 serial servo test
// type servo position 0 to 180 in serial monitor
// for writeMicroseconds, use a value like 1500
// Powering a servo from the arduino usually *DOES NOT WORK*.

String readString;
#include <Servo.h>
Servo myservo;  // create servo object to control a servo

void setup() {
  Serial.begin(9600);
  myservo.attach(9);
}

void loop() {

  while (Serial.available()) {

    if (Serial.available() >0) {
      char c = Serial.read();  //gets one byte from serial buffer
      readString += c; //makes the string readString
      delay(3);
    }
  }

  if (readString.length() >0) {
    Serial.println(readString);
    int n = readString.toInt();
    Serial.println(n);
    myservo.writeMicroseconds(n);
    //myservo.write(n);
    readString="";
  }
}
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

flavios


Go Up