Tuesday, October 25, 2011

3D Printer Build Post 1 (RepRap Prusa Mendel)

The long journey to building a 3D printer has been underway for quite a while now. With the complete set of parts ordered and much of the construction finished I decided to share the progress; outline my frustrations, and post about how you can benefit from my mistakes.

I have been building the printer for over a month; and the last batch of parts arrived early this week. What can clearly be said about this project is that you will underestimate it. The original plan was to get this working in six months. Once construction was underway; it seemed more like a month. It now looks like this could really take up to six months (to produce a quality 3D printed part). In this part of the coverage; I hope to outline the budget and basic build so far; finally going over some problems and warning points.

The budget for this printer is quite high. It is a mid-range open source 3D printer known as a Prusa Mendel. You can find the wiki for it here. I chose to start with the basics (more on this later). So here is the budget:
  • The starter kit $195.00 (from this ebay auction)
  • Rods - Threaded and Smooth, $68.17 (McMaster.com)
  • Motors - Pololu Nema 17 x 5 $104.70 (Pololu.com, item link)
  • Hot End and Ramps 1.4  $364.00 (Ultimachine.com)
  • Wire, digital caliper, etc. ~50.00
So the total budget so far for the printer is ~$782.00

Here are the basic pictures; showing various steps of the frame building process. I cut the rods myself; making a jig according to this page. I then used the electric saw to get through them quickly.


At this point I lost my memory card; so there is a gap of missing pictures. They weren't very interesting anyways. The pictures resume with motors in place and the y-axis completed.

The extruder which feeds plastic into the hot end has to be 'hobbed'; basically you give it teeth so that it grips the plastic. The extruder can then force plastic into the hot end which acts as a glue gun (but for plastic). I hobbed by hand. Following that sparks are some pictures of the extruder; which came together easily.

With the extruder completed, tested, and mounted - the basic build was complete. I didn't want to start wiring things up until I got some chores out of the way. So the second picture below is my converted ATX power supply. I may do a complete post on this; as it is very useful for anyone doing robotics/arduino. The short and sweet? Connect the green to ground; then all of the orange (3.3v), red (5v), and yellow (12v) become easy power. The other wires can be removed.

Before putting the top back on.

At this point I have begun working on the wiring and getting everything to the final setup. There is still a ton of work to do however and I do not think that my carriages move as freely as they should. That said; I did want to share some of my sticking points in case you are considering this venture for yourself. So; consider these points before you start and you can benefit from my troubles.
  1. A dremel is NOT an optional tool. You will need to correct parts, cut parts; etc.
  2. Have a large work area available; I am using both my full desk; a table I purchased and a couple shelves.
  3. Have something to organize parts; similar to component bins. There are a LOT of nuts, bolts and washers.
  4. Have a small enough level; if your level is too big; it doesn't fit against the rods and you will have trouble leveling. You could also have a spacer ready; but remember you need to level various parts.
  5. A digital caliper is highly recommended for accuracy.
  6. Plan for the 'breaks'; you will have two glue steps where you glue and walk away. You will also apply ceramic to the hot-end and it should sit overnight.
  7. Have your PSU ready before you attempt to build your hot-end; you will need the +12v for curing.
 There are also various problems I'm running into that I can't seem to find resources for. Be wary of these; or if you know the answer - let me know!
  1. How does the hot end attach to the extruder? I really cannot find this!
  2. Preparing the default bed; do I just put aluminum foil on it? All documentation seems to simply skip this and references the 'prepared print bed'.
  3. I will know more tonight; but you apparently need a linux box to build and upgrade the firmware. I will update this entry based on my findings.
  4. How should the Arduino Mega be powered; usb?
That wraps up this post. Hopefully my next post about this will include a first print and more information to help you build your printer.

Saturday, October 15, 2011

Arduino Robot 3 - Part 1 - Reflectance Sensor

This is the first part of my post covering my creation of the line following Arduino robot. In this post I will talk about the costs; setup and preparation for creating the robot. I will also discuss a few different approaches to line following that I explored. We will get the sensor attached to the robot and retrieving data. In the next part, we will cover the final approach used; tour the code, and see the full video.

The budget for this tank is quite low, because we start with Robot 1. I chose to add a single reflectance sensor to the bottom of Wandering Tank; and remove the wall avoidance equipment. So, the budget:
So Line Following Tank has an estimated budget of $105.00 to build.

Since there is no need for the parts from Robot 2, the cost is very low. I would suggest coming up with a few other things to order so that you don't pay more in shipping and handling than for the sensor. I ordered a couple sensors and of course, more of these. Time to build!

Building this robot is not as simple as ordering the parts. I could find no reliable way to attach the sensor to the bottom front of the robot. I ended cutting a strip of double sided tape up into squares and stacking them to a desired height. Wiring the robot is simple; I used digital pin 5; which is pin 19 on the Arduino. Here are some pictures as a guide:

Soldering the wires to the sensor is easy. You are simply giving it 5V to operate with, grounding it, and giving it somewhere to send data. You must add the Arduino Library For Pololu QTR Sensors to your Arduino IDE before working with the sensor.

