Thursday 9 June 2011

Reliable connections

After eliminating lots of other sources of unreliability in my machines, electrical connection failures are now the most common failure mode.

The latest failure on my Mendel was that it started leaving a 10mm gap in the outline rectangle that it draws around the objects. Since a bed full of objects still seemed to build OK I decided perhaps it was due to an air bubble in the extruder while it was warming up. However, one time I saw the extruder motor stall and realised it was actually a bad connection.

I have come to realise that simple friction fit connectors do not work in the environment of these machines. I tried re-seating the motor plug but that did not fix it, so I figured the cable must be faulty. I wired both coils in series to my multimeter and waggled the cable until it went open circuit. That allowed me to locate the break and it was, as could be expected, at the point where the cable bends the most, i.e. just below the cable clamp on the  top right of this picture: -


On reflection this was not a good arrangement as the cable is only just long enough for the extremes of travel, so it is forced to bend sharply both ways at the clamp. After millions of movements the strands break one by one but the insulation holds the ends together making it only lose contact when it is stretched. When I pulled the ends of the wires three of them snapped very easily, indicating most if not all the strands were broken.

I had a similar problem with the mains wire to a heated bed a while ago. In that case the arcing melted the insulation and allowed the live and neutral to short out, blowing a hole in outer sheath of the cable. Not good! Normally you expect a fuse to protect against a cable fire, but if all the strands start breaking, reducing the current capability, or it breaks and arcs, the fuse offers no protection against fire. Even a low voltage heated bed could fail in this way because of the high current.

The XY table of HydraRaptor uses 9 way D-type connectors. These have been totally reliable moving connections because they are screwed together and have gold plated pins and proper strain relief. The professional stepper motor drives on HydraRaptor have screw terminal blocks for their connections, and again they have proved totally reliable. In contrast all the friction fit connectors fail if there is any movement or vibration of the wire. Some even burn out despite being run at well below their current rating. The contact resistance rises and they then start to heat up.

I rewired my Mendel extruder using a 9 way D-type at the extruder and a longer loop of cable. That necessitated resiting the extruder controller and I also replaced all of its 0.1" MTA connectors with screw terminal blocks. The wires could go straight into these but I added ferrules to allow them to be more easily removed and replaced. I just push the wire into the ferrule and then squeeze it with pliers.

I reprapped a bracket to attach the DB9 connector to the back of  Wade's extruder bracket.

The pins are four motor connections, two heater, two thermistor and one heatsink fan that shares a 12V feed with the heater.

Here is the new arrangement :-


The cable loop is much longer, so it bends through a much smaller angle. The top end goes through two cable clamps before it goes to the extruder controller. I found that if you put a bunch of wires though a single clamp you can get some movement at the other side of the clamp. Using two eliminates any movement of the wire relative to the board, less critical now I that have screw terminals, but still a good idea.

It should last a lot longer than the previous cable (which lasted for 15 months of continuous use) and can be easily replaced. I have seen people use corrugated tubing to protect the cable, but I didn't fancy adding any more drag on the extruder as it would increase backlash.

Interestingly, although my extruder stepper motor connections have failed several times, I have never damaged the Allegro driver chips.




Monday 25 April 2011

Auto bed leveling

One thing I find tedious is leveling the bed of my machines, so I decided to make use of the Z-probe on HydraRaptor to measure the incline of the bed and compensate for it in software.

First I had to increase the resolution of my Z axis. When I first built the machine I did not realise that I would need fine resolution on Z, so I used an old 24V unipolar motor that I had in my junk collection. With half stepping it gave me 0.05mm resolution. I thought that it was a 200 step motor and that the lead screw had a pitch of 20mm. It turns out it must have been a 250 step motor because the pitch is actually 25mm. I replaced it with a Keling KL23H251-24-8B NEMA23 left over from my Darwin and I now drive it with a x10 microstepping controller the same as I use on X and Y. That gives me a resolution of 0.0125mm and also makes it the fastest axis on my machine. It can easily do 150 mm/s but seeing the nozzle approaching the bed at that speed and then stopping within 0.3mm is very unnerving, so I limit the speed to 50mm/s!

I no longer need the heat sink and fan because the new motor is more efficient and is directly mounted on the axis, which takes the heat away.


I use 6mm aluminium tooling plate so I make the assumption that the bed is a flat plane (rotated slightly around the X and Y axes and offset a little in Z). That means I only need to measure the height at three arbitrary points in order to characterise that plane. I then use the method here to calculate the equation of the plane in the form ax + by +cz +d = 0. The method puts two vectors through the three points and takes the cross product to get a vector at right angles to both of them. That is the normal to the plane and its components are the coefficients a, b and c. Substituting the first point into the equation gives d.

It is important that the three points are ordered anti-clockwise, otherwise the normal vector would point downwards and the machine would try to build the object upside down under the surface of the bed!

