|
|
|
|
September 02, 2010, 09:41:43 PM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: March 18th - Buy an
Axon
or
Axon II
, build a great robot, and support SoR.
Robot Forum
Home
Help
Search
Login
Register
Robot Forum
>
Software
>
Software
>
About the “magic” numbers 25 and 44 on the photovore_v1.h file
Pages: [
1
]
Print
Author
Topic: About the “magic” numbers 25 and 44 on the photovore_v1.h file (Read 7899 times)
0 Members and 1 Guest are viewing this topic.
paulobrasko
Beginner
Helpful? 0
Offline
Posts: 6
About the “magic” numbers 25 and 44 on the photovore_v1.h file
«
on:
December 30, 2007, 08:22:07 PM »
To all,
I was wondering about the numbers 25 and 44 from the photovore_v1.h file that are used to move the robot. I spent some time and I think I can provide a good explanation for the people that are wondering for the same reason.
Please, if you see anything wrong in my explanation (maybe everything at all), please feel free to correct. The following is what I think that is happening, but again, I am not 100% sure.
Topic: About the “magic” numbers 25 and 44 on the photovore_v1.h file.
A non-modified servo motor can move from a variety of positions from a full left to full right. The time (duration in milliseconds) of a high voltage signal applied to the motor is the factor that determines what is the new position that the servo-motor must go. Therefore it is not the level of the voltage itself, but for how long that voltage is applied to the servo-motor.
For our case, this time varies from 1 millisecond to 2 milliseconds for the full left to the full right positions. Providing 1.5 milliseconds will place the motor in the middle position.
The photovore_v1.h code operates in a variable based on the number of cycles (just an integer number) and not TIME. However, as a comment in the code states, we can correlate the variable "cycles" with "time" as follows
23/.992*(time in milliseconds) = number of cycles
Now let’s understand those 44 and 25 “magic” numbers.
For the MODIFIED servo-motor used for this robot, the 1.5 ms signal will make the motor to stop rotation (it will not go either forward nor backward), while any signal smaller than 1.5 ms will make the motor to run continuously to the left, and any signal longer that it will make the motor to run continuously to the right..
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).
If we give a lower cycle number, let’s say 25 (or about 10 cycles less), the motor will rotate in one direction. And if we give a higher number, let’s say 44 (or about 10 cycles more (remember the round-off that we needed to do for 34.8 above), then the servo motor will go in the other direction for about the same speed (but in the reverse direction) as the one provided by the 25 cycles.
Therefore that is the reason for the 25 and 44: they are 10 cycles for less or for more of the “neutral” (stop) position.
Now, let’s talk about why the number 25 and 44 are placed in that way in the code. I will discuss only the “go straight” else statement, since the others are easily understood if you understand this one.
//light is about equal on both sides
else
{
//go straight
servo_left(25);
servo_right(44);
}
Why the numbers are 25 for a motor and 44 for the other if they are running straight forward? It is due to the fact that we have mounted both motors in the robot chassis in reversed with relation to each other, i.e., to go straight forward one motor must go forward while the other must go backwards. That’s why the left servo is set to 25 (backward movement) while the other is set to 44 (forward movement). Both are 10 cycles apart from the middle (stop) position, providing this way the same speed and movement direction on both motors.
I hope this explanation can help someone that did not had figured out about those numbers before, like me a day ago!
Please make any comment on this as necessary. There will be no hard feelings, ahhhaahh
Paulo Brasko (Brazilian Greetings!)
Logged
ed1380
Supreme Robot
Helpful? 2
Offline
Posts: 1,475
Re: About the “magic” numbers 25 and 44 on the photovore_v1.h file
«
Reply #1 on:
December 30, 2007, 08:52:09 PM »
good post
Logged
Problems making the $50 robot circuit board?
click here.
http://www.societyofrobots.com/robotforum/index.php?topic=3292.msg25198#msg25198
Admin
Administrator
Supreme Robot
Helpful? 110
Offline
Posts: 9,833
Re: About the “magic” numbers 25 and 44 on the photovore_v1.h file
«
Reply #2 on:
December 30, 2007, 08:54:15 PM »
Wow ok this is 100% correct!
(I will link this to the tutorial right now for others to use)
Additions:
The exact numbers depend on various factors, including length of cycle time (determined by your specific microcontroller and timing crystal/settings). 25 and 44 are specific to the ATmega8 and ATmega168 running at 1Mhz (the default for the $50 robot tutorial).
The numbers also depend on your choice in servo type and brand and how you modified it.
By varying the number - say 22 or 27 instead of 25, you can slow down or speed up your servo. Servos make a different humming noise depending on the speed (because of the gears meshing at different frequencies).
There is another popular way to control servos instead of using cycles. This method involves using timer interrupts. The problem with this method is that it simply won't work if you have many servos (typically more than 4). Not a problem for the $50 robot, but definitely a problem for bipeds/hexapods/snake robots which have a dozen or so servos.
Logged
subscribe to SoR's YouTube account
silent069
Full Member
Helpful? 0
Offline
Posts: 49
Re: About the “magic” numbers 25 and 44 on the photovore_v1.h file
«
Reply #3 on:
July 08, 2008, 05:22:02 PM »
This topic is really helpful to understanding servos! very nice
Logged
pomprocker
Supreme Robot
Helpful? 15
Offline
Posts: 1,430
Sorry miss, I was giving myself an oil-job.
Re: About the “magic” numbers 25 and 44 on the photovore_v1.h file
«
Reply #4 on:
July 08, 2008, 06:16:24 PM »
A good place to start to find your own magic numbers would be to first find a stand still for your robot and then increment and decrement from there.
For example: I haven't had time to tweak these settings in my $50 robot code, so my robot always veers to the left.. never goes very straight.
Logged
Blog:
Nerd Stuff - Programming, Electronics, Mechanics
pulkitgulati
Beginner
Helpful? 0
Offline
Posts: 1
Re: About the “magic” numbers 25 and 44 on the photovore_v1.h file
«
Reply #5 on:
September 13, 2008, 05:20:34 AM »
Very useful to improve upon the understanding with the servos for future uses as well....
Thanks a lot!!!!
Logged
Metal Slug 2
Robot Overlord
Helpful? 4
Offline
Posts: 216
Re: About the “magic” numbers 25 and 44 on the photovore_v1.h file
«
Reply #6 on:
January 27, 2009, 01:00:17 AM »
Quote from: paulobrasko on December 30, 2007, 08:22:07 PM
Now, let’s talk about why the number 25 and 44 are placed in that way in the code. I will discuss only the “go straight” else statement, since the others are easily understood if you understand this one.
//light is about equal on both sides
else
{
//go straight
servo_left(25);
servo_right(44);
}
Why the numbers are 25 for a motor and 44 for the other if they are running straight forward? It is due to the fact that we have mounted both motors in the robot chassis in reversed with relation to each other, i.e., to go straight forward one motor must go forward while the other must go backwards.
aha! i get it now =), thanks...that puzzled me for the longest time.
Logged
RoBoTicS
Full Member
Helpful? 0
Offline
Posts: 80
Man is a robot with defects
Re: About the “magic” numbers 25 and 44 on the photovore_v1.h file
«
Reply #7 on:
January 27, 2009, 08:58:54 AM »
awesome thanks
Logged
Miles
Full Member
Helpful? 1
Offline
Posts: 49
Re: About the “magic” numbers 25 and 44 on the photovore_v1.h file
«
Reply #8 on:
January 27, 2009, 11:44:38 PM »
Hello, i understand why the servo's are set to 25 and 44 but was just wondering how you figured this bit out:
23/.992*(1.5) = 34.8 (let’s make an integer of 35).
Where did you get the 23/.992*(1.5) from?
Logged
Admin
Administrator
Supreme Robot
Helpful? 110
Offline
Posts: 9,833
Re: About the “magic” numbers 25 and 44 on the photovore_v1.h file
«
Reply #9 on:
February 13, 2009, 12:24:57 AM »
Quote from: Miles on January 27, 2009, 11:44:38 PM
Hello, i understand why the servo's are set to 25 and 44 but was just wondering how you figured this bit out:
23/.992*(1.5) = 34.8 (let’s make an integer of 35).
Where did you get the 23/.992*(1.5) from?
I used my oscilloscope to time it.
Logged
subscribe to SoR's YouTube account
Pages: [
1
]
Print
Jump to:
Please select a destination:
-----------------------------
General Misc
-----------------------------
=> Misc
=> Robot Videos
-----------------------------
Software
-----------------------------
=> Software
-----------------------------
Electronics
-----------------------------
=> Electronics
-----------------------------
Mechanics and Construction
-----------------------------
=> Mechanics and Construction
Related Topics
Subject
Started by
Replies
Views
Last post
About the values used in the DELAY_CYCLES command in the photovore_v1.h
Software
paulobrasko
2
1556
January 01, 2008, 11:31:53 AM
by
paulobrasko
Photovore_v1 error PLS HELP
Software
cyclopediatechtilon
1
797
December 27, 2008, 03:19:32 AM
by
Admin
help - "magic numbers"
Software
byuri
6
1112
January 30, 2009, 05:18:07 AM
by
byuri
Photovore_v1.c:108: fatal error: opening dependency file .dep/Photovore_v1.o.d:
Software
Becky
5
2126
May 10, 2009, 10:10:01 AM
by
LIONS*LEADER
Advertise on this Forum
Loading...