syntax-highlighter

Showing posts with label mechanical. Show all posts
Showing posts with label mechanical. Show all posts

Thursday, May 23, 2013

Smooth Feedrate Envelopes for Motion Control

When running motors it is desirable to run them as smoothly as possible to minimize vibrations and possible missed steps. This is why controllers for 3D printers and CNC machines typically incorporate some notion of acceleration rather than instantly switching from one feedrate to another.  Often this is done with a simple ramp of the feedrate, i.e. using a constant acceleration profile.

As an example, consider a machine starting at feedrate $f_0$ and then performing a very long linear move at a constant feedrate $f_1$. For this example, If $f(t)$ is the machine feedrate over time and $a$ is a constant acceleration, this profile would be defined mathematically as follows:

\begin{equation}
f(t) = \begin{cases}
f_0      & \mbox{if } t < t_0 \\
f_0 + a (t - t_0) \hspace{0.5cm} & \mbox{if } 0 \leq t - t_0 \leq \frac{f_1-f_0}{a} \\
f_1 & \mbox{otherwise}
\end{cases}
\end{equation}

Graphically, here's a plot of the feedrate over time for a move starting at rest at $t=0$ and accelerating up to a feedrate of 2 over one unit of time:


The problem with a constant acceleration profile is that there are sharp kinks in the feedrate plotted over time.  These kinks imply instantaneous changes in acceleration, which in turn imply infinite forces for infinitely short periods of time.  Of course, there is no mechanical way to produce these forces, so what actually happens is the machine overshoots very slightly and averages the forces out over a short time. For low feedrates with a light machine this actually works okay, but for a heavy machine at high-feedrates, the overshoot can be more than a motor step which causes the machine to lose position.  In an open-loop design, once the machine loses position, it never recovers and in all likelihood, the part is ruined.

There are a few ways to address this problem:
  • Use lower feedrates
  • Use higher torque motors
  • Use a closed-loop control scheme, e.g. with encoders on the motors
  • Make the acceleration smooth
The first is clearly not an option because it wastes time and feedrates may be chosen specifically for valid reasons such as minimizing local part heating or reducing machining time.  In an ideal world we'd do the remaining three items, but options two and three are expensive, particularly for hobby gear.  However the fourth option can be tackled in firmware with minimal hardware overhead. 

In order to smoothly transition between accelerations we can simply use a different curve to interpolate the feedrates.  The conditions needed are that the feedrates match the desired rates at the beginning and end of the curve and that the slope of the feedrate curves (i.e. the acceleration) is zero at the endpoints.  In between the endpoints we want the curve to be smooth.

The one of the simplest classes of functions that meet these requirements are cubic polynomials.  These are defined by four coefficients $a$, $b$, $c$ and $d$ using the following equation, where $\tau$ is the fraction of the total time spent accelerating:

\begin{equation}
f(\tau) = a \tau^3 + b \tau^2 + c \tau + d
\end{equation}

We now want to solve for the coefficients needed to reproduce the move.  There are four coefficients so we need four equations.  Two come from the requirement that we match the feedrates at the curve endpoints:

\begin{eqnarray}
f(\tau=0) = a 0^3 + b 0^2 + c 0 + d &=& f_0 \\
f(\tau=1) = a 1^3 + b 1^2 + c 1 + d &=& f_1
\end{eqnarray}

From these, we see that $d=f_0$ and $a+b+c=f_1-f_0$. The remaining two equations can be found using the requirements that the slope of the feedrate curve is zero at the endpoints. To enforce these constraints we need the derivative of the cubic function:

\begin{equation}
f'(\tau) = 3 a \tau^2 + 2 b \tau + c
\end{equation}

The constraints can now be enforced by requiring that:

\begin{eqnarray}
f'(\tau=0) = 3 a 0^2 + 2 b 0 + c &=& 0 \\
f'(\tau=1) = 3 a 1^2 + 2 b 1 + c &=& 0 
\end{eqnarray}

These equations make it clear that $c=0$ and $3 a + 2 b = 0$. Combining these with the previous conditions leaves two equations and two unknowns:

\begin{eqnarray}
a + b &=& f_1 - f_0 \\
3 a + 2b &=& 0
\end{eqnarray}

So $a = -\frac{2 b}{3}$ which means that $b = 3 (f_1-f_0)$ and $a = -2 (f_1 - f_0)$. This gives the following equation for the interpolating curve:

\begin{equation}
f(\tau) = -2(f_1-f_0)\tau^3 + 3(f_1-f_0)\tau^2 + f_0
\end{equation}

The only remaining thing is to define $\tau$ in terms of $t$.  This is a simple linear interpolation from the start of the acceleration $t_0$ to the end of the acceleration $t_1=\frac{f_1-f_0}{a}$:

\begin{equation}
\tau = \frac{t-t_0}{t_1-t_0} = \frac{t-t_0}{\frac{f_1-f_0}{a}-t_0}
\end{equation}

