Problem with Continuous servo voor chicken coop door.

Electric componements:
DS3231
Arduino Uno
Fitec FS5106R Servo

Hi,

Im making a automatic chicken door with arduino but its acting a bit weird.
The servo im using (Fitec FS5106R Continuous Servo) sometimes just starts to slowly spin for 1 sec and then it stops. Anyone know what to do?

Here’s my code BTW.

#include <DS3231.h>
#include <Servo.h>

DS3231  rtc(SDA, SCL);

Time t;

const int OnHour = 21;
const int OnMin = 45;
const int OnSec = 01;


const int OffHour = 22;
const int OffMin = 13;
const int OffSec = 01;

Servo Tservo;

void setup() {
  Serial.begin(115200);
  rtc.begin();

Tservo.attach(10);


  //rtc.setDOW(FRIDAY);    
  //rtc.setTime(16, 47, 0);     
  //rtc.setDate(1, 5, 2020);   

  
}

void loop() {
  t = rtc.getTime();
  Serial.print(t.hour);
  Serial.print(" hour(s), ");
  Serial.print(t.min);
  Serial.print(" minute(s)");
  Serial.println(" ");
  delay (1000);

    Tservo.attach(10);
  
  if(t.hour == OnHour && t.min == OnMin && t.sec == OnSec){

    Tservo.write(180);
    delay(5000);
    Tservo.detach();
    }

   
   
  if(t.hour == OffHour && t.min == OffMin && t.sec == OffSec){
      
      Tservo.write(0);
      delay(5000);
      Tservo.detach();
     
      
    }

   if(t.hour != OnHour && t.min != OnMin && t.sec != OnSec){
      Tservo.detach();
     
    }
    
}

Kyan.

Anyone know what to do?

Get a real servo perhaps, maybe a sail winch servo. A "continuous servo" is not really a servo at all, rather it is an electronically controlled motor that you cannot position at an exact angle

When you detach() it then it is free to move. From the code I guess that it is driving a pulley that winds up a rope/cable to open/close the door. Is that correct ?

UKHeliBob:
From the code I guess that it is driving a pulley that winds up a rope/cable to open/close the door. Is that correct ?

Yes thats correct but the problem is thats the only way I can get it to stop becuz when i do Tservo.write(90) for example it keeps rotating very slowly. You think there is another way I can make this work.

Try a few values round 90. There's usually one between about 87 and 93 that will stop the motor.

Steve

Thanks gonna try it now

The only continuous servo I've ever used has an adjusting screw: do a write(90) then adjust the screw until it stops. Does that one not have such a screw tucked away somewhere?

Im not sure maby inside?

Ill check it out right away

thatkyan-:
Im not sure maby inside?

Ill check it out right away

I’d be surprised if it was inside, but it’s worth a look. Mine’s on the outside…

You think there is another way I can make this work.

Using a sail winch servo or a stepper motor would allow you to control the actual position of the servo/motor output

“Yes thats correct but the problem is thats the only way I can get it to stop becuz when i do Tservo.write(90) for example it keeps rotating very slowly. You think there is another way I can make this work.”

A simple way to keep a continuous servo from “creeping” is to code detach the servo when it has reached its desired position, and attach it when it is to move to another position. Also, using myservo.writeMicroseconds gives much better control of a servo than writing a degree position. Below is some old servo test code that should help you find the no movement “sweet spot” value for your continuous rotation servo.

// zoomkat 3-28-14 serial servo incremental test code
// using serial monitor type a character (s to increase or a 
// to decrease) and enter to change servo position 
// (two hands required, one for letter entry and one for enter key)
// use strings like 90x or 1500x for new servo position 
// for IDE 1.0.5 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.

#include<Servo.h>
String readString;
Servo myservo;
int pos=1500; //~neutral value for continuous rotation servo
//int pos=90;

void setup()
{
  myservo.attach(7, 400, 2600); //servo control pin, and range if desired
  Serial.begin(9600);
  Serial.println("serial servo incremental test code");
  Serial.println("type a character (s to increase or a to decrease)");
  Serial.println("and enter to change servo position");
  Serial.println("use strings like 90x or 1500x for new servo position");
  Serial.println();
}

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) {
    if(readString.indexOf('x') >0) { 
      pos = readString.toInt();
    }

    if(readString =="a"){
      (pos=pos-1); //use larger numbers for larger increments
      if(pos<0) (pos=0); //prevent negative number
    }
    if (readString =="s"){
      (pos=pos+1);
    }

    if(pos >= 400) //determine servo write method
    {
      Serial.println(pos);
      myservo.writeMicroseconds(pos);
    }
    else
    {   
      Serial.println(pos);
      myservo.write(pos); 
    }
  }
  readString=""; //empty for next input
}

A simple way to keep a continuous servo from "creeping" is to code detach the servo when it has reached its desired position,

That's all very well but the servo is then free to rotate under load which may be undesirable

"That's all very well but the servo is then free to rotate under load which may be undesirable"

If there is rotational force on the servo such that it will rotate against the gear resistance when detached, then supply it with a control position such that the servo stops being turned by the force.

If there is rotational force on the servo such that it will rotate against the gear resistance when detached, then supply it with a control position such that the servo stops being turned by the force.

But the OP is using a continuous rotation "servo" so it cannot be positioned. It is the wrong tool for the job

UKHeliBob:
But the OP is using a continuous rotation "servo" so it cannot be positioned. It is the wrong tool for the job

The OP hasn't expressed an issue with positioning yet, so that may be solved.

jubukraa:
The only continuous servo I've ever used has an adjusting screw: do a write(90) then adjust the screw until it stops. Does that one not have such a screw tucked away somewhere?

Yes i found the potentiometer inside and i kept twisting it when i did a write(90) till it stopped and now it works!!
All i have to do now is find out what kind of voltage im gonna use becuz when i connect it to my laptop it works but it doesnt work with a 9V adapter

If you have the servo connected to the Arduino 5V pin then it won't work. The internal regulator can't deliver nearly enough current for that big servo.

You are only getting away with it when powered from the laptop by USB because that bypasses the regulator so if it pulls too much current it's the laptop that will break not the Arduino.

If you must run it from 9V then connect the 9V supply to a 6V DC-DC converter for the servo power.

Steve

Yes i found the potentiometer inside and i kept twisting it when i did a write(90) till it stopped and now it works!!

It works at the moment, but will the motor rotate at the same speed when the voltage supplied to it is different, particularly if it varies over time ? Is there any chance that you could attach some kind of encoder to the output shaft so that the servo can be positioned rather than relying on timing and good luck ?

zoomkat:
The OP hasn't expressed an issue with positioning yet, so that may be solved.

Your right i'm not having any problems with the positioning becuz i measured how long the servo had to move to make the chicken coop door go Up/Down and than im just doing Tservo.write(The amount of seconds);

The main problems i have RN are the powering issue and after a day of being hooked up to my laptop voor testing in the end it didnt even work like expect because it just didnt turn.

UKHeliBob:
Is there any chance that you could attach some kind of encoder to the output shaft so that the servo can be positioned rather than relying on timing and good luck ?

Im not sure i tried alot of things for example
Tservo.detach();
Tservo.write(90);
Tservo.writeMicroseconds(....);

Im not sure what to try anymore

Im not sure what to try anymore

What I had in mind was a method of knowing how far the motor had rotated that did not rely on time and voltage