Thursday, March 24, 2016

Building a 3D Printer and My 3D Printing Adventure

I can't believe it was almost 10 years ago since I first heard about the RepRap project. It is an open source hardware project aims at building a self-replicating 3D printer. The concept of open source mechanical hardware was new at the time. I badly wanted to have one but I could not afford it. The kit was so expensive at the time. If I remember it right, the kit was being sold for 4,000 USD. It was way beyond my ability to afford. It's the price of a second hand car. After all, I was making only a few thousands pesos (Php) at the time.

Two weeks ago, while I was checking for the status of my online purchases at AliExpress, an advertisement came up about a 3D printer called Delta. It caught my attention so I clicked the ad which leads me to a product on sale about a something called Kossel Delta 3D printer. It looks familiar, it looks like a RepRap design but it's different. There is no Cartesian rods, instead, it has a triangular frame wherein three stepper motors are driving a complex kinematic linkages (I have a little background in mechanical engineering and robotics so I understand the kinematics of the machine by looking at it). It was interesting, because it's compact and the kinematics are quite interesting. What was even more interesting was the price. It was priced at $200 US. I couldn't quite believe it at the beginning so I started googling for Kossel Delta and Google brought me to the RepRap page. This is when I said "I knew it", that's why it looks like RepRap design. RepRap design has evolved a lot for the past 10 years. That's the good thing about open source. So I went back to AliExpress and clicked the "Buy Now" button.

Few days have past and I received a big box at my front door. Inside is the 3D printer kit. The kit's main parts are the 4 stepper motors, the aluminum rails already cut in correct lengths, the Arduino based motherboard,  and the 3D printed plastic parts.




Mechanical



The kit arrived on Friday morning so I spent the whole Friday planning about my Saturday, which is "To start building the printer". The first thing I did on that Saturday was to take a coffee and a very quick breakfast as I couldn't wait to see what's in the box. I laid out the parts on the living room table. I couldn't find a build manual in the package. There was 1 sheet of paper listing all the parts that is in the kit but there was nothing about how to assemble it. It did not stop me from building the frame though. That's because I found a youtube video of a guy building his own similar kit. Not exactly the same but it's also based on RepRap's Kossel mini design.


Without an build instruction manual, it was quite difficult to know which bolts and nut I should use for which part. There are more than a hundred of them. But I manage to guess it right. The size of the hole is a hint but the length was quite a lucky guess.




Electronics

I have had a few help form 2 guys specially for the installation of timing belts. I finished the mechanical parts of the build in the afternoon. Then I immediately started working on the electronics side. I installing the micro limit switches for all the end stops. there was one extra limit switch that got me scratching my head. The guy in the youtube video did not have it. He only has 3 limit switches. It took sometime to realize that it was for the Z axis auto leveling feature. Which was not there in former versions of Kossel. There was a fulcrum mechanism in the hot-end assembly that I was wondering about what it was for while I was building it. Not I know that that was for the auto-leveling feature. Auto-leveling is a feature for compensating mechanical alignment in the software. The printer will actually try to find where the base (print bed) is on a certain XY point. The firmware can then do adjust ment in the Z axis to compensate for the mechanical error. Without this, you will have to manually calibrate the printer everytime you print to make sure the the position of the print bed is stil the same as before.

I attached the 4th limit swith to the obvious holes in the hot-end assembly. The design was quite impressive. In other printers there is a dedicated mechanical lever that are used to detect the printbed while some printers use expensive inductive proximity sensors. Well, this printer uses the nozzle itself as the sensor. Isn't that cool?

After connecting everything, stepper motors, limit switches, heater, thermistor and cooling fan. Voila!!! It's time to give it a brain.




Firmware

What was funny about this part was that there was an SD card included in the kit that I always assume to contain the firmware source code. I did not touch it until the mechanical and electronics are ready. Indeed, it did contain the firmware but it also contained a PDF file with all the complete instruction for assembling the kit documented in it. Whew, I would have saved some time if I knew this file was there in the SD card.

The firmware included in the kit is the Marlin firmware. It's one of the firmare maintained in the RepRap community. The firmware is written in C, of course the printer is run by Arduino microcontroller unit (MCU). I flashed the firmware to the board and tested right away and of course it did not work perfectly. It printed way to high above the print bed. The extruder motor is not working, the fan is not working.




