go away spammer

Author Topic: Servo Control: 74HC238 vs. 74595  (Read 2361 times)

0 Members and 1 Guest are viewing this topic.

Offline klimsTopic starter

  • Robot Overlord
  • ****
  • Posts: 190
  • Helpful? 2
Servo Control: 74HC238 vs. 74595
« on: May 29, 2012, 05:22:00 AM »
Hey guys,


I'm trying to design a servo control board for a project that will give me accurate control of up to 24 servos.
Ideally I would use 24 X 16 bit hardware PWM from a mircocontroller but as yet I haven't been able to find one.
I have tried using software PWM but I'm not happy with the accuracy as I was getting servo jitters. I have been hunting around on the net for a solution and this is what I have come up with:

OPTION 1.
74HC238 (demultiplexer) chip that allows a single 16bit PWM channel to be turned into 8. Webbot says in his docs that this method brings the accuracy of hardware PWM to many servos, but brings some overhead.

OPTION 2.
74595 (8 bit shift register) that people are using to control up to 32 servos (4 chips). I think this is what the Lynxmotion SCC-32 uses and I haven't heard many complaints about servo accuracy for these boards.


Has anyone tried both of these chips for servo control? I would appreciate feedback on the following criteria:
   a) which solution would put more load on the board
   b) which solution would give better accuracy


Thanks for your help!

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Servo Control: 74HC238 vs. 74595
« Reply #1 on: May 30, 2012, 04:42:41 PM »
Here are my thoughts - apologies for long comment.

Take the worse case of a servo needing, say, a 2.5ms pulse every 20ms.....it has to be every 20ms otherwise the servo goes 'floppy' - no torque.

The pulse length (2.5ms) is critical - any +/- deviation makes it jitter. ie flicking between 2.4ms and 2.6ms = jitter.

Why would anything be so in-exact as to cause this jitter? Well - if there is any 'software' involved in controlling the length of the pulse then that software can be interrupted via hardware interrupts (ie the uart needs attention, the I2C bus needs attention, the ADC converter needs attention etc etc). The more of these opportunities you introduce (by asking the same board to do lots of other things) increases the likelihood that this will happen.

Hardware PWM is great - as everything is happening in hardware and cannot be influenced by all the other things your program is doing and any interrupts they may cause. Its rock solid. But you need one timer for each servo - and that's the problem. You've probably only got 1, 2 or 3 timers available. So great for a two wheeled robot, say.

Software PWM is cheap but inaccurate. It uses one, ore more, timers to not only control the length of the pulse but also to control which output pin the pulse is sent to. The pulse length, and change of pin, is performed via interrupts. So if your board is handling all sorts of interrupts (I2C, UART, etc as above) then it gets in-exact. For example: if it is using timer interrupts to say when the '2.5ms' pulse has finished (so it can turn off the output pin) then this can be delayed slightly if the CPU is having to deal with other outstanding interrupts. This is partly a problem with the AVR chip architecture - some other chips allow you to prioritize the interrupts which in our case would mean that we could make sure the servo pulse interrupt is given highest priority - but on AVR you can't do this. However: software PWM is not a waste of time - if your servo are modified for continuous rotation, rather than angular position, then this momentary change in speed is not normally an issue - either due to momentum or coz you are using encoders to cope with all of the other differences (like the diameter of your wheels is not 100% identical).


Glitches/twitching - this ONLY happens if software is involved in getting the PWM signal to the pin - due to the problem of other interrupts happening concurrently as mentioned above. Of course if your board is only doing software PWM from one timer then there won't be any other interrupts. However: with WebbotLib it is sort of assumed that you also need a system clock for measuring time - and so there is always an interrupt for this. The only way for PWM which involves any software to be exact is if it disables ALL interrupts whilst generating the pulse. The problem here is it can mean killing off everything else whilst generating a single 2.5ms pulse for a single servo. Have 8 servos and it means 8*2.5=20ms ie kill the machine for 20ms - oh and we need to do it every 20ms - so the whole machine is dead. That ain't good if the same board is talking to other sensors.

