Author Topic: Axon servo control inaccuracy: need servo controller?  (Read 3677 times)

0 Members and 1 Guest are viewing this topic.

Offline klimsTopic starter

  • Robot Overlord
  • ****
  • Posts: 187
  • Helpful? 2
Axon servo control inaccuracy: need servo controller?
« on: June 07, 2010, 04:54:42 AM »
Hey guys,

I have an Axon running my 16DOF biped and I'm just not happy with the accuracy of the servo control I get using the Axon. Correct me if I'm wrong, but I think this is a result of the 5% error in the frequency.
Is there any way of making this more accurate?

I don't think there is, so I have been doing some research on servo controllers. May as well get some dedicated hardware that control my servos reliably no matter what controller I use.
Do you guys have any suggestions? I was thinking I might daisy chain a few of the Pololu micro serial controllers
http://www.robotshop.ca/pololu-micro-serial-servo-controller.html


Thanks for your input,
Andrew

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,121
  • Helpful? 108
Re: Axon servo control inaccuracy: need servo controller?
« Reply #1 on: June 07, 2010, 06:29:49 PM »
Hi Andrew

First of all its probably worth saying that its not a problem caused by the Axon. The  Axon is NOT a dedicated servo controller - its a 'brain' - which can also be used to drive servos whilst doing other things. So what you have got is a software problem - ie your code cant control your 16 servos correctly and this may be because it is doing a million other things.

