How to control a servo not by its position but by its speed ?

Hello,
I'm trying to make a solar tracker using an Arduino UNO and 2 servos.
To do so, im reading the values of two light sensors and comparing their values. When it's below a certain value, i want for the servo that is needed to move to move.
For example :
image
So, with this while, i want the servo to move in the direction of CHD, and to stop when CHD-CHG > 2, but if i do that i have to control the servo's speed, since i dont care about its position. However, i dont know how to control the servos speed.

Any advice ?

Welcome to the forum

Presuming that you are using proper servos and not "continuous rotation servos" then take a look at the Servo Sweep example in the IDE

For more help, post your sketch here, using code tags when you do

3 Likes

We know that the Earth rotates 15 degrees per hour. I hope that helps.

Turn them ON?

    if (inpA < inpB)
        servoPos++;
    else if (inpA > inpB)
        servoPos--
    servo.write (servoPos);

To calculate speed (velocity vector) you need two components:

  1. time (beginning time to ending time)
  2. distance (beginning angle to ending angle)

v = t/d

[edit] sorry... velocity is distance over time: v = d/t... thank you for correcting me.

Most standard servos operate on position, not time.
One could, I imagine, run the servo a given amount of time which may/may not work as expected against any distance parameters.

Seems to be class is back in session and everyone has continuous servos for wheel drivers.

You are contradicting yourself. Moving the servo in the direction of CHD until CHD-CHG>2 is controlling the servo's position. The only effect of the speed of the servo is in how long it takes to travel from its current position to the position where CHD-CHG>2.

Even if you are using a continuous rotation servo, the light sensors are acting as positional feedback. You would need to control the speed of the servo in that case, but mainly to prevent overshooting the final position by so much that it takes forever to settle down and stop.

I think this problem is best solved by using a stepping motor rather than a servo. This is because the speed of movement is known and so you would not need any sensors.

By using sensors like you propose then it would not work if it is a cloudy day.

1 Like

Hi @danviouuu
Welcome to the forum.

Until the op replies we can't do much.
I think that the op may be over thinking the situation and may need to experiment with the hardware.
@danviouuu have you looked at other Arduino Solar Tracker projects, Google..

Can you please tell us your electronics, programming, arduino, hardware experience?

You will have to include some hysteresis in your code to stop the tracker hunting around the sweet spot.

Look here.

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

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.