Plotting this for the same parameters as before gives a smooth, kink-free curve that considerably reduces the time-rate-of-change of acceleration:


In the post-to-come I will demonstrate applying this to a real stepper motor being driven aggressively.  Although seemingly complicated, for a cost of only a few operations per step, it is possible to switch from the linear acceleration profile to the cubic one derived here and get considerably smoother operation.

Wednesday, March 13, 2013

Reducing Warping/Shrinkage in Large 3D Prints

I've been doing a bit more 3D printing lately and having problems with large 3D prints warping due to uneven cooling. Most of the prints I work on are fairly large, roughly 10x8x4 cm or larger, so this can be a big problem, particularly if the dimensions change enough to mess up the fit of parts. Basically the problem is that as layers cool, they contract and pull off the build-surface. Generally I'm printing PLA on painter's tape, so this will just pull up the tape. An example is shown in the photo below:


You can see how the tape is pulled up at the near edge; this is about 2mm of shrinkage which is not too bad. But this is also a relatively small part, perhaps 5x5x4 cm, and the problem gets worse as the parts get bigger.  A partial fix is to use a heated bed, but the Gen6 electronics for my printer do not support controlling a bed.

However a more practical solution was suggested by another member of the Vancouver Hack Space.  He's working on a very large printer for very large prints; I highly suggest visiting his site ottersoft.ca if you're interested.  Anyway, his suggestion is to space the part up from the bed using some dummy geometry and then print with support material.  The support material forms less connected layers than the object, which gives it more...'give' when printing. Here's an example:


The little block is some dummy geometry added to lower the bottom of the geometry about 1.5 cm. When printed with support, the extra flex of the support lets the object stay attached to the bed without the terrible shrinking.


Part of this seems to be the extra flex, but I suspect that another part is less direct contact with the large metal build-plate, which acts like a heat sink, so the whole part cools more uniformly.


After pulling it off the build plate, you can see that the support material on both sides is in contact with the table, indicating little to no warping.  And this is a big part, roughly 10x8x3 cm.


The downside is that you now have to deal with the support material. If this is the same as the print material, it can be difficult to clean off without leaving a nasty surface finish or changing the part accuracy. For example, filing the support out of the horizontal holes without accidentally changing the hole diameter.  But once done carefully, the part is remarkably accurate: the height as measured at all four corners only differs by about 0.15 mm (with a layer height of 0.3 mm), and the holes are actually round and not elliptical.

I wish that I could take credit for this trick, but that belongs to Loial (ottersoft.ca) of VHS (hackspace.ca)

Wednesday, December 19, 2012

Parametrically Designed Gearboxes

Using my Python CSG and Gear libraries, I've been able to start parametrically designing parts.  This can sort of be done with OpenSCAD, but the lack of proper variables and functions makes it difficult.  Recently I tried designing a full gearbox.  The script is shown below: it's a bit messy, but you get the idea:


import gears
import pyPolyCSG as csg

def make_clamp_hub( B ):
    thickness = 9
    hub = csg.cylinder( B/2.0+6, thickness, True )
    hub = hub + csg.cylinder( 4.0, B+10, True ).rotate( 90.0, 0.0, 0.0 ).translate( B/2+3, 0, 0 )
    hub = hub - csg.cylinder( 2.0, 100, True ).rotate( 90.0, 0.0, 0.0 ).translate( B/2+3, 0, 0 )
    hub = hub - csg.box( B/2+6, thickness, 2, True ).translate( B/2+3.5, 0, 0 )
    return hub.rotate(90,0,0).translate( 0, 0, thickness/2-0.01 )

def make_gear( pressure_angle, pitch, teeth, thickness, bore ):
    px, py = gears.gears_make_gear( pressure_angle, teeth, pitch )
    coords = []
    for i in range( 0, len(px) ):
        coords.append( ( px[i], py[i] ) )
    gear = csg.extrusion( coords, thickness ) + make_clamp_hub( bore ).translate( 0, 0, thickness )
    gear = gear - csg.cylinder( bore/2.0, thickness*100, True ).rotate( 90.0, 0.0, 0.0 )
    return gear

pressure_angle = 20.0
pitch          = 0.8
N1             = 12
B1             = 8.0+0.7
T1             = 10.0

N2             = 36
B2             = 5.0+0.7
T2             = 5.0

backlash       = 1.0

dp1 = gears.gears_pitch_diameter( pressure_angle, N1, pitch )
dp2 = gears.gears_pitch_diameter( pressure_angle, N2, pitch )
do1 = gears.gears_outer_diameter( pressure_angle, N1, pitch )
do2 = gears.gears_outer_diameter( pressure_angle, N2, pitch )
dc  = ( dp1 + dp2 )/2.0 + backlash

gear1 = make_gear( pressure_angle, pitch, N1, T1, B1 )
gear1.save_mesh("gear_%gdeg_P%g_%d_tooth.obj" % ( pressure_angle, pitch, N1 ))

