Arduino Forum

Topics => Robotics => Topic started by: biotech on May 24, 2012, 10:23 pm

Title: I need code to run to modified 360 degrees servo motors.
Post by: biotech on May 24, 2012, 10:23 pm
Hi everyone!

I am getting started with Arduino and so far so good. My first goal was to modify a servo motor to make it turn 360 degrees. Just today I connected it to the Adafruit motor shield and the Arduino board. With the code I got I was able to see the motor running non stop. To me that was kind of a giant leap!

Can someone please give me a simple code to run two modified servo motors as robot wheels. Maybe they can start turning forwards then stop, and start turning backwards. Something simple like that.

The other thing I need please is info about how to access the servo motors libraries. By now I only found in those libraries the knob and sweep routines but sure enough there is much more than that.

Any help will be more than welcome. Thanks!
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: zoomkat on May 25, 2012, 12:09 am
Some test code where two us servo positions can be sent from the serial monitor to control two servos.

Code: [Select]

// zoomkat 12-13-11 serial servo (2) test
// for writeMicroseconds, use a value like 1500
// for IDE 1.0
// Powering a servo from the arduino usually DOES NOT WORK.
// two servo setup with two servo commands
// send eight character string like 15001500 or 14501550
// use serial monitor to test

#include <Servo.h>
String readString, servo1, servo2;
Servo myservo1;  // create servo object to control a servo
Servo myservo2;

void setup() {
  Serial.begin(9600);
  myservo1.attach(6);  //the pin for the servo control
  myservo2.attach(7);
  Serial.println("two-servo-test-1.0"); // so I can keep track of what is loaded
}

void loop() {

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

  if (readString.length() >0) {
      Serial.println(readString); //see what was received
     
      // expect a string like 07002100 containing the two servo positions     
      servo1 = readString.substring(0, 4); //get the first four characters
      servo2 = readString.substring(4, 8); //get the next four characters
     
      Serial.println(servo1);  //print to serial monitor to see parsed results
      Serial.println(servo2);

      int n1 = servo1.toInt();
      int n2 = servo2.toInt();

      Serial.println("the numbers are :");
      Serial.println(n1);  //print to serial monitor to see number results
      Serial.println(n2);
           
      myservo1.writeMicroseconds(n1); //set servo position
      myservo2.writeMicroseconds(n2);
    readString="";
  }
}

Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: biotech on May 25, 2012, 06:10 pm
Hi Zoomkat,

Thank you for the code. I have tried it with only one modification. I set the servos in ports 9 and 10 as I am using the Adafruit motor shield.

I connected only one motor and and it still turns continuosly. Am I doing something wrong or maybe the modification in the electronics of the servos is not right?


Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: Jantje on May 25, 2012, 06:35 pm
Th code states
Code: [Select]
// expect a string like 07002100 containing the two servo positions
So
1) start the serial monitor at baud rate 9600
2) send a string like 0100000 if you connected your servo to pin 6(not sure how you changed the code)
3) send a string like 1000000 if you connected your servo to pin 6(not sure how you changed the code)
4) see what the servo does and deduce a new value
5) redo 4 till the motor doesn't move anymore

Best regards
Jantje



Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: zoomkat on May 25, 2012, 08:47 pm
Quote
2) send a string like 0100000 if you connected your servo to pin 6(not sure how you changed the code)


Not the best starting point for testing. Most continous rotation servos have a neutral stop rotation value of ~1500us. usually full rotation in one direction is ~1400us, and ~1600us for the other direction. I'd start with a value like 15001500 and vary the values by +-10us to see how the rotation speed changes. Newer factory made continous rotation servos may have much broader speed change bands, but ~1500us should still be the neutral stoped value.
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: biotech on May 26, 2012, 03:41 am
Hi guys,

Thanks for the help.

I didn't know about the serial monitor feature. Right now I have connected the servo to the Adafruit and then the Arduino board to the computer via USB. I am trying to send the values you mentioned via the serial monitor, buy I get the error message "port 6 not found".

As mentioned before, due to the Adafruit motor shield I modified the code to ports 9 and 10. The problem is that when I try to change the port from 6 to 9 or 10 at the serial monitor it doesn´t allow me to do it.

This is the code I am using with the modifications:

