Sunday, July 17, 2022

The CoreXY Belt "Tuning" Myth

I have seen uncountable forum posts, comments, emails, etc., about the need to "tune" belts in a corexy mechanism. The comments usually involve something about phone apps that read the frequency of a plucked belt and how you have to precisely match the tensions of the belts. The concept seems to scare off many would be corexy DIYers, thinking that there is some sort of voodoo required to get corexy machines to work properly. 

It's all nonsense.

There is one primary goal in setting the belt tension. It is to set the tension so that the X and Y axes are square. If they aren't square your prints won't be square- i.e. they will be distorted. What is more important to you, getting perfect middle C from the belts, or getting undistorted prints out of your machine?

It is apparently not obvious why tensioning the belts can affect the squareness of the axes so I have prepared some diagrams, below, that illustrate the concept. They are based on a diagram I have used a lot in the past so they may look familiar. I used UMMD's stacked belt layout, but the same concepts apply to any other belt layout you may use.

Fundamental assumption- you built the machine so that the X and Y axes are square when there are no belts on the mechanism. Don't assume you can use belt tension to correct for sloppy construction! If your axes aren't square without the belts, no if, ands, or buts, it's wrong. Fix it.

There are different ways to tension the belts, but adjustment must always be done on each belt, independently. If you move P3 or P4 in the Y direction, you tension both belts. That's not what we want to do. I illustrate tensioning by moving the motors. You could tension this belt by adjusting the attachments at the extruder carriage, or by having pulleys pressed against the belt between P3 and P4 or between the A motor and P4. 

Note: In the examples I use moving the motors to tension the belts because that's how I do it in my printer. It doesn't matter how you tension each belt- screw adjustments at the extruder carriage, moving motor, etc., the effect of the increased tension on the belt will be the same on the X axis.

When you move the A motor, P1 and P2 will experience forces created by the tension in the belt. There will be X and Y components of the forces at those pulleys, but we can ignore the X components because they don't affect the position of the X axis. The Y components of the force, illustrated by the green arrows are equal and in opposite directions. That is what causes the X axis to tilt out of square with the Y axis.

If everything is made of metal and bolted together tightly, how can the X axis possibly rotate out of square with the Y axis? Let's see... the Y axis bearing blocks to which the X axis rail is attached are not perfectly rigid and will deform slightly. The Y axis rails and whatever they are mounted on will also flex a little (especially if they are end-supported round rails). The X axis itself will also flex a little. All those little imperfections add up and will allow the X axis to tilt relative to the Y axis. Don't believe it? Try this experiment before you put belts on the mechanism:

Hold one end of the X axis against one of the mechanical stops at one end of the Y axis. Now grab the opposite end of the X axis and try to move it along the Y axis. Of course it moves. The X axis acts as a long lever arm against the opposite, fixed end of the axis. A little force applied at the free end turns into a big force at the opposite end of the axis, causing all those little flexures to occur. Notice that it doesn't take a lot of force to move the free end of the X axis. Now imagine what belt tension might do:

2nd belt in place before it is tensioned...

Now tension the 2nd belt by moving the B motor.

Notice the forces created (red) are opposite those created when the first belt was tensioned (green). Also notice that the arrows representing all the forces are longer because tensioning the second belt (red) increases tension on the first belt (green).

The X axis rotates back into square with the Y axis and your printer will now be able to make undistorted prints.

 If your printer's mechanism were built with absolutely perfect mechanical symmetry, the belts would be equal in tension when the axes are square. No one builds printer mechanisms with perfect symmetry, therefore when the axes are square, the belts tensions will not be exactly equal. It doesn't matter. Belt driven linear positioning mechanisms work well over a wide range of belt tensions. 

I've put the above illustrations together into an animated .gif file:

