Evolution of a Blog

This blog has evolved as I have as a maker. It starts at the beginning of my journey where I began to re-tread my tires in the useful lore of micro electronics and the open-source software that can drive them. While building solutions around micro-electronics are still an occasional topic my more recent focus has been on the 3D Printing side of making.

Monday, February 3, 2014

3D Printer - Comments on 'The Kit'

This is the final in a series of posts describing my adventures with 3D printing, and specifically, with a Prusa I3 RepRap Kit.   The first of the series is here.

There were some goods, bads, and uglies associated with this kit (as a review by Greg discusses on the 3D Printer Czar website). 

First, the ugly, NO INSTRUCTIONS!   I know that this is being worked on but kits should not be shipped without instructions unless there is a clear understanding by the buyer that this is the case.   Even then there would be some things that would have helped mitigate frustration.  First, provide some high quality photos of an assembled printer taken from multiple angles!  Second, provide some links to the most relevant variants of this particular printer where instructions do exist!

Next, the bad.   As Greg stated in his review there were some missing parts in my kit and the wrench that was provided was one size too small to actually fit anything!   In my case at least some of the missing parts might be due to a customs inspection as the printed parts bag was open and parts had spilled from it.  

Finally, the good.   This kit really does provide excellent quality parts for what I think is the best variant of all the Prusa printers and at a very reasonable price.   I could not find a better price for the Prusa I3 with Ramps (though I did find a comparable price with a Sanguinololu board.   I had also priced out the sourcing of parts outside of a complete kit and the end price would have been pretty close to the cost of this kit.   I would also say that the support of my build from Han in Hong Kong was pretty good considering that he is probably pretty stressed out by having to answer questions that documentation would circumvent! 

The bottom line...if documentation is available for this kit buying one is a no brainer.   Good quality parts, a great variant of the Prusa I3, and literally everything you need in one nicely packed box (save a region specific power cord).   The kit even comes with the glass for the heated bed which many kits do not. 

The above is what I wrote as a product review on the 3D Printer Czar's website.   Here are some more observations from my build:
  1. The smooth rods for the z axis are 1cm too long.  I had to drill a hole in the upper supports for the rod to protrude...otherwise it would have blocked the servo by the same amount.
  2. Unless I am completely off my rocker some of the areas where you think that a 10mm bolt should work...there is not enough room (as in the bolt does not protrude from the other side).  I have been forced to use the longer 16s and of course ran out of them and used some of the 25s which of course I then ran out of them.   I am getting some more bolts but I think it is another thing for you to look at. 
  3. The tie-ties provided don't fit any of the holes where they are intended to go.   I had smaller tie-ties that I was able to use but even these did not fit on the x-axis carriage.   I used bare wire here and wrapped it tightly to secure it.  I guess, in all these cases, I could have expanded the slots but I found the alternative tie-ties and wire easier.
  4. I was missing the parts that connect the z-axis servos to the threaded rod that drives motion on that axis.  I was able to do a work around using shrink wrap tubing and some cable ties that worked (and continues to work).
  5. The kit comes with the fan for the extruder but not the printed part that would allow you to mount the fan!   Not a problem as I printed one but a good note for the instructions...or just include that part!
  6. Pointing the buyer to a version of a firmware configuration file that matches this printer would be a nice idea!
Finally, even when the documentation is done, I would STRONGLY recommend that the Czar add a forum feature to their website.   All support requests should be channeled through that medium.  That way the questions that I ask may not need to be answered again as another user might see the answer.   In addition, while active in the build process, users might actually help themselves!  There are plenty of free alternatives out there that could meet this need.

3D Printer - Electronics (and Firmware) Integration

This is the second in a series of posts describing my adventures with 3D printing, and specifically, with a Prusa I3 RepRap Kit.   The first of the series is here. 

Installation of the electronics was pretty straightforward.   This variant of the I3 has support panels that extend from the back of the x- and z-axis plane that provide structural stability and a handy place to mount the power supply and electronics.  My only complaint on this mounting was that the holes did not seem to line up with anything but it could just have been me!

The kit comes with some connectors intended to be crimped onto the wires leading from the servos, end stops, and thermistors but I quickly discarded those in favor of simply soldering the ends of some leads that I already had as I simply did not have the patience to do the tiddly bits work.  I have since ordered some nice connectors and am retro-fitting them.

The photo of the electronics shows both my soldering of leads to avoid the crimping of fiddly bits and also a couple of the nicer connectors that I am retro-fitting (the one that says end stop)!

At this point I connected one of my host computers with the Arduino IDE to the printer so I could mess with it's firmware (or Arduino sketches to be more precise). 

Configuration of the firmware provided a larger challenge, again one that documentation would have helped me to avoid!   There are a plethora of choices of firmware for the Arduino/Ramps hardware and somehow I ended up choosing Marlin.   I don't regret this decision I just can't claim any science behind it!

Marlin is driven by a configuration.h file that allows you to customize it's function to your exact hardware configuration.  Some of this is pretty easy such as choosing your board!   One other  parameter caused me a little more trouble.   DEFAULT_AXIS_STEPS_PER_UNIT was key to getting things moving!   This provides the number of steps per unit for each of the servos.   By default the x and y are fine but the z and extruder were way off.   In particular the z as it was so low that my z-axis was barely moving when running the hardware integration test (results of which are shown below).


Sunday, February 2, 2014

3D Printer - Mechanical Build

Completed Printer
This is the second in a series of posts describing my adventures with 3D printing, and specifically, with a Prusa I3 RepRap Kit.   The first of the series is here.  A picture of the completed printer is to the right.

Here are the parts, somewhat organized, with the parts list from the kit.   I did not do a complete item, by item, inventory but wish that I had for a number of reasons.   First because I was missing a couple parts and second as it might have helped me avoid at least on mistake!

The first piece to be built was the frame of the y-axis.   Did I mention that at the time of this building 3D Printer Czar had not completed their assembly instructions?   I found some for a Prusa I3 on the web and used them.   Did I mention that one of the characteristics of the open hardware source world of the Prusa that there are multiple versions of the Prusa I3?

Which I discover to my chagrin as I start connecting the box frame for the y-axis.   Note that it is a rectangle and all the rods are the same length on a given side.   Just like the one from the instructions that I found.   Unfortunately not like the one the Czar wanted me to build.   Had I done a good inventory I would have known that the frame was supposed to a longer rod to connect to the back of the support frame and I would not have taken a hack saw to a part that I then had to source a replacement.  Naturally, having assembly instructions, or at least high quality pictures, would have also helped!  Anyway, here is the completed frame with the hot bed platform in place.  Speaking of this platform...it was not exceedingly obvious to me how it was supposed to be mounted to the bearings.   Turns out that it just sits on them and is secured with cable ties.  You can't have too many cable ties of different sizes especially as those in the kit did not fit!


Here is the y-axis with the longer rod replaced and with the y-axis servo in place.   The timing belt has also been installed anchored on the bottom of the car that will drive the hot bed and looping through the y-axis idler at one end and the servo motor at the other end.



Now it was time to start on the x- and z-axis frame.  The three bearings will support the extruder assembly.  


At some point it was going to be necessary to tackle the extruder assembly so I got right on it.   This is the completed extruder ready to be mounted on the x-axis car. 



The major mechanical components of the printer were now complete and needed only to be assembled.   The y-axis carriage slides into the x- and z-axis assembly and is bolted into place.  Finally the acrylic support and stiffening pieces are attached to the x- and z-axis assembly ready for mounting of the power supply and electronics.


Here is the printer with all of the mechanical bits attached.



The next post in this series covers electronics and firmware integration.

Saturday, February 1, 2014

3D Printer - Adventures with a Prusa I3 RepRap


What has an Arduino with a giant shield on top of it as a brain, five giant servos, moves in three axis, and can replicate itself?   Not exactly a robot but a 3D printer.   Decided that I absolutely had to have one.  Knew that I wanted to build a kit, both to save some money, and for the experience of it all.

Did some research on the various kits out there and decided on the Prusa I3.   The Prusa I2 or Mendel seems to be one of the most popular kits out there and the I3 is an easier to build, improved version, of the Mendel.   Then started to look for places to buy one.

On Arrival
You can buy the pieces individually getting the hardware and frame from one place, the electronics from another, and the printed bits from yet another.   You can even source the hardware yourself.   I decided that buying a complete kit was the way to go.   I also decided that I wanted a RAMPS based printer.   Options were starting to get limited.   I ended up with buying from the 3D Printer Czar in Hong Kong.

As Assembled
The kit was $500 with another $80 for over night shipment to the UK.   This was less than any other kit that I had found.   I ordered the kit on New Years Eve.   The shipment promise was within seven days and it shipped within that window on the Monday after New Years Eve.  It arrived in the UK the next day and then the waiting on the government began.   Two weeks later it had finally freed itself from customs and the tax man and after paying my 80 quid of taxes I got my printer kit.

I am going to describe the rest of this project in a series of posts covering the following:
Obligatory Owl
In the meantime, here are two videos showing the project at the point of some initial calibration and then doing a first large print:

In Action

Printed Spares and a Filament Roll Stand


Thursday, November 7, 2013

Node.Js Physical Interface Demo App - Upgrades in Progress

Per some previous posts (starting  here) I have pulled some functionality from a project that I am working on into a little demo application - Node.Js Physical Interface Demo.  

Over the past days I have refined the framework that I am using for my web server.  I have chosen to use a fairly primitive approach to providing web service as I have based my application on the http module.   This gives me very atomic control though with some added complexity.

In order to attack that complexity I have refined my own framework for http service.  There are to scripts that are purely server...server.js which talks to the port and form.js which handles page and form interaces asynchronously.   Two additional scripts provide an interface between server and form, serverExits and formExits.   As the name implies there are a number of exits embedded in Server and Form that allow a application to customize some key handling aspects.

Everything else is pure application.   To add a web page you create a script that includes application logic AND to handlers...serverHandler and formHandler.  serverHandler executes the asynchronous recieve of a form which is then processed by formHandler.   A matching html file is created in the html directory, with some meta tags that allow substitutions of variables, and Bob is Your Uncle.

I will write more about this later.   Remember that my target is an embedded application with its head being a small LCD touchscreen.....

Thursday, October 31, 2013

Beaglebone Black Image Setup for 'The App'

Below is the procedure that I follow to create an Operating System mage on which my app runs.   This assumes we are starting with a distribution image that has been flashed to the internal drive of the BBB, dd'ed off that image having booted from the external SD drive, and then having used the img copy to create a new bootable SD card.  I know, there is probably an easier way to accomplish creating a new bootable image from a distribution file!

In any case then we do the following:



First make sure that the system date and time is accurate: 
ntpdate -b -s -u pool.ntp.org



Then update the package indexes for both the OS and for NPM:
opkg update
npm update 



Now install all the OS level stuff that we will be needing:
opkg install python-compiler
opkg install python-misc
opkg install python-multiprocessing
opkg install xdotool
opkg install gettext



The version of git on the BBB needs to be updated so download the tarball with the code and then do the following:
tar -xvf git-1.8.?.tar.gz
cd git-1.8.?
./configure --without-python
make
make install



There is a problem with npm such that it will incorrectly fail thinking that it does not have the right version of Python installed.   Fix this via the below edits:
nano /usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js 
Change:
if (semver.gte(version, '2.5.0') && semver.lt(version, '3.0.0')) {
getNodeDir()
                    } else {
               failPythonVersion(version)
                    } 
To:
getNodeDir()



Now all the npm packages that we need can be installed:  
npm install -g node-gyp
npm install -g i2c
npm install -g socket.io
npm install -g descriptive-statistics
npm install -g exec-sync
npm install -g zipstream  
npm install -g line-by-line
npm install -g serialport2



Following sections, for RTC, are obsoleted by getting the date and time via the Arduino.  At this point, assuming we are wired for our I2C devices, we can set up our Real Time Clock.    This is, of course, assuming that when you run the first of the below commands you see something at address 0x68!   If there is, test it by doing the rest of the commands (get current network time, create the RTC device, write the time to the RTC, pull it off the RTC):
i2cdetect -y -r 1

ntpdate -b -s -u pool.ntp.org
echo ds3231 0x68 >/sys/bus/i2c/devices/i2c-1/new_device
hwclock -f -w /dev/rtc  
hwclock -f -s /dev/rtc


If all is well above (note that you need to check the device [/dev/rtc?] that was created to ensure you have the right name), create the following file “rtc” in “/etc/init.d”:
#! /bin/sh
# /etc/init.d/rtc

### BEGIN INIT INFO
# Provides:          Time sync
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Updates time from rtc
### END INIT INFO

# If you want a command to always run, put it here

# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting time sync"
    echo ds3231 0x68 >/sys/bus/i2c/devices/i2c-1/new_device
    hwclock -f /dev/rtc -s
    ;;
  *)
    echo "Usage: /etc/init.d/rtc {start}"
    exit 1
    ;;
