Pages: 1 [2]   Go Down
Author Topic: Newbie - HS-311 Servo 360 Continuous Rotation help  (Read 3437 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code for testing and setup of servos. For my DIY continous rotation servos I send a 1500us position signal to the servo and tweek the pot until the motor stopps turning, then secure the pot in place. the below sail servo might be of interest, but is $$$.

http://www.robotshop.com/ca/hitec-hs785hb-servo-motor-2.html

Code:
// zoomkat 10-22-11 serial servo test
// type servo position 0 to 180 in serial monitor
// or for writeMicroseconds, use a value like 1500
// for IDE 0022 and later
// 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.writeMicroseconds(1500); //set initial servo position if desired
  myservo.attach(7);  //the pin for the servo control
  Serial.println("servo-test-22-dual-input"); // so I can keep track of what is loaded
}

void loop() {
  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the string readString
    delay(2);  //slow looping to allow buffer to fill with next character
  }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string
    int n = readString.toInt();  //convert readString into a number

    // auto select appropriate value, copied from someone elses code.
    if(n >= 500)
    {
      Serial.print("writing Microseconds: ");
      Serial.println(n);
      myservo.writeMicroseconds(n);
    }
    else
    {  
      Serial.print("writing Angle: ");
      Serial.println(n);
      myservo.write(n);
    }

    readString=""; //empty for next input
  }
}


This code works great! Just purchased a HS-311 from ServoCity and it had a POT. I had no idea what it did and now I see it simply sets the STOP point depending on the value inputted from the keyboard. Thanks for this.
Logged

0
Offline Offline
Tesla Member
***
Karma: 148
Posts: 9753
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If you remove the stop, the servo will be 'stopped' by the potentiometer which will probably break.  Or perhaps you will strip some gear.

The pots in the servos I've taken apart and modified do not have stops. The only mechanical stop has been the plastic tab on the output shaft. Soon I plan to just remove the servo plastic stop tab and then do some testing with the servo. 
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A HITEC HS-311 is rated for 4.8V-6V. As you mentioned that you have provided with 'live' , which I am assuming is 9V, you might have probably damaged the HS-311 circuit. You should connect the 9V to the Vin of the Arduino and 5V of the Arduino to the 'live' of the Servo Motor.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please guide me i am using Hitec hs 311 but it only goes toward a angle 180 degree whatever the input is and cannot goes to a angle which i desire i have tried different codes but problem is same help me please.
i am using arduino uno r3 board smiley-sad-blue
Logged

0
Offline Offline
Tesla Member
***
Karma: 148
Posts: 9753
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
and cannot goes to a angle which i desire

Most continuous rotation servos can not be commanded to stop at an "angle".
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem i mention earlier is now solved can u tell me Is it possible that i can use infrared sensor without using analogue pins of Arduino uno instead can i use pin o and 1 TXd RXD for this purpose?
 
Logged

Pages: 1 [2]   Go Up
Jump to: