Servo Motor Control

Hello,

Its my first time and I wish to control a normal gas / water valve using servo motor.

As valve needs only 90 degree to be open / close , I wish to initialize servo position to 90 degree. Then in loop it could move 45 + and 45 - ,

Now I only need the initial 90 degree once only ( I think ) , shall I still write it in void loop ( ) ?

Any tips for newbies ?

shall I still write it in void loop ( ) ?

If it needs to be positioned only once then do it in the setup() function.

How is the servo powered ? "From the Arduino 5V and GND pins" is the wrong answer.

From my judgement , It is bad to power anything at all from Arduino so I will make a battery pack for it. So external battery.

Alright then so if I write in setup()

" int pos = 90; object.write(pos); "

It will be good enough?

I cannot make more than a single post in 5 minutes I guess so here it is...

My teacher wishes us to understand motors, and he also wishes us to start to program electronics, aim is not to make things efficient but to get the job done. It is a project, even though it seems absurd to control such a valve , one could just use solenoid valve, But I understand that I need to start working on programmable ROMs and so I am ...

So I have a servo motor, I have a valve, I have an idea of coupling assembly ...

The valve can rotate 180 and so can the servo , but servo does not rotate necessarily 180 , sometimes more sometimes less ( not authentic source ) but I still want to get the middle 90 degree rotation. Middle 90 I can get by initializing servo to 90 degree, then valve can be opened by + 45 and closed by - 45 . That way I can be sure that my range of control lies within the range of motor or something and that the shaft would actually to go the point and not get stuck or something ...

Descriptive enough ? :p

If you really only want the servo to move once after the Arduino is switched on you could put the code in setup() and leave loop() empty. But I can't see why that would require an Arduino or a servo.

I suspect your requirement is more complex.

For your own benefit and ours you need to write a more extensive description of how your system is required to behave. I mean a plain language description, not code. If you have a clear project description it will be much easier to write code to give effect to it.

Have a look at Planning and Implementing a Program

...R

Also

I am a little confused about the output voltage I measure from DMM ( Between Output pin and GND ) ,

Its like a positive sin wave ....

Is that how the signal should be ?

Abdul_Moeez: Its like a positive sin wave ....

Is that how the signal should be ?

That depends on what the Arduino program is causing the I/O pin to do.

How can you detect a sine wave (or any sort of wave) on a DMM?

Post your program and tell us exactly what you are trying to measure.

...R

Robin2:
How can you detect a sine wave (or any sort of wave) on a DMM?

Post your program and tell us exactly what you are trying to measure.

…R

Well , I am not good at this … :frowning: . I set DMM to voltage ( 20 V DC ) and it shows that … 0 1 2 3 4 5, 5 4 3 2 etc etc
That is the signal that I would give to my servo right ? Does it’s voltage not help me in concluding anything ?

Program :

#include <Servo.h>
void Group_E_Project();
void Group_E_SERVO();

Servo object;

int pos=0 ;

void setup()
{
object.attach(9);
}

void loop()
{
Group_E_SERVO();
}

void Group_E_SERVO()
{
for (pos = 0; pos <= 180; pos += 1)
{
object.write(pos);
delay(200);
}
for (pos = 180; pos >= 0; pos -= 1)
{
object.write(pos);
delay(200);
}
}

What are you connecting the meter to?

Does it's voltage not help me in concluding anything ?

What does that sentence mean?

AWOL: What are you connecting the meter to?What does that sentence mean?

I just want to learn something , I am new and it does interest me but I know it will take me a while to ask the right thing.

Problem 1: If i write

" int pos = 90; object.write(pos); "

in global , will it move my motor shaft position to 90 degree ? If it won't , what will ?

Problem 2 : Can I get to know anything at all from the signal generated ? I have not done any course of signals , I have almost 0 knowledge about signals. I would like to get a direction so when I actually do these things in theory , I understand better. If possible , I would like what the above program would exactly do to my servo.

Sorry for vague statements and Thank you for your patience.

" int pos = 90;
  object.write(pos); "

is just a long-winded way of writing object.write(90);

A servo is operated by a very low duty cycle (typically 5 to 10%) PWM waveform at about 50Hz. Trying to make sense of this waveform with a typically DMM is a waste of time. Don't bother trying, you need an oscilloscope.

AWOL: " int pos = 90;   object.write(pos); "

is just a long-winded way of writing object.write(90);

A servo is operated by a very low duty cycle (typically 5 to 10%) PWM waveform at about 50Hz. Trying to make sense of this waveform with a typically DMM is a waste of time. Don't bother trying, you need an oscilloscope.

Thankyou and thankyou...