In preparing to create the line follower; I had to do a lot of research and of course make sure I was ready to use the sensor in code. Using the sensor in code is easy. I will show the code to use the robot as a color detector. The speaker will make noise to reflect (get it?) the color seen by the sensor. As I wave the robot over a dark line; the frequency will change.

 * George Frick (george.frick@gmail.com)
 * October 2011.
 * Arduino Robot 3 - Sensor Wave Test
 * This isn't a robot; but uses the build line following robot to test the reflectance
 * sensor. The robot starts up and beeps to notify the user to calibrate (wave robot
 * back and forth over line), then beeps again before starting. Once started the robot
 * calls buzz with the detected color value as the frequency.
 * This tests runs continuously. The user may choose to view Serial output.
#include <PololuQTRSensors.h>

const int qtrPin = 19; // pin 5 as digital is pin 19
const int buzzerPin = 14;

// create an object for your type of sensor (RC or Analog)
// in this example there is one sensor on qtrPin
PololuQTRSensorsRC qtr(( unsigned char[]) {qtrPin}, 1);

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps  
  pinMode(buzzerPin, OUTPUT);
  buzz(buzzerPin, 1000, 100);
  calibrateQTR(); // Wave the sensor accross the color specture during this time!!!
  buzz(buzzerPin, 2000, 200);

