To get started with a board design for a servo controller made by the community here at DIY Drones for CNC and whatever floats your boat servo control. This discussion is part of the DIY Drones CNC Machine project. All are welcome to contribute their input on this fantastic project.

Views: 3595

Replies to This Discussion

I have a little bit of experience here with servos. Basically, unless you want to get crazy on the control software side, most setups use a step based pulse system. Nothing wrong with that and of course it allows for cheap stepper drivers and motors. Some of the high end servos take velocity inputs via serial data connections and special protocols.

My suggestion is to get step/dir pulse based working, then you can always add in front end code to accept other formats.


Both Gecko Drive servo controllers and these makerbot ones below can use step and direction pulses:

The problem here is that I was too in search of a DIY servo driver, based on step and dir pulse inputs, using common microcontrollers.

Here's what I know:

Messing with the open source Makerbot servo, the firmware is not in any way good to use at this time stock. Maybe someone can fix the magic bullet, but the system right now has horrible response in one direction. In other words, the comparator loop only works well (fast update) but in the reverse, a horrible lag. Knowing that using the Arduino IDE introduces lots of wasted cycles in the compiled code is at least somewhat to blame for the performance. I say this because some other designs based around PIC microcontrollers pretty much use assembly code to massively speed up the feedback comparator loop to a reasonable rate. Again, this is my limited understanding with a fair amount of hands on testing.

This forced me to just buy Gecko drivers which are reasonably priced. If you look at the gecko drives structure, they use FPGA which is insanely fast since it's hard coded logic that performs at near analog rates. By that, I mean update is so fast, the main comparator is running in the several kilohertz range as the drive is outside the range of my hearing. No hiss, no squeak, no buzz. I don't ever think you are going to get a microcontroller, even with assembly, as fast as FPGA.

Here are some videos:

Arduino based servo drive= very bad performance.

Gecko based


Stucture, no matter what is the same for all servos.

You basically have a comparator that takes a commanded position VS sensed position. It outputs to an H bridge. There is ususally a front end module to interface to quadrature or other encoder to get the sensed position, and then of course, there are gain and dampending modules in the feed to the Hbridge. Last is a safety and control module.

Thus, if you think of the blocks we have to build, it's not impossible and there is plenty of open source available. The question in my mind is can we get the speed we need out of cheap micros to even make this work. I say that because I have the FPGA based Geckos and to me, there is no way it can be built any other way. In other words, if you want a good servo, from the hardware point, it's FPGA or bust. This 200Hz loop rate claimed in the arducopter firmware (I haven't tested to see what it is) is no way fast enough for our intended usage in servos. We need 1KHz minimum and more than 10KHz is insanely better. I say this because otherwise if the loop rate isn't faster than human hearing, this thing will be louder and more expensive than steppers and then what's the point. Servos only become viable when they are more quiet than steppers or the whole position feedback is an absolute requirement rather than a desire. They cost more period just because of the requirement for an encoder. BTW cheap encoders are in every printer which I documented here :


So what I can contribute today to the project is that you can get cheap encoders anywhere that interface to the Geckos. If we can come up with an open source driver that beats or matches the Gecko in performance while also being less cost, then that's saying something. To me, knowing what's been put into the commercial product from both a hardware and research, the fact that it works extremely well and is resonably priced, makes this a serious challenge.

Anyway, I have a test bed, different motors and supplies, different masses, and the reference standard geckos alone with the makerbot versions. If you guys want to hack the makerbot code, I can run side by side tests for everyone and make videos. If you come up with a good design I also have some PICs lying around and of course, H-bridges are no problem so we can go to town as far as testing goes.

+1 on the Gecko products. Absolutely solid and well supported. They have years of experience and thousands of users (we use them in our medical products).

$121/axis for their BDC Servo Drive. The cost/performance ratio is tough to beat with that product.

80VDC,20A maximum!

Glad you stepped in Vernon. You've already got the platform to do comparisons.


I am sorry to hear of your tooth issue but glad you are feeling some better.

Pain creates a difficult environment for concentration and thinking.

One important point to remember is that it is far easier to change motor drives than the steel of the machine. You can start with one system, if you hate it, go with another.

A classmate of mine worked for a company that was converting hydraulic based machine tools to electric drive controls.

This a clear example that the control systems will age in time but the 60 year old Bridgeport type mill got a new lease on life.

Let us hope the DIY CNC chassis is around to be upgraded to what ever the future brings.

I am gathering parts for the 3 UHU based drives now.


Henrik here, I'm the developer of the alternative control module for the UHU based drives mentioned in the other thread, I was invitied by Monroe to join this group due to the groups possible interest in incorporating my motion control module (or special version of it) in a PMDC servo drive of your own design.

It's not clear to me which power levels we're talking about here, not that it really matters for the controller itself. It's just that if you we're talking from a couple of hundred watts up to say a 1kW I'd say it's may actually not be worth it to do it yourself when you can get a G320X for $121 or a DG2S08020 from CNCDrive for ~$90 (nice drives both of them though personally I prefer the one from CNCDrive).

With that said building your own may of course have other merits, in this case you could build it to exactly match the specification needed for the project (which, like I said is not clear to me yet) and you might be able to get drives cheaper in the end. No need to have 200V, 50A MOSFETS in a 50W drive.

There seems to be a bit of confision regarding servo loop rate vs PWM frequency. Basically the PWM frequency is what needs to be above the audiable range. In my module the PWM frequency is fixed at ~19.5kHz. Higher PWM frequency results in smoother current in the motor winding and allows motors with lower inductance winding (pancake motors and ironless motors are two examples which are typically low inductance) to be run but it comes at the cost of higher losses (in the form of heat) in the switching elements in the drive.

The servo loop is what calculates the position error and "commands" the motor based on that error and some sort of control loop (most often PID). In analog drives (such as the G320) this is a continous process while in digital drives it's executed at a certain frequency. The optimal frequency at which to execute the servo loop can depend on several things, like the intertia of the system, mechanical timeconstant of the motor and load and so on. (It may sound as if I know how to calculate this stuff but I don't...) In my module the servo loop rate is setable in 10 steps from 1220Hz up to 2785Hz. IF the motor and load was/is able to mechanically respond that fast then the servo loop frequency MIGHT translate into audiable noise but not many mechanical systems can respond to frequencies like that.