esac

exit 0



Make the above created file executable:
chmod +x rtc



And have it run automatically:
update-rc.d rtc defaults




Now make sure the board time is set, then load it to the RTC:

ntpdate -b -s -u pool.ntp.org
hwclock -f -w /dev/rtc  


Now we can create our source directories for the application.   First create a directory named "AppNameHere", cd into it, and execute the following command:
git clone https://github.com/ThamesWill/AppNameHere.git dev

Fix for possible authentication issues:
http://derekmolloy.ie/fixing-git-and-curl-certificates-problem-on-beaglebone-blac/

Once this has completed (note that you will need an id on github) you should execute the following script from the download:
dev/install



The above should have created all the other directories and startup files that will be needed.   At this point you should be able to execute the command line configuration tool:
./config



If everything is working you will see a list of default parameters.
One last change is to point the cloud9 environment at the source code we just downloaded. Do this by editting the following file replacing the "/etc/lib/cloud9" entries with the path to the dev directory created above.
nano /lib/systemd/system/cloud9.service 



You will now need to either reboot or tell systemctl about your changes and then restart cloud9:
systemctl --system daemon-reload
systemctl restart cloud9
nano /lib/systemd/system/cloud9.service 



Finally, make sure that you have updated the hosts file to match your server name for The App configuration