Some manufacturers, such as Gates, have phone apps to set the belt tension based on the type and size of belt, the length of span, etc., so you can use it to set the tension to the manufacturer's specified optimal tension value (assuming you know what that value is, and can convert it to frequency). I wouldn't assume that all belts have the same optimal tension, so if you're using no-name Chinese belts and adjusting them to Gates specs, you may or may not be getting what you are expecting. OTOH, it's nice to have some objective indication of belt tension, even if it isn't optimal. The good news is that belt tension isn't critical al long as you set it high enough that the belts don't flop around but not so high that they cause excessive wear on the bearings in the motors or binding of the mechanism. "Tight, but not too tight" applies.

I hope this clears up some of the silliness that the internet always seems to provide a home for..

Sunday, May 8, 2022

Bank Account Protection Circuit for Servo/Stepper Motors

Update 6/11/22

The parts I ordered from Mouser finally arrived, after 6 months of delays in getting the connectors. Here's one of the boards, fully assembled, using the 1W wirewound resistors and including the connector:

If you decide to build some of these circuits, you can skip the connectors and just solder the power in and out wires to the board.

Now back to the original post...


I wrote most of this post a couple months ago but didn't publish it because I was waiting for the connectors I ordered from Mouser Electronics. When I first ordered them, one piece was out of stock and due to be back in stock in a couple weeks. In a couple weeks I got an email informing me that the back ordered parts wouldn't be in for another month. A month went by and I got notice that the backordered parts were in stock but one of the other pieces was now out of stock. They're telling me that the parts should be in stock at the end of May. 

I decided to try using the servomotors in my corexy 3D printer, Ultra MegaMax Dominator and wanted to have protection for the controller board and all the other stuff that connects to the power supplies that power the XY motors, so I went ahead and wired in the protection circuits without the In/Out connectors.

Next time I order parts, I guess I'll have them ship as they arrive in stock instead of holding shipment until all parts are available.

Why Does My Bank Account Require Protection?

A while back, when I was working on the Arrakis sand table, I discovered that one really needs to take some special precautions when driving servomotors (or steppers) at high speed and acceleration. I had a Duet controller board, a couple buck converters to power LED strips, and servomotor, all connected to a single 200W 24V power supply. I made the mistake of driving the mechanism into the end of an axis at 1500 mm/sec. The sudden stop caused the motor's kinetic energy to be converted to electrical energy which ended up on the power supply line, blowing up the controller board, power supply, and buck converters, about $200 worth of electronics, hence the title of this post.

Motors generate voltage that opposes the voltage trying to make them turn. Under certain conditions, they can generate more voltage than the driving voltage. Those conditions include driving them at excessive speed, manually turning them (such as when sliding around the extruder in a 3D printer by hand), and slamming into physical stops while they are moving at high speed (like I did). In the Arrakis sand table, a simple error in generating the pattern file that's a little bigger than the actual table dimensions (combined with an incorrect axis maximum definition in the config file) can cause such a sudden stop. In servomotors like the iHSV series parts I used in Arrakis, the specified maximum rotational speed, 3,000 rpm, is limited by the self-generated voltage. When generating a pattern file for Arrakis, it's easy to make a mistake that will drive the motor beyond the 3,000 rpm limit.

Protection can take different forms. In Arrakis, which runs RepRap firmware on a Duet WiFi 3D printer controller board, I can program speed, acceleration, and travel limits in the Duet's configuration files. In theory, the fault condition should never occur. However, all that assumes that the controller hasn't lost its mind, that there are no mechanical failures, and that the dumbass (specifically, me) experimenting with the mechanism remembers to set the correct software limits in the controller.

What is really needed is a device that will protect my bank account from my stupidity, an insane controller board, or a mechanical failure in the mechanism. Preferably it will be a circuit that will sense a fault condition and keep it from damaging the electronics that might be sharing a power supply with the motor.

Someone on a web forum pointed out a protection circuit in an app note from Gecko Drives, a company that makes stepper and servo motor drivers. 

The circuit is pretty simple- the 1,000uF cap absorbs small current spikes that may occur under normal operation of the motor. Normally, motor current from the power supply goes through the diode to the integrated motor/driver. In the event of a sudden motor stop due to hitting the limit of an axis, or a bearing seizing up, or some object blocking the motion, the motor will put a reverse current spike on its power line. That will cause the voltage on the capacitor to rise above the power supply voltage, reverse biasing the diode (switching it off) which will turn on the transistor, dumping the current coming from the motor to ground via the 33 Ohm resistor. The power supply and anything else connected to it will never see the voltage/current spike from the motor.

I ran a simple simulation in LTSpice to see how it works. The voltage source on the left is the 24V power supply and the current source on the right stands in for the motor.

It's not much of a model, but it roughly demonstrates what happens in the circuit:

The green trace is the current in the motor. It starts at -3.4A, which represents the loaded motor current supplied by the 24V power supply (V1). When the current reverses direction (the fault condition) the voltage across the motor (blue trace) rises. Current through R3 (33 Ohms) starts at about zero because the transistor is off. When the voltage across the motor rises above 24V, the transistor turns on and current through R3 (red trace) rises. The power supply voltage is the light blue trace- notice it barely moves.

I decided I needed to build some of these circuits as I have 4 more of the motors waiting for projects (in addition to the two that are in Arrakis). I thought about hay wiring them, but it didn't seem like a good idea, so I needed a printed circuit board. I asked around the makerspace and a couple people recommended KiCAD, so I gave it a try.

Parts Selection

When you lay out a PCB, you need to know exactly which parts you're going to use in order to select appropriate footprints. The app note doesn't say too much about the parts so I made some calculations of basic specs then went shopping. I decided to use through-hole mounting for all the parts because they're easy to handle and solder.

The motor current normally flows through the diode so it has to be rated to handle it. The data sheet on the motors seems to indicate that the nominal load current for the motor is 3.4A  (3.4A x 24V=81.6W, and the motor is advertised as a 78W motor, so the current seems about right) and that the driver will alarm (and hopefully shut down?) at 300% of that. 300% of 3.4A is 10.2A, so I chose a 15A 100V Schottkey diode (SMC 15SQ100). In normal operation, with 3.4A going through the diode and voltage drop of 0.5V, the diode will have to dissipate about 1.7W, so it's going to get warm/hot (assuming the motor is loaded and drawing full current).

In the "Arrakis Incident" the motors were brought to an abrupt stop which is what caused the voltage/current spike that blew up the power supply and other electronics. If there had been a protection circuit like the one here, after the stop and current spike, the motor might have started up again (the power supply wouldn't have been dead) and run until it slammed into another hard stop. And it might have kept going, over and over. Hopefully, I'll be there watching it and will shut off power before the repeated slamming around does any damage.

The iHSV motor's integrated drivers appear to monitor the motor speed and/or supply voltage and will shut down the motor/driver if you try to drive it so fast that the self generated voltage exceeds the power supply voltage by some unknown amount. Other motor and driver combos may not do that.

If you try to drive a motor beyond it's spec rpm limit, the voltage at the motor will rise, Q1 will shut off, and the motor will slow down or stop until Q1 turns off again, and then the motor speeds up again repeating the cycle (again, the iHSV motors don't seem to do this). In some mechanisms it might keep doing that until someone notices that something is wrong and shuts down the machine. That means R1, R2, R3, and Q1 will all be working to dissipate energy from the motor on a repeated basis.

I point out the different types of faults because it affects the component selection. When Q1 is off, the normal state, R1 and R2 have very tiny current passing through them. In a fault condition, the current goes up and depends on the magnitude of the voltage/current spike produced by the motor. A 20V rise will cause 20 mA to go through R1 and R2. A 76V rise (which puts us up to 100V, the rating of capacitor C1) will drive 76 mA through them. 20 mA will dissipate 0.4W and 76 mA will dissipate 5.8W. Unfortunately, I can't really predict how the iHSV motors behave. There's no way to know what the voltage/current spike will look like under different fault conditions, and I'm not prepared to risk destroying a motor to find out. I chose to use 1W resistors for R1 and R2 and hope that will be sufficient. I used wire wound resistors because they can tolerate power surges better than other types. The ones I used are good for 10x their rated power (=10W) for 5 sec.