So the only TRUE way of producing glitch free PWM is to either use hardware PWM (for a few servos); or to use some sort of software assisted PWM where the number of other 'non servo related' interrupts is kept to a minimum - ie a slave board or other extra hardware. The only other interrupts the slave board would need to re-act to is the comms from the host to say what speed/position to use for a given servo. Although this is still an interrupt - it is only one interrupt - and you don't tend to need to change positions very frequently so it doesn't happen very often in the scheme of things. That's why there are so many slave servo controller boards around.

Hybrid solutions. The 74HC238 solution in WebbotLib is a kinda compromise. It uses a single hardware PWM timer for generating the pulses (with all of its benefits) but then controls the 74HC238 via software to direct the 'pulse' to the appropriate output. So, as 'klims' says there is 'an overhead' but this is more in the pin switching than the pulse length. So it should be jitter free.

74HC238 vs 74595? Well since they both involve external hardware then they will both no doubt require software to be involved to help control that hardware. So they are both in the Hybrid category. Not "heard complaints about the SCC-32/74595" - well thats probably because it is a slave board. My comment about 'overhead' with the 74HC238 is when you have it connected to your master, Axon say, board along with everything else.

Since you are talking of creating a slave board then I would have thought that either route would work. The 74HC238 is dirt cheap (don't know about 74595) so you could knock it out on a breadboard for a few $.





« Last Edit: May 31, 2012, 01:21:53 PM by Webbot »
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 billhowl

  • Supreme Robot
  • *****
  • Posts: 376
  • Helpful? 32
  • Your success is in your hands.
Re: Servo Control: 74HC238 vs. 74595
« Reply #2 on: May 31, 2012, 04:37:50 AM »
You can control very large numbers of servos precisely using an external PWM chip. Each chip can control up to 16 servos and can be daisy-chained for more then 16 outputs. See PWM Expansion with TLC5940 for library code and examples in Arduino.

Offline klimsTopic starter

  • Robot Overlord
  • ****
  • Posts: 190
  • Helpful? 2
Re: Servo Control: 74HC238 vs. 74595
« Reply #3 on: May 31, 2012, 05:37:13 AM »
Thanks for the extended reply webbot. Very informative!  :)

I don't plan to use the board as purely slave device like the SCC-32. My plan was to use it as a motion controller, so it would be responsible for playing gaits as well as controlling servos. I was also hoping for some data acquisition, but based on your reply that might be a bit optimistic.

I take from what you're saying that in order to get accurate servo control as well as some sensor input and other functionality, a slave servo controller should be used. Maybe I can use the servo controller I have combined with an small microcontroller that is supported by webbotlib.


Thanks for the link billhowl. Definitely looks like something worth looking in to!

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Servo Control: 74HC238 vs. 74595
« Reply #4 on: May 31, 2012, 01:51:26 PM »
Yep - some sort of slave is good. billhowl has mentioned another (ie its a slave coz your off-loading the signal generation to something else).

Of course the ultimate is something like the Dynamixel servos (AX-12 onwards). These, effectively, have their own processor built into the servo. Give it a position/speed (at 1 million bits per second!) and it just gets on with it until it hears from you again. So each servo is effectively a slave. They are probably the best servos I've yet seen - allowing position control as well as continuous rotation - with loads of torque. The downside is that if you need more than one then you need to re-mortgage your house.

There is also some s/w and matching h/w standards called Open Servo (google it) that does a similar thing - ie cut the guts out of your current servo, insert their board, and off you go. Been around for a while but, unfortunately, not much up-take.
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: 190
  • Helpful? 2
Re: Servo Control: 74HC238 vs. 74595
« Reply #5 on: June 08, 2012, 06:30:40 AM »
Great suggestions guys.
Unfortunately I have already invested in decent rc servos. If I was spending my money again I would definitely have gone dynamixel.

It has only just occurred to me that I can reprogram an arduino board to use webbotlib, so I might try an arduino pro mini with the mini servo controller I have to get the package size I wafer after. If that fails the TLC5940 on a custom board sounds like a great option.

Cheers

 


Get Your Ad Here

data_list