PDA

View Full Version : [Interesting] Hack servo v3.00 - Get full PID position and speed control from your hobby servo



Antonb
04-01-2010, 09:22 AM
Yes we like servo mods!


http://www.youtube.com/watch?v=8jajnIBX2cU

As promished this is the third servo hack. This builts upon the second hack - 'add 10-bit abolute/incremental feedback encoder to
your hobby servo' . Source code is open and links provided at the end of the post. Eagle schematics are also provided.
In terms of the board files... well dont be lazy! After all all three boards are two-sided and fairly easy to design once you have a look at the schematics. Here I explain more or less how you would make it yourself, the components needed, some well-thought tips and how to install it inside your servo.

So lets make a start, shall we?

To do this you need 3 basic components:

1. Magnetic encoder IC and a circumferential field distribution magnet. The AS5040 gives you 10-bit resolution, the AS5145 12-bit resolution (4096 positions / 360 degrees) and an SPI interface which always comes handy. The two ICs are pin-to-pin compatible. Get these directly from Austrian Microsystems - ask for a sample, they normally ship the next day.
2. An ATMega 328P (MFL package) an on-board regulator and a 20MHz crystal (to get the control loop closing at 1KHz)
3. A Freescale motor driver IC (MC33887) which can deliver up to 5 Amps continuous. If you need something smaller try the MCP17511 (1 Amp cont.)

Each of these should go into a separate board and all three should stack together using low profile pin headers/sockets. The target board outline is 15.5x15.5mm - a good design exercise :) This will make it fit inside any standard size servo. If you cannot get it that small try the 1/4 scale instead. The target board outline for this is 25x32mm with plenty of height space.

When designing the magnetic encoder board bear in mind that the centre of the servo's output shaft for standard servos should be located 10mm from servo casing (15mm for 1/4-scale servos). The magnetic encoder ICs have an allignment tolerance of +/- 0.5 mm so they are pretty forgiving in terms of misallignment.

The ATMega328P board should stack directly under the magnetic encoder. It is the same processor Arduino uses. Remember to keep the programming pins near the board edge for easy access. The pins needed to get feedback from the encoder and control the motor driver should come out on the sides of the board such that all three boards can be stacked together. The remaining pins should be exposed using pads so you can solder wires and use them if your application needs them. You should have 4 digital IOs and 4 analog inputs available for other stuff. Basically you get full Arduino functionality but 4MHz faster clock and half the footprint of Arduino nano :))

The motor driver board should be on the bottom of the board assembly. Keep the bottom layer free of components with a large copper plane and use thermal vias to direct heat away from the board. Keep it free of components so you can add heatsinking if so
required. Normally you should ok without, but if you go for high-performance coreless servos heatsinking becomes a must.


http://www.01mech.com/sites/default/files/images/MagEnc.PicoMCU.01MD.JPG


When everything is ready (.....) you can install the boards inside your servo. To do that first you have to connect the magnet to the servo's output shaft. I will repeat the necessary part of the procedure of my previous post just to avoid any confusion.

- Start by accessing the servo’s bottom compartment and by removing the control / power electronics from the servo. Unsolder the motor’s leads and proceed by removing the feedback potentiometer.

- If continuous rotation is required, access the servo’s top compartment where the gearbox is located and remove the mechanical stop from the output gear. Take extra care not to damage the gear’s teeth as well as, keeping any foreign particles from entering the gearbox assembly. Particles residing on any of the gears’ teeth will cause undesirable noise during operation and may also affect the performance of your servo.


http://www.01mech.com/sites/default/files/images/MagEnc1.jpg


- Next disassemble the potentiometer keeping the rotation shaft. Remove the potentiometer slider from the shaft. What remains is going to be used as a support shaft for the encoder’s disk magnet. The magnet is going to be glued onto it.

- Carefully flatten the potentiometer’s base using sandpaper or an abrasive disk.

- Roughen the side of the disk magnet to be glued onto the potentiometer’s shaft by using sandpaper. This step is essential and will ensure a strong assembly.

- Take a small piece of wood, 10mm thick and drill a blind 3.5mm diameter hole approximately 5mm deep. This is going to hold the
potentiometer’s shaft and the disk magnet vertically while the epoxy settles.

- Prepare a small epoxy mix, insert the pot’s shaft to the hole and place the disk magnet on the pot’s shaft with a small drop of epoxy between them. Remove any excess epoxy. Ideally you should aim to leave a small ring of epoxy around the circumference of your magnet for lateral support. Remember that your servo has an output speed of about 60 rpm but the system that the servo is going to be installed will most likely be subjected to other sources of vibration. Accurately centre the magnet on the shaft and leave to settle for at least 6 hours (for a 5min epoxy). We know you cannot wait to start using the Supermodified™ on your project but you must show patience if you do not want to repeat this step in the near future.

- Insert the pot’s shaft back into the servo’s output gear. Make sure the flatten area of the shaft goes fully into the corresponding ‘pocket’ of the servo’s output gear like it did before the modification.


http://www.01mech.com/sites/default/files/images/MagEnc2.jpg


Next you need to flash the Atmel. Check Google Code page(s) below for the source code and programming guide for AVRStudio, MS Visual Studio Xpress and Eclipse. The AVR library page is a must. Currently supporting only ATMega MCUs but soon to be expanded.

http://code.google.com/p/zoavrlib/

http://code.google.com/p/zosupermodified/

Following the procedure above you need to make a hard decision: I2C, RS232 or RS485?? With I2C and RS485 you can daisy chain many controllers together. Solder the appropriate cables in place together with the motor-leads' cables and the power-cables.

At this point you should be able to drop the boards assembly inside, locate it in place using heat-glue or thermal foam and start playing :))

Schematics (Eagle & pdf):

http://www.01mech.com/supermodified scroll down the page & right click > Save as...

I am still waiting on my boards to arrive. Will update the post accordingly then.

zoomkat
04-01-2010, 10:01 AM
Just as a readibility suggestion, you might go back and put a carrage return between each photo such that they are aligned vertically instead of horozontally. On my laptop having the pix horozontally aligned makes me have to endlessly scroll back and forth to try to read the text (or copy and paste in note pad). Looks like an interesting article so far.

jes1510
04-01-2010, 10:55 AM
Nice! I do have a question though. What is the advantage of this over an off the shelf networked servo such as the AX-12. By the time you take a decent servo like the 645 and do this then the 645 may very well be more expensive than the AX-12.

Antonb
04-02-2010, 05:27 AM
Nice! I do have a question though. What is the advantage of this over an off the shelf networked servo such as the AX-12. By the time you take a decent servo like the 645 and do this then the 645 may very well be more expensive than the AX-12.

That must be the the perfect question :)
The AX-12 is a very capable servo. However there are some things it could do better like:
-Its motion resolution is four times less (0.35 degrees for the AX-12 against 0.087 degrees for the controller above).
-It does not support continuous rotation. Its range is limited to 300 degrees. the controller above is made for continuous rotation
-It does not support I2C comms.
-The controller above has 4 analog and 4 digital IOs available for other stuff and is also re-programmable (and totally Arduino compatible)
-The current delivery capability of the controller above exceeds 5Amps (with proper heatsinking) and therefore could easily be used to drive even medium size DC motors replacing ridiculously expensive DC motor controllers.
-The AX-12 does not support motion profiling which, the contoller above (it is called Supermodified) does.
-You can adjust the PID parameters on the Supermodified.
-The Supermodified comes with really nice support libraries for one of the most popular MCUs ever the ATMega328P for which there is a ton of stuff around from the community.