First off: if you use my WebbotLib library (http://webbot.org.uk) then some users have used it to control around 24 servos in the background whilst doing other stuff- so it could be useful to you.

Second: it also supports (a range of) Servo Controller boards. So your code just says 'Set servo X to position Y' and WebbotLib will do what is required - ie talk over UART, I2C, SPI or whatever the servo board expects. Swap from one board to another and your code barely changes.

--- End of Advert! ---

The other board you may want to consider is the Devantech SD-21 which supports up to 21 servos and is already used by WebbotLib users.

But if  you go with the Pololu product and like WebbotLib then I'd be happy to make sure it is supported.



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 Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,632
  • Helpful? 169
    • Society of Robots
Re: Axon servo control inaccuracy: need servo controller?
« Reply #2 on: June 07, 2010, 07:23:11 PM »
klims, you won't get any better accuracy than with a hardware PWM pin - even on a dedicated servo controller (as they all use hardware PWM just like the Axon). I haven't compared WebbotLib software PWM to hardware PWM wrt servo accuracy, but I doubt it'll be that different.

Servos themselves are fairly inaccurate. What servo type(s) are you using?

Offline klimsTopic starter

  • Robot Overlord
  • ****
  • Posts: 187
  • Helpful? 2
Re: Axon servo control inaccuracy: need servo controller?
« Reply #3 on: June 09, 2010, 07:05:01 PM »
What happens is I output a pose to my robot, then a short time later I output exactly the same pose and I get the robot jittering. I can see that the servo position has changed.
I am using the HS5646MG digital servos.

I think this is because the servo command on the Axon does not continually output the PWM signal, rather it just outputs it once telling the servo to go to a position.

Webbot: I don't exactly understand how your lib works. Does it need to be run by the computer? Or can it make code for the Axon? I'm referring specifically to the gait generator.


Am I right in understanding that the only way I will get true PWM with good accuracy would be to use as servo controller as it has dedicated hardware PWM?

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,632
  • Helpful? 169
    • Society of Robots
Re: Axon servo control inaccuracy: need servo controller?
« Reply #4 on: June 09, 2010, 07:26:42 PM »
Quote
Am I right in understanding that the only way I will get true PWM with good accuracy would be to use as servo controller as it has dedicated hardware PWM?

Both the Axon and all servo controllers use a microcontroller with PWM to control servos. Hardware PWM pins will always work equally as well on both.

Are you using hardware or software based PWM?

Offline klimsTopic starter

  • Robot Overlord
  • ****
  • Posts: 187
  • Helpful? 2
Re: Axon servo control inaccuracy: need servo controller?
« Reply #5 on: June 09, 2010, 07:49:31 PM »
Good question... I'm not 100% sure.
I have been using the standard 'servo' command on the Axon. I don't really know what that does.
My guess would be software PWM only because I can't control analog servos using the command, which I think would mean that I'm only getting a single pulse being sent down the line.

I know the Axon can control a lot of servos, but they can't all be controlled via hardware PWM can they? I seem to remember reading somewhere that there were only a few 10 bit and a few 8 bit available.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,121
  • Helpful? 108
Re: Axon servo control inaccuracy: need servo controller?
« Reply #6 on: June 09, 2010, 07:50:22 PM »
Hi Klims

From what you say you are using Gait Designer (on a pc say) and this is sending commands, via USART/USB, to your mcu to control the servos?
Correct assumption?

If so this means you are using the Gait Designer receiver code on the robot. ie the PC generates the servo positions and sends them to the robot and the robot code generates the PWM continuously. It will do this either via hardware or software depending on your code (PM the code and I'll let you know). Either way the PWM is generated in the background, under interrupts, and has certainly been proved for up to about 24 servos (http://www.societyofrobots.com/robotforum/index.php?topic=11333.0)
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 klimsTopic starter

  • Robot Overlord
  • ****
  • Posts: 187
  • Helpful? 2
Re: Axon servo control inaccuracy: need servo controller?
« Reply #7 on: June 09, 2010, 08:02:24 PM »
Sorry for the confusion. I will try explain my situation again.

I currently have a 16DOF biped that I have programmed using the Axon and only the Axon.
I am unhappy with the repeatability of asking a servo to go to a position, which I have tested by asking a robot to go to the same position over and over again. I want to fix this problem before I continue my development.

I am trying to find a fix for getting 16+ servos working accurately. I don't care whether this is a software fix or a hardware fix.


Does that make sense?

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,632
  • Helpful? 169
    • Society of Robots
Re: Axon servo control inaccuracy: need servo controller?
« Reply #8 on: June 09, 2010, 08:05:45 PM »
Quote
I know the Axon can control a lot of servos, but they can't all be controlled via hardware PWM can they? I seem to remember reading somewhere that there were only a few 10 bit and a few 8 bit available.

The original Axon has 7 hardware PWM pins, the Axon II has 15.

Look at this chart here:
http://www.societyofrobots.com/axon2/images/640pinout.gif

Hardware PWM pins have OSC written next to it. Its always best to use hardware PWM first.

Quote
I am unhappy with the repeatability of asking a servo to go to a position

What is the exact angle error you are getting? (measure the error both with and without anything mechanically connected to the servo)

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,121
  • Helpful? 108
Re: Axon servo control inaccuracy: need servo controller?
« Reply #9 on: June 09, 2010, 08:31:28 PM »
Hi Klims

Having re-read your posts then I'm not sure I understand how you are controlling the servos as of now.

You could be using WebbotLib, AVRlib or Admins original lib for the Axon (pre WebbotLib), or something else
So when you say

Code: [Select]
... biped that I have programmed using the Axon and only the Axon.

it doesn't actually mean a whole deal as there is no 'one way' to program any controller.

'Axon' is hardware and could be programmed in a million and one different ways - using a million and one different libraries.

What we dont know is how you are doing it.


If you are using WebbotLib then I'm rather confused as each servo has a background/interrupt routine to set its position every 20ms. Since this is happening in the background you can even have a ridiculous foreground routine like:-
while(1){
  .. do nothing ..
}
that just repeats forever and the servo functions will still continue to work.
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 klimsTopic starter

  • Robot Overlord
  • ****
  • Posts: 187
  • Helpful? 2
Re: Axon servo control inaccuracy: need servo controller?
« Reply #10 on: June 09, 2010, 09:39:09 PM »
You could be using WebbotLib, AVRlib or Admins original lib for the Axon (pre WebbotLib), or something else
So when you say
Code: [Select]
... biped that I have programmed using the Axon and only the Axon.
it doesn't actually mean a whole deal as there is no 'one way' to program any controller.

Sorry, that was silly of me. What I meant was that I am programming the Axon with Admin's original libs that came out when I bought the Axon a couple of years ago now.


If you are using WebbotLib then I'm rather confused as each servo has a background/interrupt routine to set its position every 20ms.

Ahhhh I think I see where I was getting confused.
I had actually wondered about whether this was possible a while back. I'm glad someone has done it for us!  ;D thanks.


What is the exact angle error you are getting? (measure the error both with and without anything mechanically connected to the servo)
I'd say about 1deg at worst. Just enough to be a pain in the neck with the hardware connected.


Thanks for the input guys.
I will try the webbot libs for the Axon and see if I get any better results and report back.

Andrew

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,632
  • Helpful? 169
    • Society of Robots
Re: Axon servo control inaccuracy: need servo controller?
« Reply #11 on: June 10, 2010, 04:56:07 AM »
Yea, I definitely recommend moving to WebbotLib. I stopped updating my own [inferior] library ages ago.

Quote
I'd say about 1deg at worst. Just enough to be a pain in the neck with the hardware connected.
Oh, you aren't going to get better than this. Servo gear backlash alone would give no less than 1 deg error . . . the jittering could be from force being applied to the servo causing it to bounce between encoder positions.

Offline klimsTopic starter

  • Robot Overlord
  • ****
  • Posts: 187
  • Helpful? 2
Re: Axon servo control inaccuracy: need servo controller?
« Reply #12 on: June 10, 2010, 06:24:06 AM »
Oh, you aren't going to get better than this. Servo gear backlash alone would give no less than 1 deg error . . . the jittering could be from force being applied to the servo causing it to bounce between encoder positions.

Nah nothing like that, or at least very unlikely.
I think I have a video around somewhere that shows it well. I'll try upload this weekend when I finally get back into this project  ;D

Offline klimsTopic starter

  • Robot Overlord
  • ****
  • Posts: 187
  • Helpful? 2
Re: Axon servo control inaccuracy: need servo controller?
« Reply #13 on: June 12, 2010, 10:23:55 PM »
This is what I am finding unbearable.

SoR lib servo control


what you are seeing is my robots 'home' position being sent out every .5 seconds. Notice how it jitters and makes noises every time it refreshes.

I'm going to try and get webbotlib's running and see if it makes a difference.
« Last Edit: June 12, 2010, 10:28:28 PM by klims »

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,121
  • Helpful? 108
Re: Axon servo control inaccuracy: need servo controller?
« Reply #14 on: June 13, 2010, 01:35:38 PM »
What you are seeing is caused by the original Axon SoR library which tried to emit servo pulses in the foreground. The frequency at which a servo receives a pulse is down to you and is subject to all sorts of other things. Unless finely tuned each time you change your code then your servos can be very loose/floppy - and that may be what you are seeing ie the knee moves to the correct place, then sags under the weight of the robot, then moves to the correct position again etc etc etc. So it appears to be juddering.

You should use WebbotLib as it gets rid of all these servo problems and you may also be interested in the Gait Designer program (see my web site) as it allows you to set up all the key frames in a humanoid animation sequence and allows you to run any given animation to produce all the 'in between' frames. The standalone part to allow you to do this when not connected to a PC is still active work in progress but is high up on my list.

Feel free to PM me if you need help to get anything going
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 klimsTopic starter

  • Robot Overlord
  • ****
  • Posts: 187
  • Helpful? 2
Re: Axon servo control inaccuracy: need servo controller?
« Reply #15 on: June 13, 2010, 06:01:26 PM »
Unless finely tuned each time you change your code then your servos can be very loose/floppy - and that may be what you are seeing ie the knee moves to the correct place, then sags under the weight of the robot, then moves to the correct position again etc etc etc. So it appears to be juddering.
this was exactly my initial problem, but I bought digital servos to fix. So now what I think is happening is that every .5s when the same set of positions are sent out the pulse varies slightly (for reasons that are over me head). I think this is why sometimes there are bigger jolts than other times. 

I am definitely in the process of trying to get the webbotlib working. I'm making it hard for myself by not using the AVR toolkit either... I hate programming with it.
Hopefully webbotlib gets me sorted and robotting again.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,121
  • Helpful? 108
Re: Axon servo control inaccuracy: need servo controller?
« Reply #16 on: June 13, 2010, 07:14:32 PM »
If your only sending out pulses to the servos every half a second then thats probably where your problem lies. It needs to be more like every 20ms. WebbotLib does this for you under interrupts (like a servo controller board).

If its AVR Studio that you dont like then try Eclipse. Its bigger (as its generic - ie can be used for Java, J2EE, Web Development etc as well) and lots of features but its harder to set up.  See http://www.societyofrobots.com/member_tutorials/node/380
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 TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,207
  • Helpful? 15
  • 1.6L Peugeot 307 tuner
Re: Axon servo control inaccuracy: need servo controller?
« Reply #17 on: June 14, 2010, 05:31:28 AM »
So many servos actually need an RTS... a.k.a. Real Time System....

Do you know how to make an RTS? It only needs one timer... preferably 16bit...
And you could PWM many channels... and I mean many many channels....

Truth be told, I have no idea how webbot lib works... I tend to reinvent the wheel...
Time consuming... only at the beginning...
For whom the interrupts toll...


P.S. I've been inactive for almost a year... Don't give promises but I'll try to complete my tutorials. I'll let you know when..

Cheers!

Offline klimsTopic starter

  • Robot Overlord
  • ****
  • Posts: 187
  • Helpful? 2
Re: Axon servo control inaccuracy: need servo controller?
« Reply #18 on: May 06, 2011, 03:31:46 AM »
Hey guys,

Got a few more questions I'm hoping someone can help me with.

I bought the Pololu serial servo controller and it works great. It uses the PIC18F4550 and manages to control 24 servos perfectly with no jitters whatsoever. It/me are not up to the application I want a servo controller for though, so I want to build my own servo controller based on the ATmega and webbotlib.

I have tried to control my robot servos using the Axon I (ATmega640) and webbotlib and while the results are better than that in the video using the SoR library, I can still see and hear the servos jittering slightly. My question is how can I be sure what is causing this exactly? The PIC was able to control the servos perfectly with no jitters so I'm guessing that it is definitely possible to do it with software PWM. So are the jitters likely coming from crystal inaccuracy? Or is it likely from webbotlib??? How can I test?


thanks for your input guys.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,121
  • Helpful? 108
Re: Axon servo control inaccuracy: need servo controller?
« Reply #19 on: May 06, 2011, 08:14:41 AM »
The jitters are most probably caused by other interrupts being called that change the pulse width fractionally here and there. These interrupts could come from the clock timer, uarts and any another other hardware you may have.

Dedicated servo controllers can get round this problem as they can run with all interrupts disabled to get exact timings. Since they spend a lot of their time pausing between turning pulses on and off then they can poll the uart receive port for any commands rather than using interrupts.

WebbotLib Version 2 now generates an optimised code file for the software uarts so that they are less affected than with Version 1 - but will still not be as good as a dedicated servo controller.
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 KurtEck

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 12
Re: Axon servo control inaccuracy: need servo controller?
« Reply #20 on: May 06, 2011, 08:55:57 AM »
I agree with webbot here, that dedicated servo controllers have the advantage that they can be optimized to do that one task very well.  Also many of them, such as the Lynxmotion SSC-32 have other hardware added to them to make it easier for the main processor on the board (SSC-32 uses Atmega 168).  Likewise the Basic Micro board Arc-32 (based on Renesas H6/3687) which is a general purpose processor has added additional hardware (Analog Muxs) to make it easier to drive the servos.

Also many of these controllers have additional support for controlling your servos.  For example on a hexapod, you may wish to move all 18 (3dof) or 24 (4dof) servos from their current location (pulse width) to a new location in some amount of time.  For example suppose you wish to move servo 1 from lets say 1500us to 1600us in lets say 100ms.  To do this smoothly assuming a 20ms servo refresh rate, that you have 5 pulses in that 100ms time frame so you would hope that the pulses during that time frame would be: (1520, 1540, 1560, 1580 and 1600).  Many of these controllers have this support built in.  Note: Some other systems have this built into their software instead (example Basic Micro with their basic).

Also I am not sure if this is coming into play here with your servos, but the resolution of webbotlib is not as accurate as the standalone controllers.  That is you only have 256 values.  If you choose the range of 750-2250us, that implies that each increment is about 5.86us.  I have heard the argument that most servos don't have any better resolution than that anyway, but I have also heard others say that the resolution of some digital servos with 1024 values is not sufficient.  Who is right?  I don't know.

Kurt

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,632
  • Helpful? 169
    • Society of Robots
Re: Axon servo control inaccuracy: need servo controller?
« Reply #21 on: May 06, 2011, 09:09:04 AM »
Also I am not sure if this is coming into play here with your servos, but the resolution of webbotlib is not as accurate as the standalone controllers.  That is you only have 256 values.  If you choose the range of 750-2250us, that implies that each increment is about 5.86us.  I have heard the argument that most servos don't have any better resolution than that anyway, but I have also heard others say that the resolution of some digital servos with 1024 values is not sufficient.  Who is right?  I don't know.
I haven't checked for the $150+ digital servos, but for all others you won't get an accuracy much above a resolution of 90 values. The HS-311 servo, if I remember right, has about 60 values. This comes out to be an accuracy of < 3 degrees, which for most purposes is good enough . . .

Offline KurtEck

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 12
Re: Axon servo control inaccuracy: need servo controller?
« Reply #22 on: May 06, 2011, 10:01:51 AM »
Thanks Admin,

As I have said, I have heard both arguments. For my biped using HS-475... I knew it did not mater much, but I was using hardware servos for this.  But I also know that when I was writing my own C library for the Renesas H8 processors (Basic Atom Pro chips), that at times I would see some jitter if my pulses would vary a little, that is for example if my pulses were something like: 1450 1452 1448 1450... and my target was 1450 they are all accurate to 2us but the servo may jitter, note: It has been awhile since I worked on this so it may have been a slightly larger delta...   So it may very well be the consistency of the signal is more important than the resolution of it.  But for those who think it matters, it might be nice if you could configure webbotlib for high resolution. (Yes I know that would eat up more of the data space.

I forgot to mention in my previous post that for my Brat code running on the Axon2 with Webbotlib, I did write a scheduler function to update the servo positions as part of a timed group move.  It worked OK, but as it was independent of the actual servo code and when the servo positions were updated depends on the how the scheduler worked, it probably does not work as smoothly as if it was actually built into the servo system. But again it worked well enough for the Brat with canned sequences for things.

Kurt

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,632
  • Helpful? 169
    • Society of Robots
Re: Axon servo control inaccuracy: need servo controller?
« Reply #23 on: May 06, 2011, 10:52:21 AM »
at times I would see some jitter if my pulses would vary a little, that is for example if my pulses were something like: 1450 1452 1448 1450... and my target was 1450 they are all accurate to 2us but the servo may jitter, note: It has been awhile since I worked on this so it may have been a slightly larger delta...   So it may very well be the consistency of the signal is more important than the resolution of it.  But for those who think it matters, it might be nice if you could configure webbotlib for high resolution. (Yes I know that would eat up more of the data space.
Ah! I misunderstood what you meant. In this case, you could be right . . .

Webbot, since the servos already require 16bit timers, going from 8 bit to 16 bit variables for servos shouldn't take up that much memory. I guess this would require the system clock to be 16 bit? Whats your thoughts? KurtEck/klims are willing guinea pigs.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,121
  • Helpful? 108
Re: Axon servo control inaccuracy: need servo controller?
« Reply #24 on: May 06, 2011, 03:52:07 PM »
Webbot, since the servos already require 16bit timers, going from 8 bit to 16 bit variables for servos shouldn't take up that much memory. I guess this would require the system clock to be 16 bit? Whats your thoughts? KurtEck/klims are willing guinea pigs.
The system clock is just that - the system clock. It has no impact on servos.
Changing the servo speed from 8 bit to 16 bit would not be too hard (except that any existing programs people have written may need to be changed). But I'm not convinced that it will get rid of the jitter !

My view is that someone may be setting a constant speed and lets say that it equates to a pulse of 1450 microseconds, If the speed ever changes then it should always be 1450 microseconds. But whilst producing the pulse there may be other interrupts that kick in (say a char is received on the uart etc) and so the interrupt service routine extends the pulse to say 1454 microseconds. But since the other interrupts may or may not happen at ANY time then they MAY or MAY NOT adjust the pulse length. ie you may get values that are 1450 microseconds +- x%. Its impossible to say what 'x%' actually is - as it may be code that the end user has written in a callback.

So the jitter problem is not to do with whether its 8 bit or 16 bit - its to do with having a processor that is not just dedicated to driving servos.

Where the 8 bit vs 16 bit thing is important is if a servo has more than 255 discrete positions - regadrless of any jitter


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 Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,632
  • Helpful? 169
    • Society of Robots
Re: Axon servo control inaccuracy: need servo controller?
« Reply #25 on: May 06, 2011, 04:01:40 PM »
hmmmm Webbot, I think you're right. Resolution doesn't matter if other interrupts arrive just before the servo should get another pulse. 8 bit is fine, ignore my last post :P

Offline klimsTopic starter

  • Robot Overlord
  • ****
  • Posts: 187
  • Helpful? 2
Re: Axon servo control inaccuracy: need servo controller?
« Reply #26 on: May 09, 2011, 04:04:39 AM »
Thanks guys.

So what I'm reading is that while webbotlib can control my servos it can't control it accurately enough to prevent jitters.

Is there any way I can make webbotlib, or any other library for that matter, work well as a servo controller? Any suggestions would be appreciated. I really don't want to have to use Pololu's scripting language if I don't have to. All my stuff already works with webbotlib.

Offline rbtying

  • Supreme Robot
  • *****
  • Posts: 452
  • Helpful? 31
Re: Axon servo control inaccuracy: need servo controller?
« Reply #27 on: May 09, 2011, 07:23:33 AM »
You could just connect the Pololu controller to the Axon via USART, thereby gaining both advantages.  And the more accurate statement is that Webbotlib can control servos without jitter, just not while actually trying to do something else.

Offline KurtEck

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 12
Re: Axon servo control inaccuracy: need servo controller?
« Reply #28 on: May 09, 2011, 07:31:35 AM »
Webbot is obviously the best one to answer this.  As he mentioned in a previous post, the problem is probably caused by interrupts that happen at the wrong time (i.e. when the processor needs to change a  servo value from low to high or high to low...).  Another thing that can cause the problem is if interrupts are disabled when a servo interrupt needs to happen.  For example, I have seen interrupts disabled in Arduino Software Serial library when it is outputting a character, this could cause havoc for your servos. 

Webbot mentioned that many servo controllers do it, by being dedicated to processing the servos.   The question is could webbotlib be tailored for this.

My guess is it may be doable in a limited way.  That is if the your program does not use any serial input or output or if the serial IO drivers could be changed to be polled instead of interrupt driven and maybe automatically polled as part of the servo code... Likewise if the functionality of the System clock could be taken over by a servo timer, or if the overflow of the system timer could be taken care of by one of the servo interrupts...

I have also heard of some other people have attempted to make more accurate interrupt handling code for very specific things.  The basics of it is if your code needs to change the state of a pin in lets say 1500us you don't set the interrupt for 1500 instead you set it for maybe 1495 and in your interrupt handler you spin until exactly 1500 and make the change. This type of code may work OK for one individual interrupt, especially if you can keep the spin time to a minimum, but I don't think this is feasible for a servo system where you get lots of interrupts...

I have not studied the webbotlib code for servos, so I don't know how difficult these types of change would be, or if it is at all doable.

As rbtyping said, is to use a servo controller like the Pololu (or SSC-32), is the easiest solution.

Kurt

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,121
  • Helpful? 108
Re: Axon servo control inaccuracy: need servo controller?
« Reply #29 on: May 09, 2011, 01:35:40 PM »
Big subject - and no quick 'yes/no' answer.
It really comes down to trying to put a gallon into a pint pot - can WebbotLib control tens of servos, motor controllers, GPS, etc etc as well as the core logic of your program all at the same time? Well - yes it can. But your controller can 'squeak at the seams' - not a limitation of WebbotLib - just a limit as to how much you can ask a single cpu to do at the same time.

Software emulation of anything tends to be resource hungry (ie ties up the processor) whether it be servo software PWM, software Uarts etc.

Using hardware PWM would be much more precise and unaffected by jitters but you are limited to the number of timers on your cpu: plus the Axon reserves, or has no headers for, a number of the channels. The Axon II is better.

So the best compromise is for WebbotLib to delegate the generation of exact servo pulses to a slave servo controller. And the library supports a number of them.ie WebbotLib can say 'generate 1450us pulse on servo5' via the uart and then not worry about it as the slave controller only has this job to do. Freeing the Axon to do all the other stuff.

Can you turn an Axon/AxonII into a slave servo controller with WebbotLib? Not easily - as WebbotLib is meant to be at the 'master' end of things. I'm sure I could produce a Hex file to do it - but it begs the questions as to why you would use a $100 controller to control servos when you can buy dedicated servo controllers for a fraction of the price.

@klims - I know you've invested time in the gait design/runtime. But you can still use a Devantech SD21 controller, for example, to control the servos from within your Axon code by only changing a handful of lines of 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

 


Get Your Ad Here

data_list