 How can I develop a code with Variable Speed for a Servo?

Hi! This is my first project as a newbie to Arduino. It’s a Sketching Arm with 2 servos and a fixed pen at the end as shown in the image. Basically for now, it can only draw a straight line.

And below is the modified Servo (Sweep) Library I used, where the count is linear so that the servo positions are also linear with respect to time (Graph 1) while moving from X to Z. And the figures below that is the corresponding movement. Now the problem is that the pen tip DOES NOT maintain a constant elevation (ground level) as the pictures show.

So now I want your help to change this code for this constant elevation by making the count (servo-positions) to be curvilinear as in (Graph 2), such that the arm should work like in the figures below it.

Any help would be appreciated!
Thanks In Advance! Arduino Code.rar (394 Bytes)

Is there a formula that relates the position of the drawing point to the angles of the servo ?

It would probably be easier to turn the mechanism on its side so that one servo moved the drawing point in an arc up and down the paper and the other moved it in an arc across the paper. That way it would be easy to maintain contact with the paper.

Nope… That is why I need an adjustable curvilinear variation to suit different height levels.

Ah yes I get it. Thanks. It even relieves the servos from extra lifting load right? I guess this is what u meant right?

But when drawing a straight line, still I need a curvy effect in their speed.
There’s an option, to increase the count by 1 (i = i+1) every time up to 90° and write another loop to reduce the count for the remaining 90°. (Uniform acceleration and deceleration). But i don’t know how…  Yes, that’s what I had in mind. You still need the algorithm, which I am afraid that I can’t help with.

The servo library supports both write() and write.Microseconds() methods. Depending on the resolution available from the servo the latter provides more precise control because the range of values that it accepts is wider.

Below are some links with servo speed info. I would think what you want to do might be to use two dimensional inverse kinematics formulas with a horizontal drawing arm.

http://www.bajdi.com/controlling-a-servo-without-the-delay-function/

http://forum.arduino.cc/index.php/topic,61586.30.html