This entry kicks off a series of posts that record my building of a starter CNC machine. Using OpenSCAD, I had previously explored various alternatives for size and materials. See Modelling a Starter CNC. I found that eventually settling on only one set of dimensions, materials and configurations can be surprisingly difficult, because of the many alternatives. However, the selected design appeared to embody the best trade-offs between needs, performance, budget, and my ability to build the machine given the tools that I currently possess.
By following these posts, you might be inspired to build your own machine, as well as learn from some the pitfalls that I find along the way.
Settling on the Design
The picture above shows the design with the dimensions that will be used.
The base, the X axis frame is 39 x 26 inches. The Y axis, which holds the table, is about 27 x 18 inches. The Z axis, on a column to raise it above the other two axes, is about 18 inches.
The table is 36 x 13 inches and the Z axis can reach about 95% of it. In addition, because the machine is not enclosed, if workpieces are greater than the platform size, theoretically the work can extend beyond either end or toward the front.<< more >>
Designing a do-it-yourself (DIY) CNC machine is an interesting challenge, solved by navigating the thicket of desires, needs, abilities, and, of course, budget to arrive with a machine that presents the best mix of all of the above. By modeling the parameters, you can explore the space of possible configurations that might best match a reasonable course of action.
Generally speaking with machining, the best machine is always the next size larger than what you have. By definition then, the best machine is always slightly out of reach. I cannot hope to solve that problem. However, I expect to create one that will be a sufficiently good test bed to create some good work and gain some experience. This post is about designing an effective machine, not the best machine.
A few years ago, I became interested in robotics, automation, and the practical implementation of intelligence in real-world objects. Having a software background (hedge funds) but lacking experience with the creation of real objects, I had little idea how machines were put together, the forces involved in movement, and how to actually make real things.
So, in the last few years I have learned to machine manually, taking a number of excellent classes on machining and CNC at the local community college. And, I bought and rebuilt an old South Bend lathe from the ground up. My current equipment is fine as far as it goes, but I find that I am still astonished at how long it takes to make a prototype.
Finally, I concluded that it is past time to move to the next step and start using CNC equipment.
The Modeling Process
Using OpenSCAD, one can create each part that would be used. By using a combination of parameters and fairly standardized parts a<< more >>
Dimensioned Drawings with OpenSCAD
OpenSCAD is an open-source program used to create 3D objects. Part of its appeal stems from the form of input to create the objects. Unlike some other 3d programs such as Blender, the means of input is essentially a written program that specifies the objects, placement, rotation and other features. By creating a small program, the object can come to life with full control of the characteristics of the object from a text level. That means less messy tweaking on the screen with the mouse and fudged dimensions.
However, suppose that you would like to go into the workshop and create your new creation with manual machining equipment? You quickly run into a problem: A lack of an annotated engineering drawing.
This program represents a first pass at enabling dimensioned drawings. While by no means complete, useful work can be performed with the modules included here.
The approach uses a top view in OpenSCAD with all of the dimensioned lines and text on the xy plane. Combing multiple views of your object in various projections and translations with dimensioned lines overlayed on a plane just above your object will give the illusion of a dimensioned drawing.
The image below shows a portion of the previous image, still primarily a top view, but rotated to break the illusion of a flat drawing.
Dimensioning Elements Available
A number of elements must come together to implement dimensioning. There must be lines, some with arrows, and some without. Written annotations must accompany the lines to provide dimensions and other written descriptions. In addition, there are a number of conventions associated with annotations and a partial implementation of such functions are included.
Getting Started<< more >>
This post records a minor success on my computer vision project training a LeNet-5 style convolutional neural net to recognize a stylus. The structure of a convolutional neural network is designed to automatically generate features from the image that are significant to the detection of categories.
The object of the game for my project is to be able to examine any given patch in an image and detect the presence of the stylus. And, if the stylus is detected, then determine the dimensions and location of the stylus. While categorization was not too difficult, the regression portion determining the location was/is problematic.
The neural net was created using PyNeurGen with modified classes for Convolutional and Subsampling layers. A StochasticNode class created for drop-out nodes simulates unreliable sensors. Basically, drop-outs are a method of regularization. At some point I will add those classes to the PyNeurGen project when the code settles down.
My initial approach used an output that signified category and location simultaneously, reasoning that the same inputs are going into both calculations. If the stylus was not detected, all the location coordinates would be 0. If detected, then draw the outline.
However, all too often, the tentative lines that appeared were erratic. The network was deciding for each and every point, whether (1) a stylus was present, and (2) the specific location of the point or output a zero. It makes more sense to detect the stylus presence, then having that belief, calculate the location.
Possibly by running additional epochs, the problems would sufficiently dissipate, but intuitively it seemed like a poor approach.
Eventually, it occurred to me that a better structure added an additional output layer. In the new format, only the two categorization nodes would sit in the former output layer. Then, when using that a priori determination of category, the category nodes would inform the location nodes without ambiguity.
In a sense, the network should be viewed as two networks, category and regression, with sparse links between them.<< more >>
When trying to find the location of an object on an image, one method matches points of an object that you have found with a template of points that sufficiently define the object. This post is a short description of a method for matching called the Procrustes distance using Python.
The Procrustes distance is named in honor of a story from Greek mythology. Procrustes was a son of Poseidon, a smith and bandit who lived in a cave. As a smith, he had made an iron bed. He would invite travelers to stay with him, and travelers could sleep in the bed.
However, Procrustes wanted the visitor to be the exact length of the bed. Fortunately, being a resourceful smith, he made tools to stretch the hapless visitors limbs if they were too short, or he would lop off the extra length of legs if they were too long.
Apparently, there was also a possibility that he actually had two beds, so that he could select the bed that was most ill-fitting. This does fly in the face of my OCD theory. In any event, Theseus eventually came along and put Procrustes out of his misery.<< more >>
An updated version of PyNeurGen which is Python Neural Genetic Algrorithms, has been uploaded. This software package implements a pure Python version of neural networks and a version of genetic algorithms, grammatical evolution.
It has been awhile since the last update. A major portion of the work entailed writing unit testing for the various modules. While some testing was done originally, in the intervening period I have developed a much greater appreciation for test functions, and so I went back and increased the coverage to somewhere around 90%. Some refactoring was necessary to break up functions into smaller more easily testable chunks.
In addition, some functions are improved. I reworked the stopping criteria for grammatical evolution. Normally, the determination of when to stop the evolutionary process revolves around when the figure of merit, the fitness value. The fitness value, generated by the process for each genotype, must become sufficiently great or small, depending upon the objective. When the hurdle is reached, it is time to stop. The other typical reason to stop the process is when a maximum number of generations has been reached.
PyNeurGen now enables custom fitness functions that among other things can enable an evolutionary process that tries build a distribution of solutions. Suppose that the fitness value is only a loose proxy for what you really want to do. In such cases, it may be that all of the fitness values in an upper range could signify genotypes that are suitable for that purpose. In situations like that, it makes more sense to think of building a population where, for example, the upper quartile must be above a hurdle fitness value. With the custom functions, that can be done now. In fact, any distribution of fitness values can be used as the stopping criteria.
Recently, I had the opportunity to visit our coffee roaster, Diantha's Coffee, a wholesale coffee roaster here in the San Francisco Bay Area, where I could see first-hand the coffee being roasted. They have an old fashioned roaster with considerable charm that has manual controls.
It turned out to be an interesting opportunity to apply machine-learning techniques to a novel process.
The Sound of Coffee Roasting
Roasting is in many ways a methodical process that takes skill and experience to get the right combination of mixtures of coffee beans, roasting temperatures, timing, and rapid cool downs.
One part of the process involves determining whether the beans have been sufficiently roasted. Depending upon the type of bean and the roast desired, there are different cycles of roasting and cool down.<< more >>
The South Bend lathe is complete. There is nothing like getting a new piece of equipment, taking it apart and putting it back together again to develop an appreciation for it.
This post covers the final results of painting and assembly. We will start with the headstock and motor, move to the middle, the carriage, and finally look at the tailstock.<< more >>
Cleaning the Apron and Carriage came somewhat later in my process after I was able to clear some room. For those not familiar with lathes, the terminology can be confusing. Ultimately, the point of the carriage is to position a cutter relative to the work and enable the cutting to take place. work. It moves on the bed via gearing. The carriage consists of several components: the part that moves back and forth on the bed is the saddle. On top of the saddle is the cross-slide. On top of the cross-slide is the compound which enables other positional movements of the cutter. On the side of the carriage is framework that hangs down in the front. This is called the apron.
Here is the saddle upside down with the apron still attached. The cross-slide and the compound have already been removed. It has been cleaned to a degree, but not fully disassembled.<< more >>
This post covers painting the South Bend Lathe that was torn down in the previous post. After going through the process of cleaning the lathe down to the bare metal, it is very satisfying seeing it progress back to functionality. Like the teardown, it had to be done in stages because of the space limitations in my workspace. However, I rigged up flat areas in the workshop that could hold quite a few little pieces.
All the pieces took several coats. I also cut the paint slightly with a fluid designed to slow the drying process a little. The purpose of that was to help eliminate brush strokes.<< more >>
I had been interested in getting a lathe, and an old friend of my Dad's decided that he no longer needed his. It was perfect timing. Not only was it functional and reasonably sized for my workspace, it was also a little bit of history.
Being used to the cycle of electronics that rapidly progress from latest-and-greatest to junk, it takes awhile to adjust to idea something more than sixty years old and expect to do some viable work with it.
A Little Maintenance
Ok, it did have some grease and dirt on it, and a little rust too. I concluded that it needed some cleaning. Once I started using it, I realized that I probably would never go back and really clean it up. So, refurbishing up front seemed like the way to go.
What follows in this posting and in some following postings are some of the pictures associated with the process. The reason I document this, is for a couple reasons. First, it is intrinisically interesting for those who like machinery, but, also, for someone else who takes on this task, you might get some ideas of what lies ahead.
My approach was, first of all, to try to do no harm. So, if something seemed fairly difficult to get apart, I wanted to avoid damaging it if at all possible, and would try to err on the side of caution. Second, I would try to clean off the grease and grime, and save the original paint if I could. Third, if I was going to paint anything I wanted to match the original color as well as I could.
Finally, I was hoping to be able to put it back together correctly.<< more >>