// zoomkat 12-13-11 serial servo (2) test
// for writeMicroseconds, use a value like 1500
// for IDE 1.0
// Powering a servo from the arduino usually DOES NOT WORK.
// two servo setup with two servo commands
// send eight character string like 15001500 or 14501550
// use serial monitor to test

#include <Servo.h>
String readString, servo1, servo2;
Servo myservo1;  // create servo object to control a servo
Servo myservo2;

void setup() {
  Serial.begin(9600);
  myservo1.attach(9);  //the pin for the servo control
  myservo2.attach(10);
  Serial.println("two-servo-test-1.0"); // so I can keep track of what is loaded
}

void loop() {

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

  if (readString.length() >0) {
      Serial.println(readString); //see what was received
     
      // expect a string like 07002100 containing the two servo positions     
      servo1 = readString.substring(0, 4); //get the first four characters
      servo2 = readString.substring(4, 8); //get the next four characters
     
      Serial.println(servo1);  //print to serial monitor to see parsed results
      Serial.println(servo2);

      int n1 = servo1.toInt();
      int n2 = servo2.toInt();

      Serial.println("the numbers are :");
      Serial.println(n1);  //print to serial monitor to see number results
      Serial.println(n2);
           
      myservo1.writeMicroseconds(n1); //set servo position
      myservo2.writeMicroseconds(n2);
    readString="";
  }
}

Any idea on how can I use the serial monitor feature if I am using a motor shield?

Thanks!

Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: zoomkat on May 26, 2012, 06:13 am
Quote
Any idea on how can I use the serial monitor feature if I am using a motor shield?


I suggest you remove the motor shield and then do some servo testing.
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: Jantje on May 26, 2012, 02:58 pm
biotech
My advice: go through the arduino samples. You are lacking quite some basic knowledge. Going through the samples will help you understand what is going on in this world.

Zoomcat
The adafruit motorshield only makes it easy to connect a servo. Basically the 2 times 3 pins (+ gnd pwm) are put nicely next to each other so you can plug in 2 servo's using the standard servo connector. it is a "extra feature" of the motorshield which is very often misunderstood as a real feature of the shield.
If you have the shield lying around and need to work with servo's it is convenient.

Best regards
Jantje
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: biotech on May 26, 2012, 04:59 pm
Jantje/Zoomkat

Believe me Jantje that I have tried the Arduino samples for servos severaly times. But they are ment for 180 degrees servos.

I got the motor shield to make my life easier in my first attempt to modify a servo. However, so far it looks impossible to calibrate a servo using the shield. Is this right?

So as Zoomkat mentioned, I think that the best option is to connect the servo motor directly to the Arduino. But here I have yet another question. This is a modified servo, so shall I connect it to the Arduino as a normal servo or as a dc motor?

By the way, I am using a 9g microservo. May it be possible that microservos are more tricky than normal servos for calibration?

Thanks for the valuable support.
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: dxw00d on May 26, 2012, 05:12 pm
Whether or not you use the shield won't make any difference. The shield just gives convenient connection points to Arduino pins. You should drive them as servos, not dc motors.

Can you describe the steps you took to modify the servos?
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: Jantje on May 26, 2012, 05:40 pm

I didn't know about the serial monitor feature. ...

Believe me Jantje that I have tried the Arduino samples for servos severaly times. But they are ment for 180 degrees servos.


My advice: go through the arduino samples. You are lacking quite some basic knowledge. Going through the samples will help you understand what is going on in this world.

I stick to my advice, and I mean all the samples, not only the servo samples. You should do at least do the basic samples and blink without delay. Play around with the samples, change some stuff and see whether it does what you intended. It is a step backwards to better mover forwards.

Best regards
Jantje
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: biotech on May 26, 2012, 06:20 pm
Jantje

You are right on that. I skept all those basic samples. Maybe it´s time to have a go on them as well. Thanks for the advise.

dxw00d

This are the steps I followed to modify the servo:
1- Remove the mechanical stop on the gear.
2- Desoldered the potentiomenter.
3- Solder in place two resistors.
4- Connected the servo to the shield and it runs continuosly as a DC.
4. Tried to calibrate the servo using the serial monitor feature but it doesn't seem to work with the servo connected to the Adafruit motor shield. The reason being is that serial monitor doesn´t allow me to change from channel 6 to channel 9 or 10 to do de calibration.

