Rotating pedestal with a continuous Servo (FS90R)

Hello everyone, I got my servo attached to my Arduino Uno and tested with the following code:

#include <VarSpeedServo.h>
 
VarSpeedServo MyServo;        // servo objects
 
int servoSpeeds = 1; // sweep speed, 1 is slowest, 255 fastest)
int servoMinPosition = 0; // the minumum servo angle
int servoMaxPosition = 360; // the maximum servo angle
 
void setup()
{
 
  MyServo.attach(9);       
  MyServo.slowmove(servoMinPosition,servoSpeeds) ; // start sweeping from min position
 
}
 
void loop()
{
  // sweep the servos
 
  if( MyServo.read() == servoMinPosition)
  {
    MyServo.slowmove(servoMaxPosition,servoSpeeds) ; 
  }       
  else if( MyServo.read() == servoMaxPosition)
  {
    MyServo.slowmove(servoMinPosition,servoSpeeds) ; 
  }       
 
}

unfortunately, Im not clear how to get this servo to slow down. Right now its just spinning with reckless abandon. Ideally, I'd like it to just spin like a lazy susan so I can plop a small resin figurine on top and let it spin. This is all part of a larger project, but i'm trying to get this done bit by bit.

Does anyone have any experience with controlling the speed of a micro-servo? The speed im looking for is exactly like:

Rotating Music Box Example

Ultimately the project will work as such:

Trigger > fairy light + music + rotating pedestal > end

Investigate the library, what functions it has. Speed ought to be found there.

A continuous rotation servo does not respond the way it looks like your code, and you, are expecting.

Write 90 to stop.

Values less than 90 will make it go one way, the further away from 90 the faster.

Values greater than 90 will make it go the other way, the further away from 90 the faster.

So 70 might be slow CCW motion, and 110 slow CW motion.

Experiment. Learn.

Lastly, read() only reports what you last wrote. For no kind of cheap servo can it actually report where the servo is. Only tells you what you already know - the last thing you wrote.

As such, read() is almost 100 percent worthless.

a7

I'd like to learn more about what you mean by this? Write 90 to stop? I've been tinkering around with min and max positions. I'm wondering if i could create a "slow effect" by introducing a delay in the loop?

Also, I'm ready to delete that read () function, once i figure out how to extricate it without breaking the code. I actually just took this code from an article on servo examples.

Sry sry sry, didn't notice you were using that library.

Which I think is not appropriate for continuous rotation servos.

At least right now my brain is too hot to make any sense of slow moving calls to such a servo.

So I was talking about the regular servo library, and its write() method. Try this and tell us what you observe:

# include <Servo.h>

Servo myservo;

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9
}

void loop() {

  myservo.write(90);     
 
  delay(3000);

  myservo.write(60);

  delay(5000);

  myservo.write(120);

  delay(5000);
}

HTH

a7

okay, so my servo spins pretty quickly and then stops for 3 seconds, spins, stops 5 seconds, spins and then repeats

Clockwise alternating with anticlockwise?

So try values closer to 90, like 80 and 100.

If you make the 5000 larger, it should just go in that direction longer.

If that's what you find, now we should start talking about what you want this to do. Maybe you already siad.

But it you are expecting to be able to turn accurately to a point, or go in exactly a number of degrees like three rotations, I think you'll have to add to the hardware some kind of means to detect when you've arrived.

If you can be happy with 180 degrees end to end, or some servos will do a bit more close to 360, you'll want to switch to a regular "goes where you tell it" servo.

a7

Here's a simple test pgm, you can get better resolution with "servo.write microSeconds":

/*
 Try this test sketch with the Servo library to see how your
 servo responds to different settings, type a position
 (0 to 180) or if you type a number greater than 180 it will be
 interpreted as microseconds(544 to 2400), in the top of serial
 monitor and hit [ENTER], start at 90 (or 1472) and work your
 way toward zero (544) 5 degrees (or 50 micros) at a time, then
 toward 180 (2400). 
*/
#include <Servo.h>
Servo servo;

void setup() {
  // initialize serial:
  Serial.begin(9600); //set serial monitor baud rate to match
  servo.write(90);
  servo.attach(9);
  prntIt();
}

void loop() {
  // if there's any serial available, read it:
  while (Serial.available() > 0) {

    // look for the next valid integer in the incoming serial stream:
    int pos = Serial.parseInt();
    pos = constrain(pos, 0, 2400);
    servo.write(pos);
    prntIt();
  }
}
void prntIt()
{
  Serial.print("  degrees = "); 
  Serial.print(servo.read());
  Serial.print("\t");
  Serial.print("microseconds =  ");
  Serial.println(servo.readMicroseconds());
}  

the idea is that the servo will begin when a trigger is pressed and will rotate for a set duration of time (an mp3 file).

The only controls I need on the servo is speed, a trigger to start and set the duration of spin.

So do you still need help?

Now that you know how to make the motor stop and go, post your attempt to make it go when one thing happens (like pressing a button) and stop when something else happens (like pressing another button, or seeing that a certain time has elapsed).

a7

Sorry, I mean to say I'm still in the dark how to accomplish all this. But thats my ultimate goal with the servo. I should mention, that button I mentioned earlier is going to be doing triple duty (I'm hoping it will trigger that servo, an audio file and some led lights all at once)

I don't know where you are on the learning curve. This is fairly simple, at least in the abstract.

The examples in the IDE should help, those in Examples/02.Digital are a good start.

In particular, read and run those you need to on the way to understanding

 Examples / 02.Digital / StateChangeDetection

That's all I can offer for now from here under the umbrella.

At least you should be able to do the part where the turntable starts on a "trigger".

HTH

a7

I'm beginning to wonder if a stepper motor with a stepper motor driver would be a far easier solution. I was reading more about the pros and cons of using a stepper motor vs a servo motor and the biggest thing that caught my eye was the "In overall performance, servo motors are best for high speed, high torque applications while stepper motors are better suited for lower acceleration". So I think I'll probably just switch gears and control the motor with a driver board.

Thats not an easy way out, right? eh? :neutral_face: