Saturday, February 18, 2023

Revisiting automatic embroidery

It's been quite a while since the first posts about my LEGO embroidery experiments saw the light of day, but the project as such has not been closed. To the contrary, I have recently started working on a more advanced version, and this time on a one that could at least rival the output of the hobbyist dedicatged embroidery machines, except for speed. It is still largely a project in progress, as many components get designed, redesigned, scrapped and reimplemented in a different way, but some points have surfaced indeed and are worth mentioning for those interested in building their own machines.

Obviously, the precision of the embroidered material's movement is of high importance: embroidering lines (satin), especially if they are only a few millimeters thick, looks very clumsy if the exact points where the needle struck the thread are not perfectly aligned. Imprecisions as small as 0.5mm can be annoying, whereas those in the range of 0.1-0.2mm are still noticeable.

This is, I'm afraid, where the precision of the LEGO movement mechanism was put under maximum strain (already in the first instance of the machine) simply because it was expected to do something it was not designed for in the first place. There are several factors in play, subtly braided together.

In order for the movement to be precise, the embroidery fabric frame has to be strong and resist any kind of deformation. This as such is not a big problem because multiple Technic beams with lots of reinforcements can bring the frame up to the required level of stiffness. But it causes another one: lots of reinforcements necessarily make everything heavier and larger, in turn increase the friction between the frame and its movement (X-Y) mechanism. Taking into account that the frame has to be squeezed very precisely into its rails (otherwise its accuracy would be sacrificed again), this causes the amounts of friction that prevent smooth travel. To be more precise, it causes tiny hystereses where the frame needs to overcome the tiny amount of friction before it finally moves, but then does so momentarily, until the next such friction point. All that results in a somewhat rough movement, unless the whole structure is reinforced even more.

The other, and in my experiences the more troubling problem, is the inherent backlash of the movement mechanisms. The moving parts themselves can, to some degree, be designed with minimal backlash, mostly using friction pins and sacrificing some smoothness in return for precision, but the actual NXT/EV3 motors suffer from it quite a lot, mostly due to their unavoidable internal gearboxes. (To wit: these are not stepper motors, but standard DC motors connected to a gearbox and a position sensor.) Precise movements - that is, at the order of magnitude of 10-20° - are rather unreliable. One way to approach this problem is to reduce the motors' output themselves by a large factor using gearboxes, but that ends up introducing just as much additional backlash.

A more promising approach is to always enforce "recoil" between movements, i.e. make sure that the correct position is always reached from the same direction. That ensures that the relative positions are retained correctly. E.g., if we always want to reach the target point by moving to the right, in case the target position is left from the current one, the machine will travel left a bit further than needed, and then return to the correct position towards right.

Exactly that approach I employed for my previous machines, but it turned out to cause yet another problem: the fact that, while embroidering, the thread tension plays a major role in the final pattern looking tidy and clean. If a recoil technique is employed to guarantee precision, all recoiled movements pull a bit more thread than needed, and loosen it as the fabric returns to its correct, intended position. More thread than needed results in a wobbly pattern.

Therefore, for comparison, I'm currently repurposing the X-Y movement mechanism of a laser cutter (powered by GRBL commands transmitted through a virtual serial COM port over USB) to move the fabric, while the LEGO EV3 takes care of driving the sewing machine through three NXT motors connected to a common shaft.

The controlling software (which is currently a custom script I slapped together in Python) is therefore a bit more complex, as it has to coordinate the loading of the embroidery, the EV3 control via Bluetooth, and the GRBL serial commands to the X-Y hardware.

Let's see if this will work... keep fingers crossed.