Author Topic: Controlling servos -> Axon  (Read 8883 times)

0 Members and 1 Guest are viewing this topic.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Controlling servos -> Axon
« Reply #30 on: May 14, 2009, 10:18:00 AM »
Is it big twitches or little twitches? Does the servo at least move to the right spot before twitching?

Offline CanabotsTopic starter

  • Contest Winner
  • Robot Overlord
  • ****
  • Posts: 245
  • Helpful? 6
  • It's not a bug, it's a feature!
    • Salmigondis Tech
Re: Controlling servos -> Axon
« Reply #31 on: May 14, 2009, 02:18:56 PM »
The servos will turn to their first specified point (for servo1, it's all the way to the left, and servo2 is all the way to the right). After this, the twitches are about 2-3* to the right and left.

To me, it looks like the program is not going to the second command. I think I'll try shortening the FOR loops, perhaps they are too large...
My robotics, electronics, software, or other stuff blog:
www.saltech.wordpress.com

Offline CanabotsTopic starter

  • Contest Winner
  • Robot Overlord
  • ****
  • Posts: 245
  • Helpful? 6
  • It's not a bug, it's a feature!
    • Salmigondis Tech
Re: Controlling servos -> Axon
« Reply #32 on: May 14, 2009, 02:46:38 PM »
Haha! I made it work (sort of).

I decided to try it by putting a plain old FOR loop in void control(void) itself like this:

Code: [Select]
void control(void)
{
while(1)
{
for(i=0;i<40;i++)
{
servo1(1);
servo2(2);
delay_ms(20);
}
for(i=0;i<40;i++)
{
servo1(2);
servo2(1);
delay_ms(20);
}
}
}

This moved the servos just how I wanted it.

When I tried putting these loops in subroutines, I got the same twitching result as the post above.

This brings up an issue though, why can't I make it work in a subroutine? This needs to be in a subroutine as I don't want to have to program a walk gait every time it pops up when I start my quadruped. Same with the robot arm I'm currently building.

Thanks for your help Admin! ;D
My robotics, electronics, software, or other stuff blog:
www.saltech.wordpress.com

Offline CanabotsTopic starter

  • Contest Winner
  • Robot Overlord
  • ****
  • Posts: 245
  • Helpful? 6
  • It's not a bug, it's a feature!
    • Salmigondis Tech
Re: Controlling servos -> Axon
« Reply #33 on: May 17, 2009, 12:26:50 PM »
So, does anyone know why my code doesn't work if it's put in a subroutine?

If I were to put it in a subroutine, it would be like this:
Code: [Select]
void test(void)
{

for(i=0;i<40;i++)
{
servo1(1);
servo2(2);
delay_ms(20);
}
for(i=0;i<40;i++)
{
servo1(2);
servo2(1);
delay_ms(20);
}
}

But on the Axon, it won't work :(...Any ideas?
My robotics, electronics, software, or other stuff blog:
www.saltech.wordpress.com

Offline CanabotsTopic starter

  • Contest Winner
  • Robot Overlord
  • ****
  • Posts: 245
  • Helpful? 6
  • It's not a bug, it's a feature!
    • Salmigondis Tech
Re: Controlling servos -> Axon
« Reply #34 on: May 20, 2009, 05:43:10 AM »
...I don't mean to be pushy, but does anyone have any ideas for this?
My robotics, electronics, software, or other stuff blog:
www.saltech.wordpress.com

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Controlling servos -> Axon
« Reply #35 on: May 20, 2009, 11:12:29 AM »
Here our some 'off the top of my head' thoughts...

1. Your subroutine uses the variable 'i'. IMHO it ought to be defined as a local variable in the the 'test' routine - just in case its upsetting the global variable which may(?) be used elsewhere in your main. - ie the 'test' function may be ok but now you are trashing something else in main.

2. Are you compiling with all optimizations disabled - just in case the compiler is trashing your code.
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 CanabotsTopic starter

  • Contest Winner
  • Robot Overlord
  • ****
  • Posts: 245
  • Helpful? 6
  • It's not a bug, it's a feature!
    • Salmigondis Tech
Re: Controlling servos -> Axon
« Reply #36 on: May 20, 2009, 03:21:42 PM »
Awesome! it works now! Thanks Webbot!  ;D
My robotics, electronics, software, or other stuff blog:
www.saltech.wordpress.com

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Controlling servos -> Axon
« Reply #37 on: May 27, 2009, 06:41:39 AM »
lol yea I always keep optimizations off. Axon memory is ginormous, so no need to optimize for memory.

As for optimizing for speed, unless you have some crazy intensive algorithm (lots of trig, SLAM, vision, etc), you don't need that either.

 


Get Your Ad Here

data_list