Author Topic: Axon MCU with servoes  (Read 838 times)

0 Members and 1 Guest are viewing this topic.

Offline UnicornKingTopic starter

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Axon MCU with servoes
« on: October 16, 2009, 11:56:24 PM »
i'm starting to build robots fresh meaning this is my first time. I was trying to get a servo to center with

wheel_left(700);
delay_ms(20);

i deleted everything in control.c from the method (or function depending on your programing language) photovore() and placed that 2 line of code. whenever run the program the servo only moves a fraction of a degree b4 stopping. if i keep running the program the servo will keep moving until it hits center then it stops. it does this from both sides reaching the same center. i dont know what i'm doing wrong can someone inform me help me with some troubleshoots?

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,150
  • Helpful? 109
Re: Axon MCU with servoes
« Reply #1 on: October 17, 2009, 12:22:43 PM »
When you send the servo a command eg via 'wheel_left' then it knows where it needs to move to and where it currently is and so starts to move. But you need to do repeatedly - ie keep telling the servo where to move to.
You say 'if i keep running the program' - which sounds bad. Embedded programs shouldn't finish - there should be an infinite loop somewhere.
So as a simple case have you tried wrarpping your code in a while(1) ie do the following forever such as:-
Code: [Select]
while(1){
wheel_left(700);
delay_ms(20);
}
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline UnicornKingTopic starter

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Re: Axon MCU with servoes
« Reply #2 on: October 17, 2009, 01:31:24 PM »
ah thank-you for the clarity and yes i have tried but your logic sounds very reasonable so it maybe that my infinite loop was incorrect so i will try to get it to work using the loop.

Offline UnicornKingTopic starter

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Re: Axon MCU with servoes
« Reply #3 on: October 17, 2009, 04:14:17 PM »
oh i fixed my problem i deleted too much of the original program so when i added all the propramed goodies my small script worked

but now i have another question. how would i go about programming logic to make the servo go back to center every time i physically move the servo myself without rerunning the code.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,659
  • Helpful? 169
    • Society of Robots
Re: Axon MCU with servoes
« Reply #4 on: October 18, 2009, 08:31:24 AM »
Quote
how would i go about programming logic to make the servo go back to center every time i physically move the servo myself without rerunning the code.
You would need to add a sensor to the wheel so that the Axon knows the servo isn't centered.

 


Get Your Ad Here

data_list