I guess the controller above might end up being a little bit more expensive in that instance but it offers so much more. Whats more is that if you start looking at higher torque servos like the HS 805BB, and fitting one of those controllers in there then, given all these capabilities that you get it actually becomes a bargain

MikeG
04-02-2010, 09:06 AM
Nice work Antonb...

Clarifications:
The AX-12 has a 0.29 degree step size and the it does support continuous rotation mode.

Do you feel that I2C is a better communication protocol than the AX-12's 1/2 duplex serial? I've been look at open servo and they use I2C too. It seems to me that the asynchronous nature of the AX-12 bus would be a more efficient protocol. Your thoughts?

Again nice work.

Antonb
04-02-2010, 01:43 PM
Nice work Antonb...

Clarifications:
The AX-12 has a 0.29 degree step size and the it does support continuous rotation mode.

Do you feel that I2C is a better communication protocol than the AX-12's 1/2 duplex serial? I've been look at open servo and they use I2C too. It seems to me that the asynchronous nature of the AX-12 bus would be a more efficient protocol. Your thoughts?

Again nice work.

You are absolutely right. I2C comes handy though for a microcontroller that does not support UART comms, or if one wants to avoid an RS 485 transceiver and still have the ability to control many devices with a single bus. Its nice to have the option..

RobotAtlas
04-02-2010, 07:40 PM
> Whats more is that if you start looking at higher torque servos like the HS 805BB,
> and fitting one of those controllers in there then, given all these capabilities that you
> get it actually becomes a bargain

I think this is the biggest attraction in making your own servo.
Yes, AX-12 are very reasonably priced for what they do (robotis probably doesn't make much money on it),
but once you want more torque, you are immediately paying at least 4 times more if you want Dynamixel,
which is a lot of money for us hobbyists.

Anton, what other motors have you actually _used_ Supermodified with?

billyzelsnack
04-02-2010, 11:03 PM
Antonb. Do you happen to know what sort of numbers the 805bb get with your driver?

Antonb
04-03-2010, 04:51 AM
> Whats more is that if you start looking at higher torque servos like the HS 805BB,
> and fitting one of those controllers in there then, given all these capabilities that you
> get it actually becomes a bargain

I think this is the biggest attraction in making your own servo.
Yes, AX-12 are very reasonably priced for what they do (robotis probably doesn't make much money on it),
but once you want more torque, you are immediately paying at least 4 times more if you want Dynamixel,
which is a lot of money for us hobbyists.

Anton, what other motors have you actually _used_ Supermodified with?

Thats exactly my point. The bigger Dynamixel models are very nice but totally expensive. Furthermore they might support continuous rotation but from my understanding - after reading a bit on the datasheets - they have an 'Operating range' of 280 to 300 degrees. This means Dynamixel servos have a dead-band of 60 to 80 degrees, coming most likely from the feedback potentiometer they use - not particularly good for robotics applications requiring uniform, continuous actuator control capability over the full 360.

I have now used the controller with many standard servos and also the Hitec 1/4 scale HS805 BB. The driver could be used to control any dc servo requiring up to 5 Amps continuous (7.8 Amps bursts). The magnetic encoder could be attached separately

Antonb
04-03-2010, 05:00 AM
Antonb. Do you happen to know what sort of numbers the 805bb get with your driver?

Im not sure if I understand what you mean. The HS-805BB is a large-scale servo from hitec which is fairly cheap and gives you up to 26kg.cm of torque. It has flanges to protect it against spraying water (not immersion) and a dual ball bearings. One Supermodified controller could drive two (maybe even three) of those simultaneously:D

billyzelsnack
04-03-2010, 08:42 AM
The 805bb can perform beyond than the rated numbers when over-volted.

http://www.lynxmotion.net/viewtopic.php?t=1602 ( 3rd post )

Looks like the limiting factor is the driver, not the motor or gearbox. Since your board can handle much more current ( dunno about the extra voltage ) it may work very nicely with this servo.

MikeG
04-03-2010, 10:21 AM
Antonb, excellent documentation. I'm going see if I can build a few supermodified servos.

Antonb
04-07-2010, 07:45 PM
The 805bb can perform beyond than the rated numbers when over-volted.

http://www.lynxmotion.net/viewtopic.php?t=1602 ( 3rd post )

Looks like the limiting factor is the driver, not the motor or gearbox. Since your board can handle much more current ( dunno about the extra voltage ) it may work very nicely with this servo.

Thanks for the info - I'll make the most of it! :D

In terms of the voltage the Supermodified can handle is 12V max - when powering directly the three board assembly, but if you power the motor driver board separately you could go up to 24V

br0x
05-25-2010, 10:05 AM
I have a question - where to get appropriate magnets? I have a feeling that accuracy and linearity are depending on it...

Antonb
05-26-2010, 01:46 AM
I have a question - where to get appropriate magnets? I have a feeling that accuracy and linearity are depending on it...
You can get them from Austrian Microsystems as well as from 01 Mechatronics.

Disk (cylindrical) magnets are common but what you after is a disk magnet with circumferential field distribution i.e. North and South poles are distributed across the diameter of the disk rather than its height.

Roboticfan
06-23-2010, 05:20 AM
Very interesting controller !
I have search around for find anything like that to not have to pay the overpriced dinamixels :)
Atm i have filled and send you the form and hope that you are fast enough for providing the material ... he he

cya :)