What is very important when doing a digital drive is that the servo loop needs to run at quite strict timing, the absoulte frequency may not be so important (although, as I said, it can help tune the system) but whatever the frequency is it needs to be stable.

I'm going to end this post with something that might get me kicked out ;-) If you're looking for open source code for this project I'm afraid I'm not the guy as I currently don't have any intentions to go open source with the module. Depending on the specifics of the project we may be able to work something else out though.

I'm not into the Arduino scene so I don't know what's available codewise there but there is a good dsPIC based project around that might be worth looking into if you haven't seen it. Just Google dsPIC servo and you should find it. The hardware for the original project uses a power OP-amp to drive the motor which isn't the most effcient way but the code is available and adaptable.





Thanks for your great response. I don't think anyone is upset you choose not to open your source. I think just your opinions and experience would be greatly appreciated.

Also, I don't anyone is stuck on what is used from a programming or hardware standpoint. Performance and cost are the main objectives and as stated by myself and others, Gecko is a good target to sort of set the standard of performance we hope to achieve. I don't think we need that kind of power, but to be honest, knowing inductance and other effects like braking, a high voltage rating of 80 volts is not entirely wrong. While we could use less amperage, I don't think 20 Amps is overkill either.

Point being, it should be a modular design for the power stage and just build that to suit.

Some research I found today


One heck of a good project here


I came upon an industrial site may be of interest to those technically qualified to interpret the direction control design is going in. 

The control system and electronic hardware is my particular interest, the rest will be created from what is available cheap (free!) and suplemented to achieve the accuracy require. 

Hi All,

Let me offer an EMC2/LinuxCNC perspective.

A common way of controlling a cnc machine with servos using linuxcnc is this:

- a "dumb" power-stage which essentially is just a powerFET or other current-switching circuitry drives the motor current. It takes PWM input. For a DC brushed servo this is just a singe H-bridge. For a 3-phase brushless motor or an induction motor this would be 3-phase H-bridge.

- an FPGA generates the PWM-signals, as well as reads the servo encoder signals. For a 3-phase motor the FPGA firmware does commutation also. The FPGA runs on a 50 or 100 MHz clock.

- LinuxCNC running on real-time linux closes the loop with a PID-controller. This loop usually runs every 1 ms. As argued previously in this thread the mechanical bandwidth of most cnc-machines is not very high, thus 1 ms is enough.

MESA-electronics makes some excellent FPGA-cards (PCI or PCIe I think) which have good support under linuxcnc. The firmware VHDL is open-source, and is compiled with Xilinx tools that Xilinx provides for free. MESA as well as pico-systems/Jon Elson also makes power-stages both for brush-DC and brushless.

I also agree with previous posters that making your own servo-controller is probably not going to be faster or cheaper than buying something ready-made.

My suggestion: stand on the shoulders of linuxcnc. get a MESA fpga-card, use the existing VHDL for encoder-counters and PWM generation. Start with an ultra-simple L297/298 power stage and a small motor with an encoder. Get familiar with modifying and compiling the VHDL. If you want the PID-loop to run on the fpga with step/dir inputs then work on that. If you want a stand-alone solution the get a stand-alone FPGA from MESA, or make your own fpga-board. If you want a high voltage/current powerstage then look at the IRAMS modules or similar.


I can try to offer some opinions. Whatever cnc-machine I'd build in the future would most probably use LinuxCNC, so that will bias my views somewhat. (I will probably forget to come to this website unless it sends me e-mail notifications about new topics/polls/replies etc. Maybe it does that already?)

I think this topic will require a better definition of what you are trying to achieve overall, and more specifically in this topic.

In general I think software people and talent (assembler or C for microcontrollers, VHDL for fpga) is easiest to find, small-signal and digital electroncis people/talent is a bit harder, and high-power electronics knowledge is the most scarce. The power stage will really require quite different approaches for =<100W and >1kW.

Do you mean the HK Magnetic Induction servos, or true encoders?

I have some of the HK MI servos, they seem pretty nice.


© 2020   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service