The app note specifies a TIP147 Darlington PNP transistor, so I chose one in a TO-220 package. Does it need a heatsink? This also depends on the magnitude and duration of the fault. I think it will only operate for a few seconds at a time under fault conditions, so I think it is safe to dispense with a heatsink.

This is a relatively high current circuit, so I chose a 4 pin Molex MegaFit connector rated for 23A per pin. I also ordered crimp terminals and shell for the plug that mates with J1.

I put together a BoM with part numbers from Mouser and Digikey here. You can make all sorts of substitutions and find the same or similar parts from other dealers. Prices in the BoM are approximate, of course. 

Designing the PCB

I watched a few youtube tutorials on using KiCAD, and dove in. One thing I found out is that if you're going to have PCBs made by OshPark or other board maker, it's best to set up the board maker's design rules before starting the board layout. 

I went to the OshPark website and looked up their design rules and checked them against the defaults in KiCAD. It turns out there were no issues so I didn't really have to change anything. A more complex board or using surface mount parts might require some of the changes.

Next I drew the schematic diagram:

Once the schematic was entered, I selected footprints for the parts. I checked data sheets for part dimensions and selected appropriate footprints from the KiCAD libraries. Then I just dragged the parts into position, paying attention to the net connections, defined the outline of the board, placed mounting holes, and started putting down traces. I used a filled area on the top of the board for a ground plane and put the rest of the wiring on the bottom of the board.

I had to change the connections to the connector a few times before arriving at the final pinout. Some pinouts led to difficult arrangement of the components on the PCB that required jumpers, etc. I found that by playing with the connector pinout I could create a very simple layout for the board.

The diode will carry the full motor current under normal operation, so the metal traces on the board need to be pretty wide to ensure low resistance and heating. There are a bunch of on-line PCB trace width calculators that will give a pretty good idea of the required trace width for any given current, trace length, and temperature rise. I used this one. I put the diode very close to the connector pins to minimize the high current trace lengths and used 10mm wide, filled areas for those connections for the same reason. They should be able to handle the fully loaded motor current and even the peak current without burning up, even with 1 oz copper.

The capacitor and transistor CE loop are the only other places that are likely to see much current so I used wider traces for those to minimize resistance/heating.

The final steps before ordering the board are to run a design rule check, fix any problems that it reveals, and then export Gerber and drill files.

This is the final layout which I have named REDump for "returned energy dump":

The board layout just before design rule check. The outline of the connector extended beyond the edge of the board so I had to edit it back to pass DRC.

The board is relatively large, 60 x 65 mm, due to the large sizes of the capacitor, 33 Ohm resistor and the connector. I used 4 mm mounting holes set at 50 and 55 mm spacing. I kept the edges of the board clear so that it could be mounted in slots in the walls of a case instead of using the screw holes.

I deliberately hung the connector beyond the edge of the board so that if I print a case for it the connector can protrude through the wall and mechanically support the connector. This overhang was flagged during the design rule check so I edited the footprint silkscreen layers so they wouldn't be drawn beyond the edge of the board.

I ordered a prototype run of 3 of the boards for about $30 from OshPark.

You can download the gerber and drill files in a zipped archive here if you just want to order boards, or the entire set of KiCAD project files is here if you want to do some editing for other parts/footprints.

And here it is:

I probably should have used bigger holes, pads, and pad spacing for the diode and the 1K resistors. When I order more boards I will make the changes to the files.


There are no tricks- just put the leads through the holes and solder them down. Pay attention to polarity of the diode and capacitor, and make sure you put the transistor in the right way- the heatsink tab should be toward the connector. 

Note- the 1W resistors and connector are all still back-ordered after about 4 months, so I built it using 1/2 watt resistors and no connectors.


I did some static tests to verify operation- first just applying supply voltage to the input and making sure it appeared at the output with a resistor substituting for the motor. Then I applied a voltage to the output to make sure sure the diode turned off and the transistor turned on. 

Finally, as I was preparing to install the servomotors in UMMD, I made a test video that indicates the protection circuit will indeed protect the power supply and other circuits from a voltage spike generated by the servomotor.


