Servo Motor Control

Dear Everyone,

I have an uno kit and a servo motor 24V and a proximity sensor.

Operation required:

  1. When the proximity switch detects an object the motor rotates one revolution even if the sensor goes low and then stop rotating.

  2. Even if the sensor detects another object while the motor is rotating no action will be taken untill the motor stops.

  3. control the speed of the servo motor as per application requirements.

I have already write a code for continuous operation as below:


#include <Servo.h>;

Servo myservo;
int pos = 0;

void setup()
{
myservo.attach(3);
}

void loop()
{
for(pos = 0; pos <= 180; pos += 1)
{
myservo.write(pos);
delay(15);
}
for(pos = 180; pos >=0; pos-=1)
{
myservo.write(pos);
delay(15);
}
}

Any help will be very appreciated.

Thanks in advance

First thing I would do, if that's a 24V servo, is check in its datasheet if it a) is controlled by a 5V signal and b) if so, are they the normal 1000-1500-2000ms signals we use here in ArduinoLand.

(Or do you know what for a fact already?)

edit: sorry I missed the below so you presumably do know your servo works with the library?

I have already write a code for continuous operation as below:

I have already write a code for continuous operation as below:

That looks like the servo sweep example. Does your servo do what the code says? Where is the code for the proximity switch? Does the servo provide positional feedback? If not how do you know if the motor is running or in position?

I know that uno kit will not be suitable for 24v but i have inserted motor driver module between arduino kit and the motor.

the code runs correctly but i don't how can i add the option of proximity switch to control the start of the motor

a7md7sam:

  1. When the proximity switch detects an object the motor rotates one revolution

I don't think continuous servos are any good at rotating a known amount. A stepper would probably be a better option for this.

a7md7sam:
I have an uno kit and a servo motor 24V and a proximity sensor.

That sounds like it may be an industrial servo rather than the hobby servos that the Servo library is intended for.

Post a link to the datasheet for the servo motor.

...R

I don't have the datasheets but it is industrial one.

If Arduino can't be used, how can i control this motor?

a7md7sam:
If Arduino can't be used, how can i control this motor?

Well we don't know it can't, yet. I asked earlier if you had tried the sketch you wrote (aka sweep) and you didn't answer, so it's not clear if you tried it or not.

As to the second part, how, that would surely require you to give links to the datasheet?

a7md7sam:
I don't have the datasheets but it is industrial one.

If Arduino can't be used, how can i control this motor?

In all probability an Arduino can be used. But I doubt very much if the Arduino Servo library is relevant. Industrial servos have more in common with stepper motors.

However without the datasheet or any information at all from you about the motor how can you expect help?

...R