Author Topic: $50 robot...Code related basic question!  (Read 2333 times)

0 Members and 1 Guest are viewing this topic.

Offline rmoreTopic starter

  • Jr. Member
  • **
  • Posts: 15
  • Helpful? 0
$50 robot...Code related basic question!
« on: July 10, 2012, 01:19:39 PM »
Hello All!

This is my first post in here! I am building the $50 robot and it has been a lot of fun so far. I learnt a great deal just by going thru the forum and looking at what problems other people faced while building this robot.

Thank you for this forum. You guys are a great help.

I have a basic question regarding the code. I do not understand how the numbers '44' and '25' were arrived at. Like the numbers in servo_left(44), servo_right(25).

What is the significance of these numbers? Why not use - say 45 and 24 instead? I probably am missing something very simple....but nevertheless please try to answer my question.

Thanks.

Rmore

Offline adanvasco

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 6
  • Necessity is the mother of invention.
Knowledge does not weigh.

Offline rmoreTopic starter

  • Jr. Member
  • **
  • Posts: 15
  • Helpful? 0
Re: $50 robot...Code related basic question!
« Reply #2 on: July 12, 2012, 09:45:38 PM »
Adanvasco,

Thank you for pointing me into the right direction. I now understand the 'magic' numbers.

I did not understand one thing that Admin said though -

     By varying the number - say 22 or 27 instead of 25, you can slow down or speed up your servo.

How is this possible? Isnt the servo supposed to rotate at a constant speed always?

Thanks.

Rmore

Offline ErikY

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: $50 robot...Code related basic question!
« Reply #3 on: July 13, 2012, 04:25:13 AM »
Adanvasco,

Thank you for pointing me into the right direction. I now understand the 'magic' numbers.

I did not understand one thing that Admin said though -

     By varying the number - say 22 or 27 instead of 25, you can slow down or speed up your servo.

How is this possible? Isnt the servo supposed to rotate at a constant speed always?

Thanks.

Rmore

Admin wrote in his tutorial that by modifying a servo, you lose the ability to control angle position but gain the ability to control servo speed.

Offline rmoreTopic starter

  • Jr. Member
  • **
  • Posts: 15
  • Helpful? 0
Re: $50 robot...Code related basic question!
« Reply #4 on: July 13, 2012, 10:29:21 AM »
Yes, but how exactly does using '22' slow down a servo and '27' increase the speed of the servo?
As far as I understand, we are using two functions - delay_cycles and servo_left/right

Input to 'servo_left' function is speed - say 22.

And this speed (22) is then the input for delay_cycles. So the port is ON for that much of time. (time taken to execute delay_cycles(22).

In next case, the port would be ON for time taken to execute delay_cycles(27).

So the time the port is ON varies in both cases. How does that time variance correspond to different speeds?
I would think its just the servo that is operating for different time intervals (but at same speed).

I am just not getting this.

Please help me understand this concept.

Thanks.

Rmore

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: $50 robot...Code related basic question!
« Reply #5 on: July 15, 2012, 08:10:22 AM »
How is this possible? Isnt the servo supposed to rotate at a constant speed always?
Servo does not rotate at constant speed. The further away destination angle is from current angle, the faster servo will rotate. So, if current angle is 0° and destination angle is 2° then servo will rotate slower than if current angle is 0° and destination angle is 15°. By modifying servo and gluing pot at 0° You can vary servo speed instead of destination angle. Does that make sense?
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline rmoreTopic starter

  • Jr. Member
  • **
  • Posts: 15
  • Helpful? 0
Re: $50 robot...Code related basic question!
« Reply #6 on: July 15, 2012, 09:16:17 AM »
New In Robotics,

Thank you. Now I do get it. So by modifying the servo, you gain control over servo speed but lose control over servo positioning.

Thanks.

Rmore