When you connect potentially high current wires it's best to avoid ground loops. That means each ground wire should go all the way back to the power supply. That's how I wired this into UMMD. The REDump board ground has a wire back to the power supply ground, and the ground from the motor goes back to the supply ground, not to the REDump board ground.

That means a 3 wire cable is required at the REDump connector. The crimp terminals listed in the BoM are for the plug that fits the jack on the PCB, and are for 14 or 16 gauge wire. If you're going to use some other gauge you'll need to order a different part number for the crimp terminals.

It's also a good idea to twist high current wire pairs, so when I installed the REDump boards in UMMD, I twisted the ground and supply leads from the REDump board back to the power supply, and twisted the motor ground lead around the supply wire from the REDump board together, then continued twisting the ground lead from the motor around the ground and supply leads from the REDump board back to the power supply.

In the future I'll be installing these boards in Arrakis so I can start experimenting with really high speed drawing without having to worry about what might happen if there's a mechanical failure.

Tuesday, March 8, 2022

New 3D Printed Sci-Fi Lamp Design

For some reason, I find myself designing and printing a lot of lamps. Here's the latest, designed in Fusion360 to fit a Feit Electric G63 vintage LED filament bulb that is 8" in diameter.

I like combining the antique look of the bulb with a "modern" base- it looks like something out of an old Buck Rogers movie (the movies from the 30s and 40s, not the awful TV series from the 80s).

The lamp base prints in vase mode. I printed it using PETG, a 1 mm nozzle, 1.2 mm line width, 0.5mm layer height, in about 4 hours at 30 mm/sec. Prusa Slicer vase mode has been broken for years and leaves a seam down the side of the print, so I sliced with Cura. No seam at all!

The overall height is 400 mm, the print is 300 mm tall. The bulb barely rises above ambient temperature, even after hours of operation, so there's no danger of melting or softening the PETG print.

A look down inside the print. You can see the tiny facets that make up the "curved" surface of the print. Maybe I need to export the STL file with even smaller segments.

Power off.

Power on- the bulb socket is quite visible at this angle. View it from a little higher or lower and the socket all but disappears due to the way the print layers scatter light.

Bottle for scale...

I'll probably print a cone using opaque white filament to cover the socket for this lamp. I'm also going to try printing the whole thing in opaque filament to see what that looks like. I'll post pictures when I do.

The Fusion360 Step file is here. You'll need a 280x280x300 mm (or larger) print capacity machine to print it, and I recommend a 1mm nozzle. You'll find the lamp is saved as a solid object. In the slicer you will use vase mode which will have no infill, a single wall, and no top layers. I printed in PETG, used 3 or 4 bottom layers, and set the line width to 1.2 mm. The resulting print is quite sturdy and very tough. I drilled a hole between the fins near the bottom of the lamp to feed in the line cord because I thought it would look better than running the cord out through a hole in the edge of one of the fins.

Thursday, February 17, 2022

Ultimate 3D Printed Wire Twister

Update 3/20/22

You can now find this design at the Wago Creators web site:

"Let's Do The Twist"

When you're wiring things like 3D printers, sand tables, model train layouts, and almost anything else, you often need to use wires to connect things that are separated anywhere from a few cm to a few meters. If you want to do it neatly, you want the wires twisted together, especially if they carry motor or bed heater currents. Twisting wires carrying high currents helps prevent them from inducing currents in adjacent wires.

A few years ago I designed a wire twister and posted it on It was a simple, two-part 3D printed tool. The spinning part had screw clamps to hold two wires and a hex shaft to fit in an electric drill/screwdriver. The fixed part was intended to be held in a bench vise. The wire clamps in both parts used screws to hold the wire tightly, so you had to use a screw driver to secure each end of each wire, creating four opportunities to stab yourself with a screwdriver in the process. Operation was simple- just pull the wires tight and pull the trigger on the drill. Bob's yer uncle, instant twisted wire pair!

A few days ago, I got an email notice that my old wire twister design was added to someone's collection at That same day I had demonstrated Wago lever nuts to my boss who is getting into model train layouts. And then, just like this old commercial...