void loop() {
  unsigned int a[] = { 0 }; // One sensor!
  qtr.readCalibrated(a);    // It will fill the array from the sensor array.
  Serial.println(a[0]);     // Use a[0] to get the only entry.
  buzz(buzzerPin, a[0] - 50, 100); // the minus 50 is arbitrary.

void calibrateQTR() {
  // start calibration phase and move the sensors over both
  // reflectance extremes they will encounter in your application:
  int i;
  for (i = 0; i < 250; i++) {

void buzz(int targetPin, long frequency, long length) {
  long delayValue = 1000000/frequency/2; // calculate the delay value between transitions
  // 1 second's worth of microseconds, divided by the frequency, then split in half since
  // there are two phases to each cycle
  long numCycles = frequency * length/ 1000; // calculate the number of cycles for proper timing
  // multiply frequency, which is really cycles per second, by the number of seconds to 
  // get the total number of cycles to produce
  for (long i=0; i < numCycles; i++){ // for the calculated length of time...
    digitalWrite(targetPin,HIGH); // write the buzzer pin high to push out the diaphram
    delayMicroseconds(delayValue); // wait for the calculated delay value
    digitalWrite(targetPin,LOW); // write the buzzer pin low to pull back the diaphram
    delayMicroseconds(delayValue); // wait againf or the calculated delay value
/* EOF */ 

In the video; you will notice me waving the robot in the beginning with no sound. This is during the calibration phase when you want to show the sensor different colors. Once calibrated another beep announces the 'wand' is ready.

The final discussion is the approach to line following. With only one sensor; it gets tricky. If you have more than one sensor; you can find the line and keep it between two sensors; etc. With one; you have to make an effort to say on the line. As of writing this; I am aware of a few approaches:
  1. Drive forward if on the line. When the robot leaves the line, sweep left and right until the line is found again; then continue forward. This has several problems; the largest of which is a simple 90 degree turn; in which the robot may end up going back along the line.
  2. Constantly sweep back and forth. I have seen this implemented on Youtube and other places. I don't like it and I don't think the robot should have to 'dance' in this way.
  3. I am working on this :-) Depending on how it turns out; it will be the next post. Otherwise I may settle for one of the other two approaches.
So; the robot is built and the code works. It's time to implement approaches to line following and see what kind of results I can get. The follow up post to this will share the finished robot and code!

Saturday, October 08, 2011

Resuming My Robot Work With Bonus 3D Printer Project

Well after a long break of working on the house; this blog will be returning to a primarily robot programming focus. My work on the house is shared elsewhere...

So; I've resumed work on my robot and added a second Arduino to my arsenal; this way I can prototype ideas without disassembling the robot. I have used it to go through the tutorial for the TFT screen:

The new Arduino is an UNO; they come in much more sophisticated packaging than their predecessor:

That is a sticker sheet on the right and a EULA in the middle. The first nice thing to notice about the UNO is it auto switches the power source. You can see this difference and other slight changes in the comparison here:

So; I will post about the robot again when line following can be demonstrated and the code is ready to share. I hope to share two versions (with and without TFT info printing).

With that; the other exciting news is that I am building a 3D printer; which I will document here and share my problems (and answer any questions the best I can). I hope to be able to print robot parts in the spring; as I have more than once been held back by the ability to mount parts. It has driven me towards switching back to Lego; which I do not want to do. The printer being targeted is the RepRap Prusa Mendel.

I have made first acquisitions and the plan is to build the printer for around $600.00. The initial set of parts (the printed ones, etc) were purchased on Ebay; this guy sells them. I then purchased the rods (uncut) from McMaster; who I had never heard of, but find very awesome! The next purchase was the stepper motors; which I of course got from Pololu.

The build has not been started yet; the parts need to be confirmed and some need to be cleaned up with the Dremel. There is also the cutting of the rods (ordered in 2 meter lengths). I'll close this post off with some more pics.

Monday, May 16, 2011

Back To Robotics - A Long Awaited Update

There has been next to no progress on my robot; this has been due to buying a house and realizing I would need to do a lot of work on it. That aside; I now have a work bench coming together and the time and money freeing up to get back to it (yay!).

There is some news; there is now a local Maker Space getting started up. This may provide tools, resources and people to work with. I am very excited since I live nearby (about a mile away); though there is no way I could currently afford the membership fee. We will see; as I plan to stop by one of their open houses.

More exciting; I have purchased a part. I saw the part come up on my reader feed and realized it was cheap and would go quickly. I refer to the 1.8 inch 18 bit color TFT LCD display with microSD card breakout released by adafruit. At only $25.00 I knew they would be gone in an instant so I just went ahead and purchased one! My goal for this is to use it for output from the robot; debugging output in the short term and more interesting output in the long term. I'm not sure what to do with the SD card slot; but it is great to have it.

So; when I make progress on my robot, including adding the TFT as output in regards to what the robot is doing; then I will post with haste here! I do have a new idea for the line following so that it isn't so jerky, and I'm excited to try and implement it. For now; here are some pics of the screen as it arrived.


Thursday, May 12, 2011

Improving your Netbeans Java Class Template And Including A License File

Well, working with Netbeans I have a problem occur over and over. One of those annoying programming tasks where you always make the change but are too lazy to deal with underlying problem. Today I decided to address on of them. Every time I create a class in Netbeans, there is a comment that appears at the top:
 * To change this template, choose Tools | Templates
 * and open the template in the editor.

My co-workers leave this in place; I am OCD about removing it every time. I don't like four lines of useless code at the top. This morning I decided to change this problem and maybe make my Java class templates a little better. I will walk through improving the class template, and adding the license file for display.

This is a stub class created before the changes:
 * To change this template, choose Tools | Templates
 * and open the template in the editor.

package com.something.somewhere;

 * @author GFrick
public class MyClass {
 // class here.    

We will start by creating a license file. You just have to create a file "license-company.txt" anywhere on your file system and fill it with your company license info. This can be any information you want in the header of all of your created Java classes. Netbeans has to be told about this file, so we choose Tools->Templates and then go down to the folder "Licenses"; highlight it and click "Add...". Navigate to the text file, choose it and click "Add". Now for any project to use this; simply open the project.properties file and add a line like this:


With this done, your license file should now appear when you create new files in Netbeans.

Now, we will improve the Java class template to include a little better javadoc and information at the top. Go to tools->templates again, find the "Java" folder and the "Java Class" item under it. You will want to copy/paste this to make a backup so you have the original. The original looks like this:

<#assign licenseFirst = "/*">
<#assign licensePrefix = " * ">
<#assign licenseLast = " */">
<#include "../Licenses/license-${project.license}.txt">
<#if package?? && package != "">
package ${package};

 * @author ${user}
public class ${name} {


We will add some additional information, namely date and encoding to convenience; the updated version looks like this:

<#assign licenseFirst = "/*">
<#assign licensePrefix = " * ">
<#assign licenseLast = " */">
<#include "../Licenses/license-${project.license}.txt">
<#if package?? && package != "">
package ${package};

* ${nameAndExt} (${encoding})
* ${date}
* @author ${user}
public class ${name} {


Now when you create a new class, a much nicer version of the template appears and there is no need to remove the top comment. Here is an example class created:

* Software property of Something Somewhere Companies. Copyright 2011.
package com.something.somewhere;

* MyClass.java (UTF-8)
* May 12, 2011
* @author gfrick
public class MyClass {

There are of course plenty of other things you can add to the template. They are written using FreeMarker; so you can script them up to your desire. There are a list of variables here: Netbeans Template Variables

Wednesday, May 04, 2011

New Site For Robotics And Electronics Supplies

I was browser my Google reader feed and a great site popped up. I've checked it out and once I get my work bench set up and get back to my robot; I'll definitely be ordering some things from here. I wanted to spread the word about the site: http://www.inmojo.com/

They have lots of RFID, Robotics and just Arduino stuff that I think would be cool to play with.

I hope to get a full post up soon.

Monday, April 18, 2011

Installing the Sun (Oracle) JDK on 64 Bit Ubuntu From Shell

I had a bit of trouble installing the JDK via the shell; but I eventually figured it out. Seems a large part of the problem was differences in 64 vs 32 bit Ubuntu. I wanted to use the apt-add-repository, but had to figure out that it requires some python libs. Here are the simply steps if you have been looking:

  1. sudo apt-get install python-software-properties
  2. sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
  3. sudo apt-get update
  4. sudo apt-get install sun-java6-jdk
After that, you should have javac/etc.

Create a "GG Button" With an IOT Button on Discord

I was having some fun with my internet button (found here: https://store.particle.io/collections/shields-and-kits), and also working on some...