I went through the documentation of marlin and learned that I have to configure the firmware. I am putting a brain to a new body, I need to tell that brain about his new body. There was a quite OK documentation of the Marlin firmware configuration on the RepRap wiki. Every build is different, because of the way each person decides where to put the limit switches. This is why we need to tell the Marlin firmware the dimension of the printer, the kinematics of the printer and the components installed to the printer. Foe example I need to tell the firmware that my printbed is not heated so that the printer will not wait for the printer bed temperature sensor data before printing. After few hours of calibration and multiple test prints, I finally got it. I couldn't wait to see it print an actual object so I tested with a 3D design object that is a part of the printer. The vertical rollers.

3D Printing

3D printing is not easy, I knew this from the beginning and from watching videos of people 3D printing objects using a printer they built. It's not a simple press of a button and voila you have your physical object. 3D printing takes minutes hours and sometimes days depending on the size and quality of the print. My first print was a complete failure but that's normal.
First attemp
Second attempt





The second print was slightly better and the 3rd print was okay. It's then time to actually feel the true experience of 3D printing. Its the experience of touching a physical object with your hand in the real world that you have created in the virtual world with your mouse. This feeling is addictive, it makes you feel powerful. It makes you feel like you can create anything. It trigger the same part of the brain that is stimulated when writing a software. But the reality is not really like that. 3D printers have their limitations, especially this FDM type of printer. It cannot print overhangs, it has a limited print volume and cannot print bigger than that volume, it cannot just print any material, etc...

I have done 3D designs before in the university with Autocad. I have also taught a basic mechanical drafting course in the university using Autocad. But that was 11 years ago. When I checked for CAD software for 3D printing, there now lots of options unlike 11 years ago where you only have a handful. So I needed to make a choice on which software I should learn now. Because I think Autocad is just to expensive for a hobby. I messaged a friend in FB who used to do 3D designs for the Virtual World "SecondLife" to ask for his opinion. He suggested Blender because it's open source and it's full featured. But when checked out the software, it seems like there's a lot to learn, too powerfull for a just simple 3D designs and I don't have a lot of time to re-learn my 3D design skills. So I went through the community forums and learned about Autodesk's 123D Design. It's free, cloud-oriented 3D modeling application with basic features for 3D design/modeling. I found several YouTube videos about 123D design tutorials, I went through them and in 1 hour, I am designing 3D objects. The first thing I designed was a wireless charging dock for my Lumia 950 XL. It's not a very common phone so I'm sure I won't find any commercial products like what I am about to design.
It was cool. I finally experienced hold a thing in my hand that I designed in the virtual world. I couldn't stop printing and designing things after this. I created an iPhone dock and sound amplifier for my girlfriend. I enhanced my printer's performance by printing new parts like a support for the print bed, because I didn't like the glass sitting on top of the aluminum rail. I printed a filament spool holder so I could get rid of the wine bottle rack that was holding my spool.


I experimented on multi-part prints by designing object that are bigger than the print bed, print them part by part and designed them to be joined later after print. I experimented on watertight prints by configuring the slicer to print thicker walls and proving it by printing a self-watering plant pot. I experimented on airtight prints by printing a sopranino recorder flute that sounded very bad (I will print a better one tomorrow). It's fun and rewarding. 3D printers are for sure a must-have DIY tool for makers.

3D Printers

3D printers are CNC machines. CNC = Computer Numerical Control machines. I have already encountered quite a few CNC machines before such as CNC milling and CNC lathe machines in factories and machine shops . CNC machines understand sequence of instructions which it will translate to physic movements in a 3 dimensional space. They are not smart machines they simply execute a series of commands called GCodes of G language which is an ISO standard for controlling robots in the manufacturing floor. 3D printers are the same. This printers have no idea what kind of object they are actually making/printing. They are simply following a sequence of instructions to perform. So who does the intelligence of preparing such instructions to build an object?

The Slicer

It is called the Slicer program. There are many slicer applications out there and Slic3er and Cura are the commonly used ones I think. What these software do is literally slice your 3D object into thin layers of a fraction of a millimeter and figures out how to print such layer. Then the final output of these software is a binary file contain a complete set of instruction that the 3D printer needs to execute in order to print the object that was sliced.

3D Printing Problems and Solutions