DONE!

Wednesday, October 30, 2013

Implementing an I2c Workaround

The i2c library that I am using (kelly/node-i2c) works great...but...after some period of observations it causes node.js to fail with a segmentation fault.   I am not sure this is a problem with the base library or with how I am using it with the Analog Digital Converter that I am using.   I suspect that it is the latter but I don't have the technical skills to diagnose the problem.  Given the former I decided to implement a workaround as described below.

wireServer = require('child_process').fork('wireServer.js', 
   [global.config.i2cDevice, global.config.i2cAddress, global.config.i2cCommand]);
wireServerPid = wireServer.pid; 
utilities.trace(false, "test - wireServer started as PID " + wireServerPid);
Since failures generally only occurred after a period of time I decided to create a background process that could be started for the period of observation and then killed until the next period is started.  


eventEmitter.on('startObserve', function(message){
    wireServer.send({"message":"init", 
        "i2cDevice":global.config.i2cDevice,
        "i2cAddress":global.config.i2cAddress,
        "i2cCommand":global.config.i2cCommand});
    // Each message will be a voltage reading that we then pass to the below routine
    wireServer.on('message', function (message) {
        observe(message.voltageIn);
    });
});
I am using an event to start the observation period by sending a message to the wireServer process started above.   The message tells the server where to look for the I2c device.  Once this is done I setup a handler for readings coming back from the server.