gear2 = make_gear( pressure_angle, pitch, N2, T2, B2 )
gear2.save_mesh("gear_%gdeg_P%g_%d_tooth.obj" % ( pressure_angle, pitch, N2 ))


def hole_xy( x, y, radius, height ):
    return csg.cylinder( radius, height, True ).rotate( 90.0, 0.0, 0.0 ).translate( x, y, height/2.0 )

B1s        = 10.0
B1p        = 22
B2p        = 10

box_pad    = 5.0
screw_diam = 4.0
box_thick  = 4.0
nema_offset  = 31.0/2.0

box_height = max( (do1, do2 ) ) + box_pad*2.0
box_width  = max( ( dc + (max( ( B1p, do1 ) )+do2)/2.0 + box_pad*2.0, nema_offset+dc+dp1/2 + screw_diam*2.0 + box_pad*2.0 ) )
screw_x_off = box_width/2.0-screw_diam
screw_y_off = box_height/2.0-screw_diam

g1_coords = ( box_pad+max((do1,B1p))/2.0, box_height/2.0 )
g2_coords = ( g1_coords[0]+dc, g1_coords[1] )

plate = csg.box( box_width, box_height, box_thick )
plate = plate - hole_xy( box_pad, box_pad, screw_diam/2.0, box_thick*2.0 )
plate = plate - hole_xy( box_width-box_pad, box_pad, screw_diam/2.0, box_thick*2.0 )
plate = plate - hole_xy( box_width-box_pad, box_height-box_pad, screw_diam/2.0, box_thick*2.0 )
plate = plate - hole_xy( box_pad, box_height-box_pad, screw_diam/2.0, box_thick*2.0 )


plate = plate + hole_xy( g1_coords[0], g1_coords[1], B1p/2.0+4.0, box_thick ).translate( 0, 0, box_thick/2+3 )
plate = plate - hole_xy( g1_coords[0], g1_coords[1], B1p/2.0, box_thick ).translate( 0, 0, box_thick/2+3 )
plate = plate - hole_xy( g1_coords[0], g1_coords[1], B1s/2.0, box_thick*2.0 )

plate = plate - hole_xy( g2_coords[0], g2_coords[1], B2p/2.0, box_thick*2.0 )
plate = plate - hole_xy( g2_coords[0]-nema_offset, g2_coords[1]-nema_offset, screw_diam/2.0, box_thick*2.0 )
plate = plate - hole_xy( g2_coords[0]+nema_offset, g2_coords[1]-nema_offset, screw_diam/2.0, box_thick*2.0 )
plate = plate - hole_xy( g2_coords[0]+nema_offset, g2_coords[1]+nema_offset, screw_diam/2.0, box_thick*2.0 )
plate = plate - hole_xy( g2_coords[0]-nema_offset, g2_coords[1]+nema_offset, screw_diam/2.0, box_thick*2.0 )
#plate = plate + gear1.translate( g1_coords[0], g1_coords[1], -10.0 )
#plate = plate + gear2.translate( g2_coords[0], g2_coords[1], -10.0 )

plate.save_mesh( "gearbox_plate.obj" )

This generates two gears and two gearbox plates that are mounted together using M3 screws.  The printed gearbox is shown below, although I'm missing some bearings and hardware.  Each plate has a recess into which a 608ZZ bearing can be press-fit.  Depending on the orientation it can either serve as a fixed or floating end.


I hope to use gearboxes like this to increase the speed that I can drive leadscrews at for my CNC project, which currently has pretty limited feedrates.  This would allow the use of cheap hardware store threaded rods, rather than expensive leadscrews, while still being a self-locking drive.

An End to Captive Nuts

I've been using 3D printed gears and timing pulleys for a while now, but have been very disappointed with the captive nuts that are used by most scripts available on Thingiverse. Generally I've found that the material being printed isn't stiff enough to allow the set screws to be tightened enough to secure to the shaft without deforming. This causes the pulley or gear to deform out of true.

To get around this I've started using clamping hubs.  They're not too much larger than the captive nut hubs but deform uniformly so the pulley/gear run true.


The picture above shows an example gear.  I've used an M3 screw in the clamping hub.  It ends up fixing very securely to the 8mm shaft and has the additional advantage of not marking the shaft.

I printed the gear above after using my Python Involute Gear Script to generate the involute profile, followed by the Python Constructive Solid Geometry Library to generate the hub and 3D model. The full source of the script that I used is shown below:

import gears
import pyPolyCSG as csg

def make_clamp_hub( B ):
    thickness = 9
    hub = csg.cylinder( B/2.0+6, thickness, True )
    hub = hub + csg.cylinder( 4.0, B+10, True ).rotate( 90.0, 0.0, 0.0 ).translate( B/2+3, 0, 0 )
    hub = hub - csg.cylinder( 2.0, 100, True ).rotate( 90.0, 0.0, 0.0 ).translate( B/2+3, 0, 0 )
    hub = hub - csg.box( B/2+6, thickness, 2, True ).translate( B/2+3.5, 0, 0 )
    return hub.rotate(90,0,0).translate( 0, 0, thickness/2-0.01 )

def make_gear( pressure_angle, pitch, teeth, thickness, bore ):
    px, py = gears.gears_make_gear( pressure_angle, teeth, pitch )
    coords = []
    for i in range( 0, len(px) ):
        coords.append( ( px[i], py[i] ) )
    gear = csg.extrusion( coords, thickness ) + make_clamp_hub( bore ).translate( 0, 0, thickness )
    gear = gear - csg.cylinder( bore/2.0, thickness*100, True ).rotate( 90.0, 0.0, 0.0 )
    return gear

pressure_angle = 20.0
pitch          = 0.8
N1             = 12
B1             = 8.0+0.7
T1             = 10.0

gear1 = make_gear( pressure_angle, pitch, N1, T1, B1 )
gear1.save_mesh("gear_%gdeg_P%g_%d_tooth.obj" % ( pressure_angle, pitch, N1 ))

I've found that being able to use Python is much more convenient than OpenSCAD, mostly because its possible to define (real) variables and functions/classes.  As a result I've pretty much switched to using the Python CSG library from OpenSCAD.

Friday, November 9, 2012

First Resin Casting

Following up on my two previous posts on making Silicone molds from OOGOO, I actually managed to cast a part today.  I ended up with mixed, but promising results as you will see. 

I started by cutting risers and sprues into the mold from my previous post.  Resin is poured into the sprues and air/resin escapes through the risers.  After the pour has finished, both the sprue and riser serve as reservoirs of excess resin to counteract shrinkage of the poured resin as it cures.


I used West System epoxy as a casting resin, which it is not specifically intended for.  It is however locally available and relatively reasonably priced.  Epoxy is also one of the least objectionable resins, much less stinky than polyester resin and apparently has substantially less shrinkage.  It's also easy to get the proportions right if you buy the pump kit.  But on the downside, it's meant for making boats, not casting.  Oh well. 


I don't have any pictures of pouring the resin, since I didn't want to gum up my phone, but in the photo above you can see the mold with mounting hole rods inserted and sprue/riser filled with epoxy.  I used vaseline as a mold release, especially thick on the metal parts since I was concerned that the epoxy would bond to the posts and scrap not only the part but the mold as well.  After pouring I plugged both holes and tumbled the mold by hand, hoping to get epoxy into all the nooks and crannies.  I failed, but more on this later.  I was concerned initially since my excess resin hardened quite quickly, but the resin in the mold appeared to harden much slower, judging by how gummy the resin at the top of the sprue and riser was.  So I left it for about four hours and luckily everything seemed solid when I checked it.


Here's the bottom half of the mold removed.  Unfortunately I ripped off the bottom half a bit too vigorously and tore the center plug.  Anyway, it was only a first try.


Here you can see the part almost completely separated from the mold, the only bit remaining is in the central hole which is the bit that I accidentally ripped off.  The vaseline also worked really well as a release agent; a quick easy twist of the posts with some pliers and they slid out cleanly.  This photo also shows the pegs left by the sprue and riser.


I then cut off the sprue and riser and filed the surfaces quickly to clean up the filament marks from the mold.  The bottom half of the part turned out pretty well, with only a few small bubbles.  However the piece looks pretty terrible due to the residual rust from the central pegs being oxidized by the Oogoo acetic acid as well as the yellowish color of the resin, although the photo makes it look worse than it actually does.  I was pleased to see that the accuracy is excellent; after a light sanding of the central hole, the linear bushing I'm using slides in perfectly with no play, although it might need a little dab of glue to keep it seated while in use.


The top portion of the part did not turn out so well due to trapped air bubbles.  The chunks missing in the photo above are all due to trapped bubbles, some of which are over 5mm across.  That's quite big for this part, which is only about 40mm on a side.  The white flecks are dust from the quick filing that is caught in the open surface bubbles.  This part is good enough to be usable, but I will try to produce a better quality version.

I realize now that the way I designed the mold was not the best.  Rather than have the Ooogoo fill the central hole, I could have put a patterned blank in as was done for the mounting holes, making it easier to separate.  Additonally, since this part only needs a single true surface, it could have been case in a single-piece mold which would have allowed me to directly see which areas were not reached by resin and also to intervene.  Having this ability would allow me to avoid the spoiled corners that can be seen in the last photo.  I would also spend more time on the cosmetic details of the pattern since every minor surface flaw was transferred to the mold and then to the finished part.  While this doesn't effect the function of the part, it does annoy me.

As an experiment, I consider this to be a success.  Ugly though it may be, this part MUCH stronger than the original printed pattern.  It is also dimensionally accurate with good surface reproduction, leading me to believe that Ooogoo molds with epoxy resin is a viable method for producing small-run parts, if one that requires some practice.  I expect the next attempt will be considerably improved. 

Saturday, November 3, 2012

Low Cost CNC Part VIII - Built-in electronics

In Part VII, I finally got the CNC cutting, but it was still a bit rough.  Cables ran everywhere, it was powered from a wall-wart and the electronics were sitting next to it on the table.  You can see the setup below:



Since finding the big C-channel piece that makes up the base of the machine, I've always planned to build the electronics into the base to give a nice, compact and clean machine.  I'd been waiting for a power-supply to arrive before doing this, but last week it came so I got to work.

The electronics are currently mounted to a piece of plywood that hooks on a key at one end and has bolt holes to bolt to some 3D printed plastic standoffs.  It fits into the base pretty nicely.


The plywood is a bit of an old shipping box; it had my address on it, hence the black tape.  Undoing two nuts on the right hand side allows the plywood to come loose:


Running approximately left-to-right, you can see the Arduino running GRBL, the three stepper driver carrier boards, a solid-state AC relay for spindle control as well as the power-supply and finally the E-stop button.  All the mains power is wired with 14 gauge household wiring connected with Marretts.  The E-stop button cuts all mains power to the power-supply and relay, thus rapidly immobilizing the machine.  The Arduino is unaffected by the E-stop, being powered from USB.  In this way, the E-stop also functions as an optional operator stop, allowing you to de-energize the machine, reposition it manually or change tools and then start it back up, knowing that it won't starting moving or cutting with your hands in there. 



Looking from the back, the USB socket for the Arduino is accessible, as is the scavenged spindle socket and power cable.  In a subsequent revision I plan to replace these with panel-mount components, but I couldn't locate them locally last week.


It's still a bit ghetto, but quite functional and self-contained at this point.  I intend to finalize the electronics layout and then make a sheet-metal replacement for the plywood with front and back panels and all panel-mount components.  But for the moment, it's working pretty well and I can easily pick it up and move it without rewiring the whole thing.


The other, straightforward, addition was cable drags on all the axes.  This has really helped to clean up the machine, giving me something that looks more like an actual tool than before.  Hopefully I will be able to start using it for projects soon.



Wednesday, October 24, 2012

Low Cost CNC Part VII - It LIVES!!!

So for the last, nearly two years, I've been working on building a low-cost, homemade, 3-axis CNC milling machine.  Today for the first time, I can say that I've done just that, having finally actually cut something.  As far as I know, it's the first milling machine build largely from 3D printed parts.

You can see the entire process, from the beginning, in the previous six posts:  Parts I, II, III, IV, V and VI.


The mill is shown below, along with the 3-axis CNC controller that I've posted about before. 


The spindle is a low-cost Dremel tool, currently attached with a Shapelock bracket.  It will no doubt get replaced with something less awful in the future (I am referring to both the Dremel and bracket, of course).


I have a Rotozip spiral-saw bit in the Dremel tool, to stand in for a proper milling bit.  It's a bit flexible, but more than up to tearing through MDF.


The whole setup is shown above and gives a good sense of scale.  My 3-Axis controller board is in the bottom right, controlled by my laptop.  The CNC itself has around a 6x6x4" working volume, although this is arbitrarily expandable in the X-direction.  The controller board runs GRBL, for which I have written a simple GUI for adjusting settings and jogging the machine. I plan to release the code for this when it stabilizes a bit, since GRBL needs a decent GUI.  I intend to add some basic features, like simple pocket/contour milling.  But for the time being, it's simply a software pendant.


So with everything set up, it was time to start cutting.  I attached my 3D printed iPhone mount to the XY table, started the Dremel, pressed record and began jogging the machine.  The result is pure awesomeness, for me anyway.



I had either the cutting depth or the feedrate too high for the spindle speed, since the bit began 'climbing', rounding the edges of the square when the feedrate was high.


But guess what? I don't care! 'Cause the CNC that I started nearly two years ago, which has been my preferred hobby while simultaneously being intensely frustrating has finally, finally, cut something. Praise Jebus!

Obviously there's refinement to be had.  For one thing, the ~10 mm long square sides should actually be one inch.  And I should make sure that the axes are actually square (I'd be shocked if they are).  Also I want to package the electronics in the base extrusion, provide a proper power-supply, perhaps some heat-sinks on the stepper drivers and maybe attach a real spindle.  And then there's ballscrews/belts.

But that's for later.  For the time being, my CNC actually cut something.

To my knowledge, this is also the first milling machine built substantially with 3D printed parts.  I hope in the not-to-distant future to get the feedrates up to the point of being able to 3D print with the mill itself. I also intend to build a tapping attachment to tap the holes used in the aluminum plates, which is -really- time-consuming and error-prone. This would make the machine as much of a RepRap as most 3D printers are, but considerably more solid.  But that's for later.

Monday, October 15, 2012

Low-Cost CNC Part VI - The Z-Axis

