Go Down

Topic: [PROBLEM] on coding towerpro Sg90 servo  (Read 242 times) previous topic - next topic

eccotejar

I want to code multiple towerpro Sg90 servo and any guides on coding each motor to run in different degrees or position?? I wanted to run my servo motor on going in different positions or opposite positions.
Thanks for the help in advance :)

johnwasser

The Arduino UNO can control 12 servos using the Servo library.  Use whatever digital output pins you like.  Provide about 1 Amp of 4-6V power for each servo.  When you write a position to the servo it will go there as fast as it can.  If you want the servo to move slower you have to break the motion into many small motions and spread them out in time.  See the "Servo->Sweep" example for that.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

eccotejar

#2
Feb 21, 2019, 03:43 pm Last Edit: Feb 21, 2019, 03:44 pm by eccotejar
The Arduino UNO can control 12 servos using the Servo library.  Use whatever digital output pins you like.  Provide about 1 Amp of 4-6V power for each servo.  When you write a position to the servo it will go there as fast as it can.  If you want the servo to move slower you have to break the motion into many small motions and spread them out in time.  See the "Servo->Sweep" example for that.
how can I code each servo motor to run in different positions?? or opposite rotations??

johnwasser

how can I code each servo motor to run in different positions?? or opposite rotations??
At any time you can write a new value to any servo to send them to any position.  You first have to decide what pattern of movement you want.  Describe the pattern in great detail.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

elvon_blunden

#4
Feb 21, 2019, 03:59 pm Last Edit: Feb 21, 2019, 04:21 pm by elvon_blunden
Describe the pattern in great detail.
And you will (edit, see next post) almost certainly very possibly ;) need to swot up on blink without delay and break the movement of each servo into tiny steps, and "blink" each servo to move a click (or not, if it's not due) each time through loop().


slipstick

how can I code each servo motor to run in different positions?? or opposite rotations??
Have you looked at the example programs? They show setting up a servo with Servo servoname. Then you send a servo to a position with servoname.write(position). So if you set up 3 servos called servo1, servo2 and servo3 and you write different values to them they go to different positions e.g.
Code: [Select]

Servo servo1;
Servo servo2;
Servo servo3;

// then later you write

servo1.write(30);
servo2.write(90);
servo3.write(150);

the servos go to different positions. The basics are really quite easy.

You may or may not need the added complications of blink without delay or sweep techniques depending on what EXACTLY you are trying to do which we don't know yet.

Steve

elvon_blunden

Assuming the servos in this current thread are these ones mentioned in a different thread:

we are using towerpro Sg90 servo for the fish movements.
... I'm very keen to see how servos will do that. I doubt if mimicking a fish's movement by discrete fins and stuff is simple to do.

You will without doubt need to:

Describe the pattern in great detail.

eccotejar

Assuming the servos in this current thread are these ones mentioned in a different thread:

... I'm very keen to see how servos will do that. I doubt if mimicking a fish's movement by discrete fins and stuff is simple to do.

You will without doubt need to:


https://youtu.be/iMSLcQSwS3g we are referring for this one. We would like to try this movement

elvon_blunden

#8
Feb 22, 2019, 07:59 am Last Edit: Feb 22, 2019, 08:00 am by elvon_blunden
https://youtu.be/iMSLcQSwS3g we are referring for this one. We would like to try this movement
Well first you need to define the movements, ie when servo1 does "this", servo2 does "that" followed by "some other thing" to your own satisfaction. That might be more difficult than the coding.

I'd say it's all very well making something "look" like a fish; I would imagine making it "swim" (in a controlled way) like a fish is a different kettle thereof. From your other thread, it seems that you actually want it to swim? You would need to know that to start moving from standstill the fish needs to wiggle in a certain way, and to stop it wiggles a different way, and to turn it must wiggle yet a different way. Do you know all of those? You need that before you can code, surely?



But that said, the Nov 2014 video says a tutorial is to follow; perhaps they did that in the 4 years since then?  Is that you tube fish a swimmer or just a bit of art?

slipstick

Define the movements that you want IN DETAIL. We're not going to work out for you what movements are needed based on a video. That's your job.

Oh and be aware that SG90s are micro servos and far from waterproof. So your "fish" had better be tiny and just decorative, maybe flapping like a fish but not in water.

Steve

elvon_blunden

So your "fish" had better be tiny and just decorative, maybe flapping like a fish but not in water.
Seems from op's other thread it's a genuine underwater device.

So the fish itself needs to be waterproof to keep the water away from the servos in the first place, like a submarine.


Go Up