What is the easiest way to have a simple left and right movement?

Hello everyone,

I am trying to move a small (5cm x 5cm) platform left and right. I need something low power if possible.

What is the best way to reach my objective?

I have previously tried a servo motor but it starts twitches uncontrollably when I embed it in my system even when I give it an external power supply. (Standalone it works fine)

Thanks in advance

Twitching servos may indicate that you are no longer sending it commands - even when stationery it needs to be told that every few milliseconds. In other words you can't just suddenly stop communicating with a servo otherwise 'twitchiness' occurs as it doesn't know what to do. I don't why it would work in a standalone environment though. And yes, you should always power the servo separately as you have done.

A stepper motor may be better to move a platform just 5cm square - you could mount it on the motor output (pulley / cog / spindle /whatever) or have it move via a belt or pulley system.

Regrettably I don't (yet) have YouTube videos for either of these items so can't point you in that direction (although there may be other stuff there to tickle your interest!). URL in my sig at the footer of this post.

Well you can fix your servo system, there is no fundamental reason why it will not work.
Alternatively get some scrap CD drives, most have stepping motors attached to the read head that can be used as a platform.

Do you just need continuous back and forth motion, like the top diagram or 2 here?

Ralph_S_Bacon:
Twitching servos may indicate that you are no longer sending it commands - even when stationery it needs to be told that every few milliseconds. In other words you can't just suddenly stop communicating with a servo otherwise 'twitchiness' occurs as it doesn't know what to do. I don't why it would work in a standalone environment though. And yes, you should always power the servo separately as you have done.

A stepper motor may be better to move a platform just 5cm square - you could mount it on the motor output (pulley / cog / spindle /whatever) or have it move via a belt or pulley system.

Regrettably I don't (yet) have YouTube videos for either of these items so can't point you in that direction (although there may be other stuff there to tickle your interest!). URL in my sig at the footer of this post.

Yes you are right, I leave it idle for some time in my code while I get readings from a sensor. I think this could be it. Do I have to send it a move command every few seconds? Or is there a way to communicate with it without changing the angle?

I will also look into trying a stepper motor. Does a stepper motor take less power? Or do they all need external power supplies?

CrossRoads:
Do you just need continuous back and forth motion, like the top diagram or 2 here?
Cranks and cams: How they work - Explain that Stuff

Yes I believe the crank diagram depicts well what I need.

Grumpy_Mike:
Well you can fix your servo system, there is no fundamental reason why it will not work.
Alternatively get some scrap CD drives, most have stepping motors attached to the read head that can be used as a platform.

Yeah I got a few fixes I will try out tomorrow when I head to the "lab".

Communication with a servo happens every few milliseconds (don't remember the exact value but 20ms comes to mind).

Stepper motors are more powerful than servos and don't have that 'twitchiness' problem, either. But they do need external power. In fact most things except LEDs need external power as the Arduino can only supply 40mA absolute max (20mA recommended by Arduino.cc) per pin.

But at least your pain will feed into my videos on these two items so others will benefit in the future, so thanks for that!

And good luck with your fix(es).

With a servo you don't have to do anything to send it the data, it will send the correct value of pulse every 20mS.
You could get a bit of twitchyness if the servo's position resolution is less than you are trying to drive it with. This might show itself by it being stable for some position values and not for others.

Ralph_S_Bacon:
Communication with a servo happens every few milliseconds (don't remember the exact value but 20ms comes to mind).

Stepper motors are more powerful than servos and don't have that 'twitchiness' problem, either. But they do need external power. In fact most things except LEDs need external power as the Arduino can only supply 40mA absolute max (20mA recommended by Arduino.cc) per pin.

But at least your pain will feed into my videos on these two items so others will benefit in the future, so thanks for that!

And good luck with your fix(es).

Well I'm glad my misery will be in the benefit of future builders!

Also I think it's worth mentioning: is it possible to turn off the servo and turn it on only when needed instead of continuously communicating with it

is it possible to turn off the servo and turn it on only when needed instead of continuously communicating with it

Yes it is possible but it is a very bad idea.

You have to make the output into an input before you turn off the power with a top switching PNP transistor. Then three is nothing to stop it moving so the steering will drift.

Update:

After fiddling more with the Servo today, I found my problem to be the following:

At certain angles my Servo is stable (ex: alternating between 50 and 140 degrees). Whereas when I change the mentioned angles by about 10 degrees the twitching returns!

It's a close enough left and right movement.

I really wish I can get the full range of my servo though but I guess I will have to make use of what I have.

Also, thanks to everyone who helped and replied to this topic
I hope this helps anyone having the same problem :slight_smile:

bilalh:
Well I'm glad my misery will be in the benefit of future builders!

Also I think it's worth mentioning: is it possible to turn off the servo and turn it on only when needed instead of continuously communicating with it

Just one other point. While Mike is right about electrically unpowering the servo, you can stop sending pulses while leaving it powered.
Just use the "Servo" library's 'servo.detach()' method. It will have a similar effect to removing the power, without the complexity. Servo power consumption will be drastically reduced and it won't actively hold it's position. Call 'servo.attach(pin)' when you need to actively drive it again.

bilalh:
After fiddling more with the Servo today, I found my problem to be the following:

At certain angles my Servo is stable (ex: alternating between 50 and 140 degrees). Whereas when I change the mentioned angles by about 10 degrees the twitching returns!

That may be the case, but it remains that if your code is such that you are not sending it pulses all the time, then it will be twitchy.

Paul__B:
That may be the case, but it remains that if your code is such that you are not sending it pulses all the time, then it will be twitchy.

I have a servo in front of me right now that’s powered but no pulses are being sent and there is absolutely no twitching.
It’s running this code:-

#include <Servo.h>

const byte servoPin = 2;
Servo myServo;

void setup()
{
    myServo.attach(servoPin);
    myServo.write(90);
    delay(250);
}

void loop()
{
    myServo.detach();
}

It moves to the central position, then does nothing else at all.