execSync('kill ' + wireServerPid);
utilities.trace(false, "test - Current wireServer running as PID " + wireServerPid + " killed")
Once the I2c interface is started node will no longer respond to messages sent to the background process!   This means I have no way of asking it to die gracefully.  That being missing I use a little less graceful approach and kill it at the O/S level.

eventEmitter.emit('startObserve', '');
Finally we launch the observation perio.

The background process that the above launches, and then communicates with, is shown below:


// Load the library we need to get voltage measurements using i2c
var i2c = require('i2c');       
var i2cDevice = "/dev/i2c-" + process.argv[2];
var i2cAddress = process.argv[3];
var i2cCommand = Number(process.argv[4]);
// Convert the i2c address from character to hex
i2cAddress = parseInt("0x" + i2cAddress);
var wire = new i2c(i2cAddress, {device: i2cDevice, debug: false}); 
var seq = 0;

wire.on('data', function(data) {
    observe(data.data);
});

// Look for an init message from test to start our observations
process.on('message', function (message) {    
    wire.stream(i2cCommand, 4, 3);
});

// Take a voltage reading and send it on to test
function observe(buffer) {
    var voltageIn = 0;
    voltageIn = (buffer[0] << 8) + buffer[1];
    // Did we get a negative value?  If so make it a zero.
    if (voltageIn > 2048) {
        voltageIn = 0;
    }
    else {
        voltageIn = voltageIn / 2048;
    }
    if (seq == 5000 || seq === 0) {
        console.log(datetimeStamp() + " - wireServer - active");
        seq = 1;
    }
    process.send({seq:seq++, voltageIn: voltageIn });    
}