Following up on Parts I, II, III, IV, and V, the machine gets a Z-Axis!
 
With the addition of a Z-Axis the machine is starting to really come together.  The main supporting column is a 4x4" square extrusion with 1/4" walls, mounted at 30 degrees.  I'm hoping this will be stiff enough to be mounted cantilevered.  It mostly passes the 'grab-and-pull' test, but I can feel it deflect a bit when I yank on it.  Hopefully the forces during machining will be low enough for this to not be an issue.


I used two Newport 360-30 angle brackets to build the main support.  These normally retail for about $110 USD, but I was able to pick them up used for $38 each.  Here's a detailed shot of the lower mount.


This still makes them the most expensive part of the machine, but even with them, I think the mechanics could be built for about $100 per axis, including motors.  I looked at a number of options for the supporting column, including welding a custom bracket, but all quotes came back at $300+.  This cost less than $100 (including the column) and is pretty stiff. Plus I can re-use the brackets later.



I still need to tweak dimensions a bit.  As can be seen in the photo above, the Z-Axis is a bit low and doesn't provide much clearance over the XY table.  I will probably add a spacer on the angle mount and drill/tap a few new holes to get a bit more clearance.  I'm only shooting for about three extra inches.  This should give the final machine a few inches of working depth, including perhaps a small vise on the table and a cutter.  I may also flip the Z-Axis around and mount the plate rather than the carriage to the supporting column, which will give a bit more clearance but has other tradeoffs.


Sunday, September 16, 2012

Low Cost CNC Part V - A Redesign

I've been working on a homemade CNC now for quite some time.  My goal for the project was to produce something modular, where shaft-mounts, motor mounts and bearings were entirely separate parts using a standardized mounting pattern.  This would allow the machines to be put together like Legos and has a lot of advantages, like the ability to mix and match drive options, e.g. in the image below, one axis is screw-driver while the other is belt-driven.



I still think this concept has merit, however the part designs that I ended up using made for bulky and not particularly stiff machines. In the photo above, the top of the XY table is close to six inches from the base plate and the machine itself has considerable give.  Even worse, I didn't build enough slop into the designs to accommodate tolerances for manually built mounting plates, so it was actually quite difficult to get all the pieces to play nice.

I've since redesigned the machine to use more compact mounts, merged the shaft and motor supports into a single axis-end part and moved to half-inch shafting.  The switch to larger shafting results in a much stiffer machine, but unfortunately does require bushing style bearings.  Using the combined axis ends simplifies alignment, but unfortunately precludes belt drives.  I've also switched to Nema 17 steppers from Nema 23s, which leads to a more compact overall machine.  Surprisingly they don't seem to have much affect on the overall machine speed.  This makes for a much cleaner design:


Like the old parts, the new parts are 3D printed, but this time on my recently acquired RepRap.  The meshes were parametrically generated using my Python contructive solid geometry library, which is becoming quite usable.  This serves for prototypes, but final parts could be machines from plastic or aluminum.  The fixed-end for the leadscrew uses the same axis-end as the motor side, but with some bearing plates and Nylin nuts to take the axial loads:


After switching to acetal linear bushings, the bearings mounts can be made much more compact, reducing the height of the XY table from about six inches to a shade over 3.  These seem to run nicely on plain hardware store shafting, although hardened precision linear shafting would obviously be stiffer and smoother than cold-rolled bar stock.


Overall the machine is looking much cleaner.  I've decided to go with a knee-mill style machine rather than a gantry arrangement.  This means an XY table horizontally with a third axis mounted vertically. I bought a massive piece of aluminum channel to serve as the base of the machine, 10"x3"x20".  This provides a sturdy mount, and the controller and power-supply can be mounted to the underside.  Here's the thing midway through the build process yesterday:


And here's the finished-except-for-limit-switches XY table mounted to the channel.  The green duct tape is just there to stop it from gouging up my coffee table when I move it.  I will also probably replace the top cheese-plate with a thicker piece of flat-bar that's had all the holes drilled and tapped; I can't tell you how much I'm looking forward to doing that.


The mount for the Z-axis will be attached at the near-end of the machine.  I still have to design and build that mount, as well as print out the parts for the third axis.

After assembly, I simply had to try it out, missing limit switches or not.  I hooked it up to my 3-axis controller board with the Pololu A4988 carrier board carriers. The Arduino is flashed with GRBL, and wired to the carrier boards, which are in turn wired to the steppers.  I need to find some extra heatsinks for the X and Y axes, along with some thermal tape or epoxy, but they seem to run cool enough for testing anyway.


Here is it running, the first time I've gotten one of these CNC projects using actual GCode.  The leadscrew for the Y-axis is a bit loose in the fixed-end bearings, causing the knocking sounds, I have to look into the alignment, but otherwise it's working pretty well.  Speed is about one inch per second.


Next up will be designing a mount for the Z-axis.  I'm quite happy with the current set of printed parts and will probably continue to use them.

