How to set the default rotation direction of a continuous servo motor?

Hello,
I am using a continuous servo motor which is this PTK 8462 MG-D. I am trying to control it with a potentiometer, but i would like to know it is possible to set it is default rotation direction and how ?

here is my code

#include <Servo.h>
int potPin = A0;
int servoPin = 9;
Servo servo;
void setup()
{
Serial.begin(9600);
}
void loop()
{
int reading = analogRead(potPin); // 0 to 1023
Serial.println(reading);
  reading =  map(reading, 0, 260, 800, 2000); 
  
  if(reading > 5) {
    servo.attach(servoPin);
    servo.writeMicroseconds(reading);
  } else {
    servo.detach(); 
  }

}

With a continuous servo (not really a servo, just a gear motor controlled by a servo signal) the first thing is to find the setting that stops the motor. That should be around 90 degrees or 1500us. Then any setting less than that will have the motor turn reverse and more will turn forward at a speed proportional to the difference from the stop number.

Why attach and detach the servo in the if-else?

If you want it to turn a certain direction and speed at start up, write that number to the servo right before you attach the servo.

What does the map function output if the reading is over 260?

thank you for the reply,

I am working on a throttle pedal which can go from 0 to 260 only so i need to remap it to get the full signal
the detach and attach i tried them to stop the servo from doing that buzzing

Is it possible to control its speed also ?
and can this servo be controlled from the servo expander board ?

How is the servo being powered? Usually buzzing or jittering is a lack of current capability of the servo power supply. No Arduino is a power supply, your servo needs an external supply capable of supplying enough current.

Attaching and detaching the servo is a hack, the solution should be to find and cure the cause of the buzzing.

What servo expander board? That's the first mention of something that should have been in the original post. Any more surprises?

no my servo is powered externally from an adapter by 6v

Sorry for not mentioning the other questions in the original post, but it just came on my mind, because i have the servo driver and i would like to know how to control it from it

this is the servo driver i am talking servo driver

Do you have the documentation for the driver that shows how to control it? If ot, that is where to begin, not pictures of a board.

ok I see thank you so much

The Adafruit version of that servo board uses the same chip. Maybe you can use the Adafruit library.

1 Like

I tried from 0 to 1500 us but it did not turn the motor in the reversed direction

Hi,

What did it do?

Tom... :smiley: :+1: :coffee: :australia:

How about 1500us to 2200us?

nothing happened the servo did not turn

it turns in 1 direction

So from 800us to 2200us the motor only turns one way? Does the speed vary over that range?

Are you controlling the motor directly with the Arduino or through the servo driver board?

Hi,

Where does it say its continuous?

Pro-Tronik 17g 8462 MG-D 6kg/0.09s 17g Micro Digital HV Servo

Reference: A2P-78462
Condition: New product
Brand: A2Pro
Pro-Tronik 17g 8462 MG-D Micro Digital HV Servo. High end technology HV servo specially designed to be mounted in glider wings or every other demanding application. Everything in this servo has been thought to offer the best performances. Its small thickness allow it to be mounted in composite molded glider wings.

Can you please post link to where you purchased your servo?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

I think that is a mistake i made ! sorry about that it is 360 degrees ! but is there a way to make it rotate the other direction because i couldn't find any searching for it yesterday

i am still controlling it using the arduino only no driver, but what i found out that the speed of rotation is related to the speed of rotating the potentiometer ! whenever i turn it fast the servo turns fast and if i turn it slow the servo turns slow

I am confused.
So the servo follows the potentiometer? If you turn the pot clockwise the servo moves one direction and if you turn the pot back (counterclockwise) the servo moves the other direction? I am beginning to think that @TomGeorge may be into something. It sounds like you might have a regular servo, not continuous.

Can you make a short video showing what the servo does in response to the pot?

in my setup, I have the potentiometer at 0, and when i turn it, the servo turns in one direction, then when i turn the pot back to 0, the servo turn back the other direction but what i am asking is how can i reverse these directions for example if mainly the servo turn clockwise when i turn the pot up from 0 and then back to 0 the servo turn counterclockwise, i need to reverse them let it start by ccw and then cw

Hi,

Swap the outer connections on the potentiometer, leave the middle wiper connection connected to the analog input.

Tom... :smiley: :coffee: :coffee: :coffee: :coffee: :australia:
PS, At the moment when you turn the pot from 0 to full, what does the voltage on the analog input do?
PLEASE use a DMM and measure it.