One of the issues I encountered after a few prints, and is the most common problem in 3D printing is how to keep your printed object stick to the base. Some people use tapes and glues while others use different materials for the base print bed. My print bed is made of glass, I tried putting a tape of top of it but it's just not nice to put tape everytime and it did not solved my problem completely. My problem was that after few layers is printed, the corners begin to curl up as it cools down. It lifted the tape up as well and I ended up with a warped corners. My solution to this is a bit weird but works perfectly, thanks to the RepRap community. I now am printing directly to the glass without using any tapes. But before printing, I spray a thin layer of hairspray (something that contains vinyl). This will serve as a water-washable adhesive that will keep the printed object in place until the print is complete. It completely solved the warping problem, thanks to my girlfriend's hairspray. :)

Another problem I encountered was the warping of overhanging parts of the object. I noticed that the overhanging parts tends to bend down, because there are no objects supporting under them. This results in an ugly curly lines of plastic in the printed object. The solution was a $20 USB fan. When I placed a fan facing the printed object while it is being printed, it makes the curly overhang problem go away. This is because the fan cools down and hardens the plastic faster right after it is extruded out of the nozzle.

There are a bunch of small problems that I encountered, like the loose ball and socket joins in of the tie rod which I solved by tying up a rubber band between the two rods to reduce the vibration. The rubber band serves as a vibration damper or the shock absorber. It also resulted to slightly better prints as the backlash in the bearing was eliminated.

I'm sure there will be a lot more problem that I will discover, but that's normal. That's the good thing about having a machine that you build yourself, because it's hackable, you can easily modify the design and rebuild or fix the machine anytime without breaking any warranty. :P 

To conclude, here's a short video of the printer in action.


Wednesday, March 9, 2016

Raspberry Pi Hadoop Cluster


I am currently in the process of learning Hadoop architecture, administration and the MapReduce programming model. I started reading about Hadoop and took free online courses but there is something missing. I wanted to try out what I read or what I was told on those training. In some exercises in the training a VM was used as a single node Hadoop server. But for me it doesn’t make sense, so I tried out setting up more VM and configured them into a Hadoop cluster. But still the experience was not very satisfying because it lacks the touch of the hardware. I wasn’t really running a cluster but simply just a bunch of virtual machines connected together in a virtual network. So I thought “How about I build a cluster of cheap computers.” In fact, that’s what Hadoop was designed for, to run on a cluster of commodity hardware. I tried googling around about cheap cluster computer and found a few blogs and videos about guys who ran MPI and Hadoop on a mini cluster of Raspberry Pi boards. So I decided to build my own mini cluster of Raspberry Pis. After all, the best way to learn new things is to get your hand dirty.

There are a couple of Raspberry Pi boards laying around my desk at home. I used them in some experiments before. But I needed more, so I ordered 3 more of these boards. Raspberry Pi is a S$50 single board computer with ARM7 1Ghz  dual-core CPU, 1GB of RAM and a microSD slot for storage.





I also bought SD cards and, USB power cables, an 8-port network switch and a high-current USB power supply/charger. Luckily I was able to find all off them locally in the neighbourhood shops except for the Raspberry Pi which I ordered online and received the next day.

I started thinking about how to clump this boards together in a rack-like structure where it is easy to cable them up to a network switch. I found few ideas online about using some stand-off bolts and nuts and acrylic boards to stack them up together. The problem is I don’t have these materials so I started walking around the house to come up with ideas and to look for materials. The mounting holes in the Raspberry Pi are 2mm wide so I started looking for bolt and screws of this size but didn’t find any. Then I went to the laundry area where I found a wire-made clothes hanger. The wire core metal is around 2mm diameter covered with a PVC plastic insulator around 1 mm thick. I grabbed it and decided to build a mini rack out of it. I created a half round loop and literally stitched the boards together.


The network switch I bought is powered by a 5V power supply at 600mA so the USB power supply can actually power it.
I downloaded a Linux distro called Raspbian Jessie it is a lightweight variant of Debian linux intended for headless Raspberry Pi server. It’s a stripped down version of Raspbian Wheezy without the UI. I then updated it with latest libraries and installed Java 8 JDK.

I followed the steps by that was described in this blog but with some extra steps to configure a second interface card with a Wi-Fi dongle and voila. I now have a Hadoop cluster running.





I later bought a set of acrylic stackable case to make the rack more stable and look good. I stripped out the board of the cheap network switch (I bought online for $7 from china) and mounted it the one of the acrylic stackable case so it will look uniform. Now I am hadooping with this little beast. I later upgraded to Hadoop 2 and installed Apache spark for future Apache Spark experiments and adventures.

Popular