Given the bed's plane I then have to make the model coordinates relative to that inclined plane and transform them to the coordinate system of the machine. To do that I calculate two orthonormal basis vectors on the plane using it's equation and use the normalised normal vector for the third. I then multiply the model coordinates by those vectors and add the origin to find where they are in the machine's coordinates. Here is the Python code I used: -

class Plane:
    "A plane in 3D."

    def __init__(self, p0, p1, p2):
        "Construct from three anti-clockwise points"
        #
        # Calcluate the normal vector
        #
        v1 = p1.minus(p0)
        v2 = p2.minus(p0)
        normal = v1.cross(v2)
        if normal.z < 0:
            raise Exception, "Probe points must be anti-clockwise"
        #
        # Coefficients of the plane equation ax + by + cz + d = 0
        #
        a = normal.x
        b = normal.y
        c = normal.z
        d = -a * p0.x -b * p0.y -c * p0.z
        #
        # Generate three basis vectors aligned with the plane
        #
        self.origin = vector( 0, 0, -d / c)

        self.k = normal                      # k axis is simply the normalised normal
        self.k.normalize()

        px = vector( 1.0, 0.0, -(a + d) / c) # an arbitrary point on the x axis: x = 1, y = 0
        self.i = px.minus(self.origin)       # find direction to it from origin
        self.i.normalize()                   # make a unit vector

        self.j = self.k.cross(self.i)        # make a third vector mutually at right angles to the other two
        self.j.normalize()                   # make a unit vector, probably is already

    def transform(self, p):
        "Transform a point to be relative to the plane"
        return self.origin.plus(self.i.times(p.x)).plus(self.j.times(p.y)).plus(self.k.times(p.z))

To test the principal I put a 1mm thick washer under one corner support of the bed to give it an extreme slant compared to normal misalignment. I then built a 100 x 100 x 5mm cube with 0.35mm layers. This would normally be impossible without the bed being level to a small proportion of the layer height. The result was that it came out fine.


As the nozzle traverses the object in XY the Z axis moves a few microsteps. It is barely visible but I can hear it and feel it if I hold the stepper motor shaft. The object is built perpendicular to the plane of the bed, so the sides are very slightly slanted with respect to the machine axis and the nozzle. I am not sure how well it would work on Mendel as the z-axis is geared down so much. It would probably still work as the movement required is so small when the bed is reasonably level. I can't test it as there isn't room for a z-probe on my carriage due to the large heat sink.

Monday 4 April 2011

Auto z-probe

A niggling problem I have with Hydraraptor is that the z-axis calibration varies with the weather and how much it is used. This is because the frame is made from wood, which absorbs atmospheric moisture and expands. When the machine is running constantly the heat from the bed dries it out and it plateaus at a low z-value. If I don't use it for a while the z-axis gets higher by as much as 0.5mm in wet weather and the first few builds need large adjustments. When printing raft-less the initial layer height needs to be accurate to about 0.05mm for 0.3mm layers.

When it was configured as a milling machine I made a tool height sensor to solve the problem. It doesn't work for FFF though because the nozzle usually has hot plastic dribbling from it and it also wastes some of the build area.

To solve the problem I designed a z-probe that hangs below the nozzle at the start of the build but then retracts itself after the measurement. It consists of a weighted metal rod that slides through a couple of plastic guides. It has a plastic flange on the top that depresses the plunger of a light action micro switch. In measurement mode the rod protrudes about 10mm below the nozzle. When the measurement is completed the axis descends to place the nozzle close to the bed. The rod lifts until the attractive force of two Neodymium magnets causes it to be pulled about 5mm above the nozzle and held there until the start of the next build.




Here it is installed on the axis.


I used a Meccano worm gear as an improvised weight to ensure the micro switch is activated, much cheaper options exist! The actual weight is surprisingly not very critical. It must be enough to activate the switch reliably but not too heavy for the magnets to lift.


The operating procedure is as follows: The machine warms up the bed and the extruder and waits for a couple of minutes for the nylon pillars that support the bed to expand fully. It then extrudes a length of filament with the z-axis at the top and gives an audio prompt on my computer. I grab the filament and snap it off and then lower the z-probe, which closes the switch and instructs the machine to start.

The axis descends rapidly to place the rod 1mm above the centre of the bed. It then descends in 0.1mm steps until the switch opens. Then it ascends in 0.01mm steps until the switch closes again and that gives the Z calibration point, which is a known distance (about 10mm) above the bed. The nozzle then descends to 1mm above the bed to retract the probe before it moves to the start point.

Here is a video of the sequence.



It could also lower the probe automatically simply by having a bracket near the top of the z-axis to catch the flange as the axis rises past it. The reason I don't do that at the moment is because I use the act of manually lowering the probe as a cue to the machine that I have removed the start extrusion.

The design is on Thingiverse.