At the moment I am thinking to forget the motor shield and connect the servo directly to the Arduino. However, as I am not good with electronics it is going to take ma a while until I get the connectors for doing this.

Please if you see anything wrong with the steps I just mentioned let me know. Thanks!

Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: AWOL on May 26, 2012, 10:39 pm
Quote
3- Solder in place two resistors.

What were the values, and how did you wire them?
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: zoomkat on May 26, 2012, 11:02 pm
Quote
2- Desoldered the potentiomenter.
3- Solder in place two resistors.


This may be where you have issues. I have unmodified 9G servos and they work with the code I posted. I also have standard servos I've modified like below and they also work with the posted code. If there is much mismatch between your resistors, you may not be able to get the servo response you want.

http://www.lynxmotion.net/viewtopic.php?f=31&t=6388
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: biotech on May 27, 2012, 08:34 pm
Zoomkat,

Are you telling me that you can make 9g servos work as normal DCs without modifying the electronics? Please let my know in case I got it wrong.

Regarding the desoldering of the pot and soldering of the resistors, I will try to do it all over again and see what happens. However, as far as I know I did it well.

Tomorrow I will get conectors for the servos so I can attach them directly to the Arduino (without the motor shield). That may be the first step to understanding what's going on.

Thanks!

Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: AWOL on May 27, 2012, 08:51 pm
Quote
Are you telling me that you can make 9g servos work as normal DCs without modifying the electronics?

I don't understand that sentence
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: biotech on May 27, 2012, 10:13 pm
AWOL

Hi, as you may see English is not my first language.

That sentence was ment to be a question for Zoomkat asking him if I can use 9g servos for continuous rotation without modifying the electronics.

I really hope I didn´t sound rude or anything like that...All of you but especially Zoomkat are being extremly helpful in helping me to get started.

Regards.
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: AWOL on May 28, 2012, 08:51 am
Some servos allow you to modify them for continuous rotation without removing the pot; either the pot shaft is sawn off or otherwise disengaged from the output shaft, or in some case you can leave the pot in circuit, but just shorten its legs, so that the pot shaft is  disengaged from the output shaft. Remember to centre the pot before closing-up.

I've never come across a mod that allows the pot to be left in place, because usually the pot itself will be incapable of 360 degree rotation.

If you're using resistors, say the pot is a 5k device, then two 2k2 or two 2k7 resistors should be soldered in its place, remembering to solder the junction of the two resistors to where the wiper was connected.
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: biotech on May 28, 2012, 09:20 pm
AWOL

Believe it or not I finally got there! What Zoomkat and yourself told me about the fact that is not necessary to remove the pot made a big difference to me. I just got a normal servo and removed all the gears, and without touching the electronics I got the motor of the servo turning continuously to one direction and then to the other as instructed.

The only thing remaining is why I can´t use the serial monitor feature. When I open Tools in there Serial Monitor is greyed out. It's set to port 6 but as I am uning an Adafruit motor shield in the codes I put "myservo.attach (9)". So I think I should change serial monitor from port 6 to 9 to be able to see the values. Am I right?  But as I mentioned, serial monitor is set to port 6 and greyed out. All in all, I can download the codes but I can´t see the values when the servos are running.

If you also know something about this particular subjet please let me know. Many thanks!
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: AWOL on May 28, 2012, 09:39 pm
Quote
I put "myservo.attach (9)". So I think I should change serial monitor from port 6 to 9 to be able to see the values.

Your COM port has got nothing to do with what pin your servo is attached to.
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: zoomkat on May 28, 2012, 10:40 pm

I've never come across a mod that allows the pot to be left in place, because usually the pot itself will be incapable of 360 degree rotation.


Many servos like the one below have a collar insert that is used to connect the pot and servo gearing. Removing the collar and stop tab is all that is needed for the mod. In other servos the gearing has a slot for the pot shaft. This slot can be drilled out round to prevent the pot moving with the gearing.