billyzelsnack
06-23-2010, 08:01 AM
If you're talking about the AX-12, it's not overpriced.

Roboticfan
06-25-2010, 03:03 AM
I have mean the bigger ones :)
Other advantage i see is that you can de-multiply the axis force with pulley etc and then
just place this circuit face to the output axis to have the real angle or keep it in the
servo (but then you have the de-multiplication maths).
Very interesting with HS-805bb who are very cheap 24-26kg/cm servos.
I have planed to use a 10 tooth pulley on servo output and a 40 tooth pulley on axis to
have 4x the HS-805bb torque.but at same time if you do this you reduce the total speed from your
axis 4x.
In continuous mode the HS-805bb made 360° in 0.84 sec , then with this setup it will be 3.36sec.
It depend if you need high torque or high speed :)
Then it depend if you have to turn or move 96 to 104kg/cm fast or not.
If you have to go fast then you have to spend like $500 for a EX-106.
If the 3.36sec are fast enough then you spend 5x less with a HS-805bb + the circuits and 2 pulley +
mount.
In my case i prefer get 5x HS-805bb + 5x circuits + all pulley etc than only 1 EX-106.
Bye.

RobotAtlas
06-25-2010, 07:39 PM
You definitely have a good point here Roboticfan.
I'm sure everybody here will only welcome progress in this area.
Not many of us can afford EX-106s :(

Antonb
06-27-2010, 04:53 AM
Hi guys,

One Supermodified combo controller can easily drive (to stall point) two HS805BB Hitec servos.
There is no need for de-multiplication maths since the magnetic encoder will be on one of the servos or even the system's output shaft i.e. in the case of Roboticfan's drive in the centre of the 40 tooth pulley. Furthermore using multiple drive units on the output drive shaft, tends to eliminate gear backlash. A good example here is nuclear plants where the servicing robots that are being used employ harmonic gearboxes and three motors per gearmotor assembly.

Another point is that as correctly billyzelsnack indicated earlier in this post is that an HS805BB Hitec servo can be over-voltaged with the main limiting factor being not gear strength but motor temperature.

I will soon be posting my fourth servo hack where i am going to incorporate a small fan inside the servo and find - out the HS805BB's mechanical as well electrical limits.

billyzelsnack
06-27-2010, 10:24 AM
I will soon be posting my fourth servo hack where i am going to incorporate a small fan inside the servo and find - out the HS805BB's mechanical as well electrical limits.

Sweet. Thanks for doing this.