go_away

Author Topic: Servo Position Calculator  (Read 5586 times)

0 Members and 1 Guest are viewing this topic.

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Servo Position Calculator
« on: August 25, 2008, 01:43:53 PM »
I've been working on my biped for about a week now and it was getting annoying to figure out the amount of cycles needed each time. So I developed a servo position calculator that calculates the angle, cycles delay,milliseconds delay, and microseconds delay for a servo when given at least one variable. It even visually displays the turn of the servo onscreen.

It is extremely useful for me. Please note : The values generated are approximate and not perfect(since it varies per servo) but you will barely notice the error.



Click for the self installer. Just unzip , run setup and open the program from Start Menu. For windows only.
http://rapidshare.com/files/140067901/Servo_Position_Calculator.zip.html

Enjoy,
Eric

EDIT : Updated version
http://erobots.blogspot.com/2008/08/update-for-servo-position-calculator.html
« Last Edit: August 26, 2008, 10:56:57 AM by airman00 »
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: Servo Position Calculator
« Reply #1 on: August 25, 2008, 04:28:41 PM »
Can you make it a webapp instead of a VB app?

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: Servo Position Calculator
« Reply #2 on: August 25, 2008, 04:53:54 PM »
Can you make it a webapp instead of a VB app?

I dunno how to .

If you have some way to upload a VB app online to web app , please tell me.
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: Servo Position Calculator
« Reply #3 on: August 25, 2008, 05:14:12 PM »
don't need all the graphics, just post the code, and i can convert it to PHP/Perl  for use in the LAMP platform

Edit: I just found this for you:
http://msdn.microsoft.com/en-us/library/ms172567(VS.80).aspx
« Last Edit: August 25, 2008, 05:15:44 PM by pomprocker »

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: Servo Position Calculator
« Reply #4 on: August 25, 2008, 06:26:33 PM »
don't need all the graphics, just post the code, and i can convert it to PHP/Perl  for use in the LAMP platform

Edit: I just found this for you:
http://msdn.microsoft.com/en-us/library/ms172567(VS.80).aspx


My code isn't very "clean" . I used only like two macros and the rest was just "brute" programming . I can provide you with all the formulas though if you want that.
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,653
  • Helpful? 169
    • Society of Robots
Re: Servo Position Calculator
« Reply #5 on: August 25, 2008, 08:21:18 PM »
You should have a box to check off whether its for the $50 bot or the Axon.

Also, add another box for a 'fudge factor' that just adds to the final result . . . in case people modified their servos differently.
« Last Edit: August 25, 2008, 08:22:14 PM by Admin »

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: Servo Position Calculator
« Reply #6 on: August 25, 2008, 08:28:57 PM »
You should have a box to check off whether its for the $50 bot or the Axon.

Also, add another box for a 'fudge factor' that just adds to the final result . . . in case people modified their servos differently.

Yea I will add all those stuff in later versions . I intended for this to be for unmodified servos but I guess I can add options for modified servos.

One problem however- I assumed in this program the uS pulse relating to angle is linear which I do not think it is. I will do some more research into it and perhaps work in it more tonite or later this week.
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: Servo Position Calculator
« Reply #7 on: August 26, 2008, 09:40:20 AM »
Here are the final formulas for everything . Please note that this is for 16 mHz . If you want it at 1 mhz for the 50 dollar robot just change the main formula to convert mS to cycles. For 16 mHz its     mS*466.6     For 1 mHz its  23.2* mS . Just derive the other formulas relating to cycles from that formula, its not so difficult.
The formulas will work as follows , you are given a value and from there you derive the rest:

Key:
Angle is the angle of the turn of the servo. 0 degrees is the center point of the servo . Negative angles are accepted,
mS = Milliseconds delay for the servo
Cycles = cycles delay for the servo
uS = Microseconds delay for the servo


Given : Angle
mS = (10(angle) + 1500) / 1000
cycles = (10(angle) + 1500)/1000 * 466.6
uS =10(angle) + 1500

Given: Cycles
Angle =  [ (  (cycles/466.6) * 1000 )  - 1500] / 10
mS = cycles/466.6
uS = (cycles/466.6) * 1000

Given: mS
Angle = [(ms*1000)-1500] / 10
cycles= mS * 466.6
uS = mS * 1000

Given: uS
Angle = (uS-1500) /10
cycles = (uS / 1000 ) *466.6
mS= uS/1000


All of the above formulas were derived from :
uS = 10 ( angle) + 1500
mS = 1000 * uS
cycles = mS * 466.6

Btw if someone wants to make a web app go ahead ! I will upload the newest version of this program later today.