...something clicked and I realized I could redesign the wire twister to use Wago lever nuts so all you'd have to do is lift the levers, shove the wires into the holes, snap the levers down and spin. No more screwdriver, no more risk of stab wounds! Wagos and 3D printing are the greatest combo since peanut butter and chocolate! The Wago 221-412 lever nuts are good for 24-12 gauge wire, solid or stranded, so they're good for almost any wires you'll ever need to twist.

The New Spinning Clamp Design

I previously designed some printable screw-down mounts for the Wago lever nuts and they worked very well. The lever nuts snap into the mounts so securely you have to use a screw driver to pry them back out. This is the basic unit I started with for the screw-down mounts, and for the new wire twister design:

I grabbed the design for the Wago holder above and reworked it to include a hex shaft to go into a drill:

The model for the Wago lever nut came from and is supposed to be accessible from inside Fusion360 (Insert>Insert a manufacturer part). It refused my login name/password when I tried to insert the part that way, so I just logged into the site in a web browser, downloaded the .stp file, then "uploaded" it to Fusion360. The model isn't very detailed, and doesn't include the concavity on the sides of the part that allow it to be held in place by the bumps inside my holder design. This is why it is sometimes better to make your own models or at least to measure the parts you want to use in CAD.

The New Fixed Clamp Design

My initial design was for a fixed clamp that you'd use with a C-clamp to hold it on the edge of a table or shelf, or in a bench vise. Then I decided it would be better if the fixed wire clamp actually was a C-clamp so you wouldn't need another tool. Here's what it looks like:

The fixed wire clamp is a clamp! Printed in 3 parts, the thumbwheel, the end cap, and the clamp body.

You can still use a vise to hold the C-clamp, if you prefer, or skip printing the fixed clamp and just hold a Wago in a bench vise.

The hardware consists of a 5/16"-18 bolt, 3-4" long, two nuts, and a washer. Those of you who live in the civilized world (you know, metric) may have to edit/scale the design file a little to use 8mm hardware. Assembly is obvious.


I used PETG filament for this one because it's pretty tough stuff and can take a lot of abuse. I arranged the parts on the print bed like this:

I have a 1mm nozzle on UMMD and the print came out OK, but I recommend you use a smaller nozzle and print in 0.2 mm layers. The extra cylinder is there to help the hex shaft of the spinning clamp print nicely. You could just print 2 or 3 of the spinning clamps (your friends are going to want one of these tools when they see it) instead.

I printed a bright color so I'd be able to find the thing in the bottom of a bag or toolbox.

The Result

The clamps were printed in 0.2 mm layers. I used contact cement to glue a piece of rubber to the fixed clamp to keep it from slipping when you pull the wires tight. I also used a drop of hot melt glue under each Wago to ensure they'd stay put. Shown here in "storage" mode- a piece of wire will keep the two parts together in your tool box so they don't get lost/separated. 

The Wago lever nuts snap into the tool, but dimensions are critical for retention and depend on your printer settings, so you may find that they will pop out of one or both clamps when you twist thick wires. The solution is as easy as a single drop of glue on the bottom of each Wago when you assemble the clamps. If you use ABS to print, superglue will work. You might want to use other glue depending on the plastic you use to print the clamps. Hot melt glue seems to work well on the Wagos.

It's a good idea to glue a little piece of rubber to the fixed clamp so it's less likely to slip when you clamp it to a smooth table top and start pulling on the wires.

The CAD File

You can download the .stp file here and open it in almost any CAD program you like.

Video, or it didn't happen!

How to Use It

In case it isn't obvious from the video above, just cut two wires to equal lengths, strip the ends, and insert them into the Wagos, and snap the levers down. Put the spinning clamp in the chuck of your drill/screwdriver, clamp the fixed clamp to a table or or shelf or put it in a vise, pull the wires tight, and pull the trigger. Keep tension on the wires as they twist, and when you feel you have enough twists in the wires, let go of the trigger. Give them one last tug to "set" the twist and then release the wires from the Wagos.