Friday, August 10, 2012

Optical Tomography Setup

As noted in a previous post, my Stochastic Tomography paper was accepted to SIGGRAPH 2012.  Last Tuesday I was in Los Angeles for the conference to present the paper, including present the synopsis in the conference 'fast-forward' to an appallingly large audience.  The photo below shows the seating but during the actual event it was standing room only. 


A bit nerve-wracking to say the least.  However it went well and after presenting my main talk to a MUCH smaller crowd, I'd like to post some photos of the setup that we used for the paper.  I should point out that this project actually did not contribute much to the capture setup, this was previously in place from work done by Borislav Trifonov, Michael Krimerman, Brad Atcheson, Derek Bradley and a slew of others.  My work on this paper focused on the algorithms primarily, but I thought people might be interested in a quick overview of the tomography capture apparatus.

The goal of the paper was to build 3D animated models of mixing liquids from multiview video.  To accomplish this, we used an array of roughly 16 Hi-Def Sony camcorders arranged in a semi-circle around our capture volume to record video streams of the two fluids mixing.


You can see the cameras in the photo above, all focused on the capture volume which is inside the glass cylinder.  Each of these records a video of the mixing process, producing 16 streams of video that look more or less like the photo shown below:


You can see one of the cameras peeking out at the right side of the frame.  The cameras are controlled by an Arduino based box that talks to each camcorder using the SONY LANC protocol.  This is an unpublished protocol used by SONY editing consoles, however it has been reverse-engineered by others to allow people to control SONY equipment.  We implemented this protocol on an Arduino, which allows us to start all the cameras recording, turn them on and off as arrays, switch them between photo and video mode and so on.  Unfortunately we can't easily set the exposure levels, transfer files to and from the device, instead we have to painstakingly do this by hand through the on-camera menus, which is error-prone and time-consuming.

The two fluids we use are water, for the clear liquid, and Fluoroscein-Sodium fluorescing dye for the mixing liquid.  This fluorescent dye is available in a powder that is soluble in water, which allows us to perform several types of capture.  The image above is dye powder dropped onto the surface of the water, this mixes with the water and is slightly denser, forming the Rayleigh-Taylor mixing process you see in that shot.  We can also pre-mix the dye powder and simple pour or inject it into the domain, this was the process used for the following two captures that were used in the paper.



This shows an unstable vortex propaging downwards, leaving a complex wake.  I recommend watching in high-def (720p or 1080p).  The next is alcohol mixed with the dye powder, injected into the cylinder from the bottom.  Since alcohol is less dense than water, it rises under buoyancy, mixing as it goes.



In the video above you can see a laminar to turbulent transition as well as lots of complex eddies that form as part of the mixing process.

The captures are illuminated with a set of white LED concert strobe panels.  These panels serve two purposes. First they let us get LOTS of light into the scene in a controlled fashion.  Second we actually use a strobed illumination at about 30Hz to optically synchronize the cameras and remove rolling-shutted shear effects.

All captures start in darkness so we can tell the time offset from the start of the video to the first frame where there is significant illumination.  In fact we can do better than alignment to a single frame, since with the rolling shutter used by these cameras, we can actually determine the first scanline that is exposed.  Using a 30Hz illumination pattern, we can also determine the exposure setting of the camera by looking for the last scanline before the light goes off again.

We then have a rolling shutter compensation program that scans through each video and reassembles a new video from the exposed and dark scanlines.  The result is a set of videos that are optically synchronized and that have minimal shearing introduced.

This gives us a set of input data, however we also need to perform some geometric calibration of the scene in order to know from what angle each video was recorded and to be able to obtain the ray inside of the capture volume that corresponds to every observed pixel.

To do this, we use an optical calibration library called CalTag that detects self-identifying marker patterns similar to QR codes in images.  We print a calibration target on overheard transparencies and mount this pattern to a 3D printed calibration jig that is placed in the glass cylinder.


This jig fits tightly in the cylinder and is registered with a set of detents that fit into recesses in a registration plate that is glued to the inside of the capture cylinder.  The marker pattern that you see in the photo above is also registered to a set of registration tabs.  We have a calibrated pattern on the front of the target as shown above, but also on the back.

When a camera takes an image of this jig after placing it into the capture domain (filled with water), an image similar to the following is obtained, although generally with far less blur due to condensation.


CalTag can then give us the corners of the marker patterns, which can be interpolated to associate with every image pixel, the corresponding 3D point on the calibration target that it 'sees'.  We then rotate the target 180 degrees to face away from the camera and take a picture of an identical and carefully aligned target on the back side of the jig, giving another 3D point for each pixel.  Connecting the points gives a ray in 3D space inside the cylinder, without having to account for any optical interactions between the interior liquid and cylinder.