,Eric
« Last Edit: August 26, 2008, 10:21:29 AM by airman00 »
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: Servo Position Calculator
« Reply #8 on: August 26, 2008, 10:45:28 AM »
Competition is good :D
This is my servo calculator made for the web.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: Servo Position Calculator
« Reply #9 on: August 26, 2008, 10:52:27 AM »
Competition is good :D
This is my servo calculator made for the web.


UCHHH WHY DIDNT YOU TELL ME YOU MADE THAT!!!!

lol , i don't think we need a web app now ;)

EDIT: It doesn't seem like your app includes calculations for cycles. Maybe you can add that in?
« Last Edit: August 26, 2008, 11:02:00 AM by airman00 »
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: Servo Position Calculator
« Reply #10 on: August 26, 2008, 10:56:11 AM »

I fixed some bugs and also added option buttons on the side of the servo wheel so that you can just click for the following angles = -90 , -45, 0 , 45, 90 .

For manual control just enter the value in the proper text box and press Calculate to get the other values.

Here is the download link for the newest version:
http://rapidshare.com/files/140300072/Servo_Calculator_Setup.zip.html

Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,653
  • Helpful? 169
    • Society of Robots
Re: Servo Position Calculator
« Reply #11 on: August 26, 2008, 12:49:26 PM »
Hmmm appears we have a competition going on . . .

Anyway, I got a better idea for you airman00, since you are working on a biped anyway. How about a program that shows a stick figure leg. You can rotate the joints as you like, and as the output it will give you a bunch of servo angles.

This way you can see the leg as a whole (or even whole robot) before doing any programming.

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: Servo Position Calculator
« Reply #12 on: August 26, 2008, 12:55:06 PM »
Anyway, I got a better idea for you airman00, since you are working on a biped anyway. How about a program that shows a stick figure leg. You can rotate the joints as you like, and as the output it will give you a bunch of servo angles.
This way you can see the leg as a whole (or even whole robot) before doing any programming.

Admin , I started work on that two days ago and this servo calculator program was a spinoff of the main biped program . I wanted the biped program to be a surprise later on :P

My problem with the biped program is that I have to program how each joint affects the other joint. Its a bit daunting but I think I will be able to finish it next month.
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: Servo Position Calculator
« Reply #13 on: August 26, 2008, 01:00:51 PM »
have fun with those kinematics and reverse kinematics  :P

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: Servo Position Calculator
« Reply #14 on: August 26, 2008, 01:01:22 PM »
have fun with those kinematics and reverse kinematics  :P

thank you , i'll be sure to post lots of questions on the forum   ;)
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,653
  • Helpful? 169
    • Society of Robots
Re: Servo Position Calculator
« Reply #15 on: August 26, 2008, 01:08:04 PM »
All you need is forward kinematics: simple trigonometry.

J1 and J2 can be found here:
http://www.societyofrobots.com/robot_arm_tutorial.shtml#forward_kinematics

Then just calculate J3 as if J1 is the base.

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: Servo Position Calculator
« Reply #16 on: August 26, 2008, 02:55:28 PM »
Well, kinematics are easy, you just compute each point as a radius/line
reverse kinematics is the real thing, asking the user where each leg should be and the MCU doing all the computations.

have you ordered the lasers for the biped human mountable mech? XD

Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline ErikY

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: Servo Position Calculator
« Reply #17 on: July 12, 2012, 12:52:37 PM »
Can someone explain to me how this would be used in c code?

I just finished the $50 robot, and the next thing I want to tackle will require me to move my servo's to very specific angles and then stop the servo at that angle.

The code I am working off of is Admin's code in SOR_utils.h which is called in the .c file by calling the method and sending in a 25 or 44, which seems to make this turn indefinitely at a certain speed.

I read the magic number 25 and 44 post, and I think I understand that a number under 35 will make the modified servo go one way, while a number above 35 will make it go the other direction. And, the closer to 35 or the further from 35 will make it go faster or slower.

So if I wanted to go to say -45 degrees and stop, I was thinking I would calculate the amount of time for 1/4th of a rotation, send the speed but change the delay_cycles to that amount of time calculated for 1/4th of a rotation, is that correct?

Can anyone help me out with this?

So I have this for example:

Code: [Select]
void delay_cycles(unsigned long int cycles)
{
while(cycles > 0)
cycles--;
}

void servo_left(signed long int speed)
{
PORT_ON(PORTD, 0);
delay_cycles(speed);
PORT_OFF(PORTD, 0);//keep off
delay_cycles(200);
}

 


Get Your Ad Here

data_list