Hi guys, i've got robotic arm, and now i'm doing math stuff. i don't get the way that sin works.

How could i translate math like:

sinα=12/15

sinα = 0.8

α = 53 degree

to Ardu code to get the same answer?

I have google it, and some sources said that it's not possible to UNO is that right?

Thank You for Your guidance,

I don’t understand. Are you trying to calculate the angle from the sin? That’s asin. You use sin() to get the sin from the angle and asin() to get the angle from the sin.

Remember, the Arduino is going to do all of this in radians and not degrees.

I try to calculate angle from triangle, and this angle give information about how much move the servo to pick up the object.

from radians i can easly change it to degrees. if i calculate that my angle is 53 from sinα=0.8

How could i calculate it in arduino?

by asin()?

Yeah. i'm bad at explaining, just... how to caluculate angle when i know that sinα = 0.8

luxfire:

by asin()?

Isn't that what I already said?

How do you calculate an angle from the sin in regular math? Forget the code for a second. Don't you use the arcsin? That's what asin calculates.

```
float alpha_radians = asin(0.8);
float alpha_degrees = alpha_radians*180./M_PI;
```

Where M_PI is defined in <math.h>

Pete

el_supremo:

```
float alpha_degrees = alpha_radians*180.0/M_PI;
```

To add one more thing, all of the trigonometric functions work in radians. So the only place that the degrees is useful is for display purposes and for the servo writes if you're not using writeMicroseconds (which you should if you want precision). So think carefully about where in the code you want to do this conversion. It isn't useful to change it to degrees if there is another trig step coming up and you'd just have to convert it back. Remember, these are float variables so every time you do that conversion you are adding some error.

@el_supremo: Note the small typo correction I made when I quoted you.

i'm using VarSpeedServo.h library to slow down servo, if i'll write position by Microseconds, could i also control movement speed not by delay()?

@Delta_G: Noted, but the compiler doesn't care.

Pete

el_supremo:

@Delta_G: Noted, but the compiler doesn't care.

Pete

Does it not? I've never tried that. I'll take your word for it. I just figured it was a typo.

luxfire:

i'm using VarSpeedServo.h library to slow down servo, if i'll write position by Microseconds, could i also control movement speed not by delay()?

You can ALWAYS avoid using delay.

as You see, i'm not very good with terms in Arduino, i'm a simple beginner who wants to learn from advanced members as You.

With this robotic arm, You're recommending writeMicroseconds, and with calculating radians/degrees, how could i change this radians/degrees into Microsec?

luxfire:

With this robotic arm, You're recommending writeMicroseconds, and with calculating radians/degrees, how could i change this radians/degrees into Microsec?

How a Servo Works

First you figure out the relationship between microseconds and angles for your particular servo (calibration) and then you write math to do that mapping. It's just math, nothing special.

luxfire:

I try to calculate angle from triangle, and this angle give information about how much move the servo to pick up the object.

from radians i can easly change it to degrees. if i calculate that my angle is 53 from sinα=0.8

How could i calculate it in arduino?

by asin()?

Yeah. i’m bad at explaining, just… how to caluculate angle when i know that sinα = 0.8

asin is short for *arcsine*, the more archaic name for the inverse sine function. In most modern math textbooks you’ll find it called sin^{-1}.