We do this for every camera, by mounting the capture domain on a rotation stage, which is again controlled by an Arduino.  An automated calibration procedure rotates the stage and triggers each camera to image the front calibration plane, then rotates an additional 180 degrees to repeat the process.  The whole mess is controlled by a python script using pySerial, including the strobes, the rotation stage and the embedded camera controller.

This gives us the needed calibration data to express our scene as a tomographic inverse problem.  Here we look for the scene content that would reproduce the measurements (videos) we obtained, given a physical model for the scene.  In this capture case, the scene is simply emissivity adding up along a ray-path, so we get a linear inverse problem, that we solve using our new Stochastic Tomography algorithm.  The result is volumetric 3D fields that you can animate, inspect and slice through and re-render however you like, as seen below in the submission video.



Stochastic Tomography and its Applications in 3D Imaging of Mixing Fluids from al. et Hullin et al. on Vimeo.

3-Axis CNC Controller

In a previous post, I showed the single axis stepper driver boards that I sent out to be made by OSH Park. These seemed to be electrically fine, although it was tricky to properly test without the connectors and other components.  After a quick order from DigiKey, I had the bits I needed.


I'm pleased to say that these work as expected, allowing the microstep mode to be chosen by DIP switch, breaking out all inputs and outputs with screw terminals, and providing the connections needed for high and low limit switches.  I've assembled three of these and screwed them to a piece of MDF to serve as the basis for a 3-Axis CNC controller board based on an Arduino Uno and GRBL.






The start of this board is shown above. Before it's complete I need to add the power connections for the high-power side, along with the limit switches.  I have the GRBL firmware flashed onto the Arduino and have connected a few motors to this setup and everything works great!


Shown below is a closeup of the boards.  The screw terminals in the front connect the limit switches for the high and low endstops.  These have pulldown resistors and are connected to two of the screw-terminal positions on the logic side of the board (the two un-wired stops).  The remaining pulldown resistors are connected to the microstep selection pins, which are set by the red DIP switch.  On the right side of the board are the motor connections (the 4-position terminal block) and the motor power connections (the two position terminals).  All connections are with 3.5mm terminal blocks, which actually meet the power requirements for multi-amp 24V operation.  They also allow multiple connections to be made which allows the daisy-chain type wiring shown above.  The low-power side also has these connections since even though they are not needed it's nice to only need one screwdriver to do the wiring.

I'm quite pleased with my first attempt at getting a board made.  It worked first try, the quality of the boards is excellent and I think these drivers can form the basis of a good many other projects.

Sunday, July 29, 2012

Prusa Build III

In the previous posts you can see the assembly of my Makerfarm Prusa up to the nearly complete frame.


I then installed the heated bed, electronics and extuder, making it look much more like a Reprap.  These were pretty simply assemblies, so I didn't bother taking progress photos.  The result is the hot-mess of wires and cable ties you see above.

Then the all-important first-turning-on, where you hope that you haven't connected something wrong and end up releasing the magic blue smoke that makes electronics go.  Amazingly, no smoke.  Installing the firmware, I had to invert a few axes in the configuration as well as recompute the mm-per-step, since I had used the SAE threaded rods rather than the M8.  All went pretty smoothly.

Finally it became time to test the extruder.  Heating it to 225, for ABS, I clicked 'extrude' in pronterface.  It worked great for a moment, then jammed, started skipping and chewed almost all the way through the filament.  So I increased the preload on the extruder: same result. So I increased the temperature: same result.  So I increased the current to the extruder stepper: same result.

At this point I was running out of ideas, so I piled the whole thing in the car and took it down to VHS.  There I asked the resident printer expert to take a look.  He spent some time looking at it, flipped my Y-axis mounts to give me more build-volume, disassembled the extruder, added thermal paste, but still couldn't figure out what was wrong.

So I contacted Colin from Makerfarm.  Within about thirty minute he had written back saying that he thought the issue might be related to running the extruder too quickly.  This made sense given the symptoms, good extrusion intially, followed by jamming shortly after.  So I dropped the extrusion rate from 300 mm/min (!) to the suggested 30 mm/min, and it worked perfectly!  I then tested to see how fast it could go, up to about 150 mm/min without problem.

So then it was time to start printing.  I could not get the prints to stick and didn't have Kapton tape.  I used some painters tape, connected the heated bed and tried again and got the following, encouraging result:






It came unstuck during the print, but I was pleased to see something resembling the box that I had tried to print.  So I retensioned the X-axis belt and tried again:





Much better, actually pretty good.  Tweaking some settings in Skeinforge improved this, specifically the flow-rate parameters, which I found produce the best prints when set to about 0.8-0.9.  So I tried a more challenging print, from my gear-generation script:




That actually looks pretty darn good!  As good as the Makerbot Thing-o-matic prints from VHS, if not better!  There are some blobs that I have to deal with, particularly where contours start and end.   So overall, as it stands, the printer has gone from left to right:





Overall, a pretty good improvement.  I will continue to try to improve the print quality, hopefully this will become a useful prototyping tool for future projects!