(http://web.comporium.net/~shb/pix/cr9.jpg)
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: biotech on May 29, 2012, 01:14 am
Zoomkat,

Thank you for the pic and detailed explanation. I will try to get those kind of servos and see how they work.

I was trying to do things that are not always necessary with the electronics of the servo. Thanks a lot for your pathience during my starting up with Arduino!

Let´s see how it goes during the next days that I will be trying new things.

Regards.
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: eightbittrip on May 30, 2012, 05:07 am
I am working on a robot platform made by vex. it is a skid steer platform driven by two continuously rotating servos. I have added a regular servo to pan a ping sensor. so far I have been able to get it moving forward at equal speeds per side and I have the pan servo working for the ping sensor. working hard to figure out how I am going to cause a reaction from the ping sensor to avoid obstacles. for now here is my code so far, it sounds like it may be similar to the type of platform discussed here.

#include <Servo.h>

Servo myservopan;  // create servo object to control a servo
Servo myservorightdrive;
Servo myservoleftdrive;

int pos = 0;    // variable to store the servo position

void setup()
{
  myservopan.attach(9);
  myservorightdrive.attach(2);
  myservoleftdrive.attach(3);
}


void loop()
{
  for(pos = 0; pos < 90; pos += 1)  // goes from 0 degrees to 90 degrees
  {                                  // in steps of 1 degree
    myservopan.write(pos);              // tell servo to go to position in variable 'pos'
    delay(20);
  }
  for(pos = 90; pos>=1; pos-=1)     // goes from 90 degrees to 0 degrees
  {                               
    myservopan.write(pos);              // tell servo to go to position in variable 'pos'
    delay(20);                       // waits 20ms for the servo to reach the position
  }
  for(pos = 90; pos>=60; pos-=1)
  {
    myservorightdrive.write(pos);
    delay(1);
  }
  for(pos = 90; pos < 130; pos += 1)
  {
    myservoleftdrive.write(pos);
    delay(1);
  }
}
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: eightbittrip on Jun 01, 2012, 04:14 am
well I have got mine working nice.. it is a ping pan roam robot. uses an ultrasonic prox sensor "parallax" mounted to a servo that pans it left and right. during a late night search for some similar arduino code I hit the jackpot. I don't know who originally created it as I have omitted and rewritten notes along with the header showing that info, thanks whoever you are. "oops". here it is :)



Code: [Select]
#include <Servo.h> //include Servo library

const int RForward = 65; //speed value of drive servo, value 0 for full speed rotation
const int RBackward = 130; //speed value of drive servo, value 180 for full speed rotation
const int LForward = RBackward; //the servos must rotate in opposite directions in order to drive in the same direction
const int LBackward = RForward; //the servos must rotate in opposite directions in order to drive in the same direction
const int RNeutral = 95; //value 90 for center, my servo is a little off
const int LNeutral = 95; //value 90 for center, my servo is a little off
const int pingPin = 7;  //signal pin on parallax ping sensor connected to this arduino pin "remember the ping sensor is 5V, not source"
const int irPin = 0;  //Sharp infrared sensor connected to this arduino pin "not currently used"
const int dangerThresh = 20; //threshold for obstacles (in cm), this was 10 by default
int leftDistance, rightDistance; //distances on either side
Servo panMotor; //servo that pans the ping sensor
Servo leftMotor;  //continuous rotation servo that drives the left wheel
Servo rightMotor; //continuous rotation servo that drives the right wheel
long duration; //time it takes to recieve PING))) signal

void setup()
{
 rightMotor.attach(11); //signal wire on right countinuous rotation "drive" servo connected to this arduino pin
 leftMotor.attach(10);  //signal wire on left continuous rotation "drive servo connected to this arduino pin
 panMotor.attach(6); //signal wire on pan servo for ping sensor connected to this arduino pin
 panMotor.write(90); //set PING))) pan to center "90 by default"
}

void loop()
{
 int distanceFwd = ping(); //ping stright ahead
 if (distanceFwd>dangerThresh) //if the path is clear
 {
   leftMotor.write(LForward); //move forward
   rightMotor.write(RForward); //move forward
 }
 else //if path is blocked
 {
   leftMotor.write(LNeutral); //stop left drive motor
   rightMotor.write(RNeutral); //stop right drive motor
   panMotor.write(0); //turn ping sensor right, 0 for full right
   delay(500);        //wait this many milliseconds
   rightDistance = ping(); //ping
   delay(500);  //wait this many milliseconds
   panMotor.write(170); //turn ping sensor left, 180 for full right "my servo hits stop limit and binds at 180"
   delay(500);  //wait this many milliseconds
   leftDistance = ping(); //ping
   delay(500);  //wait this many milliseconds
   panMotor.write(83); //return to center, "90 by default" my servo is off center
   delay(100);  //wait this many milliseconds
   compareDistance(); //compare the two distances measured
 }
}
 
void compareDistance()
{
 if (leftDistance>rightDistance) //if left is less obstructed
 {
   leftMotor.write(LBackward); //rotate left drive servo bacward "skid steer"
   rightMotor.write(RForward); //rotate right drive servo forward "skid steer"
   delay(1000); //run motors this many milliseconds
 }
 else if (rightDistance>leftDistance) //if right is less obstructed
 {
   leftMotor.write(LForward); //rotate left drive servo forward "skid steer"
   rightMotor.write(RBackward); //rotate right drive servo backward "skid steer"
   delay(1000);  //run motors this many milliseconds
 }
  else //if they are equally obstructed
 {
   leftMotor.write(LForward); //rotate left drive servo forward
   rightMotor.write(RBackward); //rotate right drive servo backward
   delay(2000); //run motors this many milliseconds
 }
}


Moderator edit: [font=Verdana][[/font]code] [font=Verdana][[/font]/code] tags added
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: biotech on Jun 01, 2012, 07:01 am
Eightbittrip,

Thank your for the code.  I will be trying it on the Arduino during the weekend. Wish me good luck!

Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: eightbittrip on Jun 03, 2012, 04:13 am
I have tinkered with that code some more and added two "bump" switches to my bot. my ping sensor has good response approaching objects head on, however while approaching objects at near parallel angles it doesn't see them. bot has a wide platform and the ping sensor has a narrow field :(  A friend had a great idea also. Wrapping a length of wire several times around the positive wire to each drive servo could induce a small current flow with respect to ground. this could be used for current sensing for overload protection :) my next goal is to find a way to smooth out the start/stop speed of my servos. they shift directions rapidly.  best of luck to you on your bot this weekend, I am sure you will need to tinker with the values that return the servos to center or stop position... here is my latest code.

Code: [Select]

//remember that the power for the servos comes from the voltage source, not the arduino board. only the signal wire "white or yellow" //is connected to the arduino board. no motor shield required .
//notes are written after these forward slashes to help explain the code
//IRpin and sharp ir sensor not working yet, ignore for now...

#include <Servo.h> //include Servo library information from arduino folder
const int RForward = 47; //speed value of drive servo, value 0 for full speed rotation
const int RBackward = 180; //speed value of drive servo, value 180 for full speed rotation
const int LForward = RBackward; //servos rotate opposite directions to drive in same direction
const int LBackward = RForward; //servos rotate opposite directions to drive in same direction
const int RNeutral = 95; //value 90 is default for center "stop", my servo is a little off
const int LNeutral = 95; //continuous rotation servo center "stop" position
const int pingPin = 7;  //signal pin on parallax ping sensor connected to arduino pin 7
const int dangerThresh = 40; //threshold limit for obstacles (in cm), 10 by default
const int IRpin = A0;  //Sharp infrared sensor connected to arduino pin analog 0
int switchPin = 2;  // normally open bumper switch connected to arduino pin 2 and ground
int leftDistance, rightDistance; //store values for later use to compare ping readings
Servo panMotor; //servo that pans the ping sensor
Servo leftMotor;  //continuous rotation servo that drives the left wheel
Servo rightMotor; //continuous rotation servo that drives the right wheel

long duration; //time it takes to recieve PING))) signal
void setup()
{
 rightMotor.attach(11); //right drive servo signal wire connected to arduino pin 11
 leftMotor.attach(10);  //left drive servo signal wire connected to arduino pin 10
 panMotor.attach(6); //pan servo for ping sensor connected to arduino pin 6
 pinMode(switchPin, INPUT);  //N.O. bumper switch connected to pin 2 and ground
 digitalWrite(switchPin, HIGH);// turns on 20k pullup resistor so switchPin will read HIGH unless triggered LOW
 pinMode(IRpin, INPUT); // set anolog pin 0 as sharp infrared sensor input
 float volts=analogRead(IRpin)*0.0048828125; ;  //read voltage from sharp ir sensor
 float distance = 65*pow(volts, -1.10);  //calculate distance from voltage reading above
 panMotor.write(83); //set PING))) sensor pan angle to center "90 by default"
}

void loop()  //after setup do these actions in a countinuous loop
{
 int distanceFwd = ping(); //ping stright ahead continuously and store the reading for comparison
 if (digitalRead(switchPin) == HIGH  && distanceFwd>dangerThresh) //if switch reads high and ping is greater distance than threshold
 
 {
   leftMotor.write(LForward); //move forward
   rightMotor.write(RForward); //move forward
 }
 else //otherwise if the path is blocked
 {
   leftMotor.write(LNeutral); //stop left drive motor
   rightMotor.write(RNeutral); //stop right drive motor
   panMotor.write(20); //turn ping sensor right, 0 for full right
   delay(300);        //wait this many milliseconds for servo to reach position
   rightDistance = ping(); //ping and calculate distance
   delay(100);  //wait this many milliseconds to store the measurement
   panMotor.write(135); //turn ping sensor left, 180 for full left
   delay(300);  //wait this many milliseconds for servo to reach position
   leftDistance = ping(); //ping and calculate distance
   delay(100);  //wait this many millisecondsto store measurement
   panMotor.write(83); //return to center, 90 for center
   delay(300);  //wait this many milliseconds for servo to reach position
   compareDistance(); //move on to next step "compare distance"
 }
}
 
void compareDistance()
{
 if (leftDistance>rightDistance) //if left is less obstructed
 {
   leftMotor.write(LBackward); //rotate left drive servo backward
   rightMotor.write(RForward); //rotate right drive servo forward
   delay(400); //run motors this many milliseconds
 }
 else if (rightDistance>leftDistance) //otherwise if right is less obstructed
 {
   leftMotor.write(LForward); //rotate left drive servo forward
   rightMotor.write(RBackward); //rotate right drive servo backward
   delay(400);  //run motors this many milliseconds
 }
  else //otherwise if they are equally obstructed
 {
   leftMotor.write(LForward); //rotate left drive servo forward
   rightMotor.write(RBackward); //rotate right drive servo backward
   delay(1500); //run motors this many milliseconds
 }
}


Moderator edit: code tags added. Again.
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: oric_dan on Jun 03, 2012, 04:48 am
I find the code example given to be rather complex. Just to find the neutral
point, I would write a 4-line for-loop program that stepped the servo pulsewidth
from 1450-1550 usec in 1-usec steps with a 100-msec delay at the end of the
loop and a Serial.print(pulsewidth); statement inside the loop.

Then I would know the neutral point in about 2-minutes.
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: Jantje on Jun 03, 2012, 02:08 pm
The way I do it:
I use the pot in the servo solution:
With the pot reachable and not yet fixed I connect the servo to the Arduino who is programmed in the 0 position.
I turn the pot till the servo stands still
I glue/fix the pot so it can not move anymore.
Job done

Best regards
Jantje
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: eightbittrip on Jun 03, 2012, 06:17 pm
Rewrote code a little more with some help from oric_dan(333), thanks  :D still working on how to smooth out the servo movements. my servos start/stop/and reverse directions too rapidly. I am worried that this will damage them eventually :~
my continuous rotation servos were made by vex robotics. they were originally designed to rotate continuously so I have never taken them apart, instead I just changes the settings in the code. the suggestions above are great if you are modifying normal servos. I have used the method of centering the potentiometer and glue it in place while the servo is hooked up and receiving a "center" signal, works great. here is my latest code 8)
Title: Re: I need code to run to modified 360 degrees servo motors.
Post by: flore1nr on Jun 15, 2012, 06:40 pm
When I was testing my servos at first I was confused as well because they would keep spinning even when I told them to stop. I would suggest keep doing some basic arduino examples. Depending on the type of servos you have if its a continuous motor 0 writes one direction 180 the other and 90 writes the servo to stop. Also make sure that if the program is telling the servo to stop then it should stop there should be a built in potentiometer that you can adjust with a screwdriver to center the servo to make the servo stop when it should be stopped.