go_away

Author Topic: cycles timing question  (Read 7596 times)

0 Members and 1 Guest are viewing this topic.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,663
  • Helpful? 169
    • Society of Robots
Re: cycles timing question
« Reply #30 on: August 22, 2008, 10:20:17 PM »
Hmmmm but on gcc for microcontrollers it sets unsigned int to 256, where its 8 bit, or 2^8.

And for unsigned long int, it is 65535, for 2^16.

Its not the same as on a PC where an unsigned long int is 2^32, or 4294967296.
(not 4294967295 ;D)

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: cycles timing question
« Reply #31 on: August 23, 2008, 05:00:21 AM »
Quote
Hmmmm but on gcc for microcontrollers it sets unsigned int to 256, where its 8 bit, or 2^8.

really? i didn't know that. got link?

the link to the AVRlib file Pomprocker posted should take precedence over GCCs defaults though. http://www.mil.ufl.edu/~chrisarnold/components/microcontrollerBoard/AVR/avrlib/docs/html/avrlibtypes_8h-source.html
i usually use AVRlib which is probably why i've never picked up on this before.

Quote
(not 4294967295 Grin)

well if we want to get pedantic about it.... i was talking about the highest value in a 4 byte int so, yes 4294967295.
it's 4294967296 different values. from 0 to 4294967295. the highest value is 4294967295. (0 takes up one place.)
the same as the highest value for a 1 byte integer is 255 (not 256).


dunk.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,663
  • Helpful? 169
    • Society of Robots
Re: cycles timing question
« Reply #32 on: August 23, 2008, 06:38:55 AM »
Hmmmm I should have read though that link further . . . this is odd tho . . . because when I declare an unsigned long int, my variable resets at 65535 . . . yet this code says 4294967295 for unsigned long ints . . .

Sorry for being 'pedantic', I was just poking fun :P

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: cycles timing question
« Reply #33 on: August 23, 2008, 12:16:12 PM »
Quote
Sorry for being 'pedantic', I was just poking fun Tongue
yes. me too. bring it.

maybe i should make it more obvious....
naaa. you'll work it out.


dunk.

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: cycles timing question
« Reply #34 on: August 23, 2008, 10:16:40 PM »
But still why did i have to do this for it to work?
Code: [Select]
microseconds=microseconds/16;
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: cycles timing question
« Reply #35 on: August 23, 2008, 11:04:27 PM »
well the delay_us function is calculated by whats in global.h right?

so whats your F_CPU?

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: cycles timing question
« Reply #36 on: August 24, 2008, 05:46:33 AM »
well the delay_us function is calculated by whats in global.h right?

so whats your F_CPU?
16mhz
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: cycles timing question
« Reply #37 on: August 24, 2008, 12:13:59 PM »
maybe the function we came up with is a combination of a cycle delay and a timer delay

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: cycles timing question
« Reply #38 on: August 24, 2008, 11:22:25 PM »
OK so even when dividing by 16 I dont get the correct position

I'll play around with this thing later . It seems like cycles based timing would be more accurate anyways
« Last Edit: August 24, 2008, 11:31:14 PM 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: cycles timing question
« Reply #39 on: August 24, 2008, 11:46:06 PM »
According to Admin to calculate the cycles from mS you use the formula below
23/.992*(16MHz/1MHz)*(time in milliseconds) = number of cycles
Also, it says on the Axon page to use 700 cycles as the centering cycle

Now if we solve :
23/.992 = 23.1854839
and we say that 1.5mS is the pulse needed to center a servo

23.1854839 *(16) * (1.5) = 556.451614

So where do we get the 700 cycles from???
My only guess would be for 20mhz since for that it would be
23.1854839 * 20 * 1.5 = 695.564517
« Last Edit: August 25, 2008, 12:30:46 AM by airman00 »
Check out the Roboduino, Arduino-compatible board!


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

www.Narobo.com

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,663
  • Helpful? 169
    • Society of Robots
Re: cycles timing question
« Reply #40 on: August 25, 2008, 04:46:48 AM »
Thats the equation for the $50 Robot, not the Axon. Use this:
234/1.003*(time in milliseconds) = number of cycles

Also, centering can be different if you modded the servo differently. You might find it centering between 500-700.

(Where did I say 700 so I can update that?)

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: cycles timing question
« Reply #41 on: August 25, 2008, 07:35:52 AM »
By the axon sample code page

Quote
SERVO CENTER CODE

      People ask all the time for the code used to center the servo. Well, here you go!

      while(1)
         {
         if(button_pressed())
            {
            wheel_left(700);
            delay_ms(20);
            }
         }
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: cycles timing question
« Reply #42 on: August 25, 2008, 07:51:28 AM »
Use this:
234/1.003*(time in milliseconds) = number of cycles

That means that
(234 / 1.003) * 1.5 = 349.95015
Shouldn't it be higher than 349 ?

Also if we look into this post about the "magic numbers" - http://www.societyofrobots.com/robotforum/index.php?topic=2724.0
We see that he correctly says
Quote
Letís compute how many cycles the 1.5 ms correspond. For this case, the number of cycles would beÖ
23/.992*(1.5) = 34.8 (letís make an integer of 35).


So thats 34.8 @ 1 mHz ( speed of 50 dollar robot) and guess what 34.8 * 16 ( speed of Axon) is ? Its  556 .
I know I am basically just repeating the formula I posted up before , but this is my logic to get 556.

Also, centering can be different if you modded the servo differently. You might find it centering between 500-700.

I am using the servos in my bipedal robot and I am not modifying them. 1.5 mS is the standard pulse for centering servos.
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: cycles timing question
« Reply #43 on: August 25, 2008, 08:40:09 AM »
hmmm for some reason 700 seems to be  the center point of the servo much more so than 556 is .

Also if you do the math  A pulse of 3 mS would equal 700 cycles , and 3mS/2  gives you 1.5mS , the code to center it.
I need some serious explaining here .


Update:
I've been playing around with it more and it turns out that the formula below seems to be the correct one

(234 / 1.003) * 2 * mS  or even easier just do       466.6 * mS = number of cycles
Example:  466.6 * mS = 699.9 cycles  // around 700 cycles
« Last Edit: August 26, 2008, 09:25:39 AM by airman00 »
Check out the Roboduino, Arduino-compatible board!


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

www.Narobo.com

 


Get Your Ad Here

data_list