Sunday, December 23, 2012

Printrbot LC mod log

I want to keep track of some of the modifications that I do to my Printrbot LC since others might find them useful. Also it will be interesting to see how what I do changes over time.

1:
The first modification that I did was to place little pieces of silicone fuel line as washers under the printbed to allow it to be leveled. This tubing is the type used for R/C models to connect the fuel tank to the engine (which I had laying around). The tubing can squish down a bit so you can vary the height of each corner of the platform. This seems to work OK, however I still cannot get the bed perfectly level.

2:
I noticed that the heated printbed takes forever to reach 90C and will almost never reach 100+. It is a bit cool in my apartment, so that might be part of it, but I also think this might be a sub optimal design for the printbed. So to try to make it a tad more efficient I placed a layer of aluminized mylar film under the wooden platform. Maybe this will conserve a bit of the heat. Ideally this would be directly under the heated plate, however I did not feel like taking it off, so we shall see how this works.

3:
I decided that mod 1 was not working well enough for me, so I switched to using springs instead. I was originally thinking of making these however I have springs laying around so that was a simpler solution. Essentially it accomplishes the same thing. I was able to get the printbed very level which greatly enhanced the quality of the print so far.

Saturday, December 15, 2012

Printer is printing

So, last time I addressed a few of the things I learned and was still struggling with on my Printrbot LC, but now I have had my first fully successful print, and another less successful so I will address some of the things that I have learned so far.

Most of my problems have been with extrusion which unfortunately can have numerous causes. One of the biggest issues I had was actually that the idler itself was not freely moving. The ball bearing was actually rubbing up against a piece of the wood extruder frame, and causing a ton of resistance. I did not look at this until well after playing around a ton with the idler tension. This lead to lots of frustration and cleaning of the hobbed bolt.

Because I draw I happen to have kneaded erasers laying around, whereas my Xacto knives were in my garage leading me to try using one to clear out the plastic from the hobbed bolt. I discovered that this is a very good way to get them cleaned out very quickly. For those who are not familiar with a kneaded eraser they are designed to pull up charcoal but not destroy themselves like a plastic eraser. They can be shaped very easily. What i did was roll mine into a rounded cone and just dab the hobbed bolt with the tip. Spin and repeat. The advantage here over the Xacto knife is that it doesn't leave a bunch of little bits of plastic all over the place. Also you are not destroying a blade by rubbing it on a piece of metal.

With the issues of the idler being stuck and the bolt being clogged solved, I was able to get a very beautiful print of Mr Jaws. During that print the second nut on the hobbed bolt came off, and apparently when I put it back on I tightened stuff up a bit too much. This lead to a ton of frustration since it seemed like the extruder was clogged even though I could manually feed filament through the print head. So it is critical that this not be too tight.

Additionally I would say that it is critical to apply locktight to both of the nuts on the Printrbot Wooden Extruder kit. On a longer print of a 40 mm cube for calibration the inside nut actually tightened up sufficiently to cause extrusion issues again. Luckily I was able to identify this and correct it, however it leads me to think that locktight or a single nylock nut should be involved in the situation to prevent this.



Wednesday, December 12, 2012

Starting in 3D printing.

The other night I finished assembling my first 3D printer, a Printrbot LC. I am very excited about this, and for the most part had an easy time assembling the printer. One issue I did have is that the instructions are video, and not completely up to date, however it seems like they are starting to also produce some instructions using Dozuki or some similar system. I think that this combination is great.

The first issue that I did run into however when getting everything configured is the wiring of the motors. The big thing to realize is that the printer does not use the standard Cartesian coordinate layout. Instead it seems as though the Y and Z coordinates are reversed, such that the Y coordinate instead of the Z coordinate controls the location of the printbed. Consequently the Y coordinate controls the height of the extruder above the printbed.

The symptoms that lead to this realization was that it was impossible to get the bridge assembly to rise very far above the printbed. This is because those motors must turn more for a given distance with the leadscrews. So if you are experiencing the same issue, go ahead and switch Y and Z motors and endstop connections.

Another issue that I am dealing with is with filament not feeding well into the extruder. I am noticing that I am unable to get a good 5mm test extrusion; the last little bit will not flow and the motor will meet lots of resistance. I believe that there are two issues going on leading to this. First, I think that the temp. might be a bit low, so I brought the extrusion temp from 200 to 210 in the _Filament_ section of the control software. Additionally I think that the idler is too tight, squishing the filament and causing the hobbed bolt to grind away material and become clogged. So I have cleaned that out and loosened the bolts for the idler. Hopefully this will lead to a good extrusion.

In addition to getting this going on the physical side I have been playing around with some of the digital side of the equation as well. I have been using Autodesks 123D Design program to learn the basics of 3D design and CAD. One good place to start is to try out some of the simple examples on the inhale3d site related to designing electronics enclosures. Additionally I have been looking into being able to generate STL files from Processing. So watch for a modification of the Menger Sponge class for a version that can generate an STL file for printing in the coming week.


Thursday, November 22, 2012

Fractal adventures: Menger Sponge

I have always found fractals interesting, so recently I decided to start playing around with them a bit as a way to practice my 3D graphics skills. I am using Processing for these experiments. First up is the Menger sponge.

To start I am taking an approach where I build up the geometry of the sponge in an unoptimized way using the "box" primitive. The locations of each cube element will be stored as a PVector in an ArrayList which we will then be able to iterate through when we render. To update the sponge I will iterate through the arraylist, and for each element determine the location for the 20 elements it will be replaced with.

So here is the Sponge class where all of this will happen:

class Sponge{
  //This is a naive implementation of a Menger sponge, using a collection of 
  //cubes to build up the geometry.  
  float size;
  PVector center;
  ArrayList<PVector&rt; elements;
  int MAXLEVEL = 3;
  int level;
  
  Sponge(float size, PVector center){
    this.size = size;
    this.center = center;
    elements = new ArrayList();
    elements.add(center);
    level = 0;
  }
  
  void divide(){
    if (level<MAXLEVEL){
    level++;
    ArrayList<PVector&rt; newElements = new ArrayList();
      float newSize = size/3;
      for(PVector e:elements){
      for(int x=-1; x<2; x++){
        for(int y=-1; y<2; y++){
          for(int z=-1; z<2; z++){
            if(!((x==0&&y==0&&z==0)||
                 (x==-1&&y==0&&z==0)||
                 (x==0&&y==0&&z==-1)||
                 (x==0&&y==0&&z==1)||
                 (x==0&&y==-1&&z==0)||
                 (x==0&&y==1&&z==0)||
                 (x==1&&y==0&&z==0))){
                   newElements.add( 
                     new PVector(e.x+x*newSize,e.y+y*newSize,e.z+z*newSize));
            }
          }
        }
      }
    }
    elements = newElements;
    size = newSize;
    }
  }
  
  
  void draw(){
    for(PVector e:elements){
      pushMatrix();
      noStroke();
      fill(64,85,133);
      translate(e.x, e.y, e.z);
      box(size);
      popMatrix();
    }
  }
}

This class is fairly simple, with only two methods, one divides the sponge so we get the next level of fractal, and the other renders the sponge. In the divide method a new arraylist is created where the locations of all of the new cubes will go. This is then populated by iterating through the current locations, and then for each of those iterating through the possible x, y, and z coordinates where we are subdividing the cube into a 3x3x3 set of cubes. Then the coordinates are checked against the locations we wish to exclude (center cube, and center of each face) and if appropriate add the location to the new arraylist.

One might notice that there is a check in the subdivide class for the maximum level for the sponge. The reason for this is that this is a very inefficient implementation to render. The division is not too bad, however rendering becomes a nightmare since we render 20^level different boxes. A natural optimization of this would be to not render the faces that are hidden from view; where two cubes are next to each other.

Saturday, November 10, 2012

OpenNI on Windows 8

So the other week I upgraded to Windows 8 on my netbook thing where I am doing most of my recent coding. Today I discovered that the code I wrote in Processing using OpenNI was not working, because it couldn't connect to the Kinect. It appears that Windows 8 does not play nicely with unverified drivers following the upgrade. So to fix this I found the following on the google group, which references the Arduino community which has the same issue.

  1. Uninstall openni, nite, and the kinect driver.
  2. Windows key + R to open the run prompt
  3. shutdown.exe /r /o /f /t 00
  4. select troubleshoot
  5. select advanced
  6. select windows startup and then restart
  7. enter the option for Disable Driver Signature
  8. reinstall openni, nite, and the kinect driver


It seems as though this is required each time that you wish to install an unsigned driver. I was initially thinking that this disabled it as a general setting however this does not seem to be the case since last night I had to do this again for the virtual serial driver needed for my 3D printer.

Thoughts on polyglot programming and learning.

The world of computer programming is such a vast and exciting realm with everything from 3d graphics, massive parallel systems, to the tiny embedded systems that make our modern world function. It is thus easy to see the complexity and difficulty in learning all of these different fields in addition to whatever it is we do for work. It feels like such a shame that there is so much to learn about and so little time to learn it all. However I think that is a place where becoming a proficient polyglot programmer can really make a difference.

I have been working a lot with Processing lately to learn about the Kinect. It strikes me how wonderful this language is for learning any graphics related programming. It is important in my view that when learning something it is important to both make rapid progress as well as not be lost in details that are only incidentally related. While I could be doing the same thing in C++ or Java, I think it would slow me down from learning the concepts that are critical to the 3d rendering as well as the Kinect itself. The universal concepts behind what I am doing will be easier to see, and thus I can translate them later to these other platforms.

In this sense I feel that polyglot not only should encompass the use of various languages to tackle problems, but also to extend our ability to rapidly assimilate information. The tools exist to help us both produce better code as well as learn more. We should remember that these languages are creative tools, and sometimes we are best off with the simple tools so we can get closer to what we are actually trying to do.

Friday, October 26, 2012

CUDA notes 1

At work I am getting the chance to experiment with CUDA to speed up some of our computationally expensive tasks. It is both very exciting as well as a very intimidating prospect as we have already invested in a Tesla c2075 board for these tests. While I have played with CUDA in the past, it is still a lot to pick up since there have been significant changes since then, and I was also unable to delve too deeply into it at the time.

To get up to speed quickly I am reading through "CUDA Application Design and Development". One thing that is not covered in the first chapter that I am very interested in is how to time the execution of a kernel. I did find some info on stack overflow about the cudaEvent object. Here is a simple example:

#include <iostream>
using namespace std;
#include <thrust/reduce.h>
#include <thrust/sequence.h>
#include <thrust/device_vector.h>
#include <thrust host_vector.h>

int main(){
 const int N=50000;
 float elapsedTime=0.0;
 cudaEvent_t start, stop;
 cudaEventCreate(&start);
 cudaEventCreate(&stop);

 cudaEventRecord(start, 0) ;//start event timer running
 thrust::device_vector<int> a(N);
 thrust::sequence(a.begin(), a.end(), 0);
 int sumA=thrust::reduce(a.begin(), a.end(), 0);
 cudaEventRecord(stop, 0);
 cudaEventSynchronize(stop);//remember kernels run asynchronously
 cudaEventElapsedTime(&elapsedTime, start, stop);
 
 int sumCheck=0;
 for (int i=0; i<N; i++)sumCheck+=i;

 cudaEventElapsedTime(&elapseTime, start, stop);

 if (sumCheck==sumA)cout<<"Test Succeeded in "<<elapseTime<<" milliseconds!"<<endl;
 else cout<<"Test FAILED"<<endl;

 cudaEventDestroy(start);
 cudaEventDestroy(stop);
 return(0);
}




Saturday, October 20, 2012

Making Thing See, pt. 1

I have recently been reading the book Making Things See which is a tour of Kinect programming using the Processing language. I have played around a little bit with processing in the past, for some artistic type programming and also because I do a lot of programming in a similar project, Arduino.

Processing itself is a language that runs on the JVM, with a subset that can run in the browser using Processing.js. It is a pretty minimalist language which makes it easy to 'sketch' programs out, which is what they actually refer to the code as. I find it very nice to work in as like Arduino you have two main pieces, a setup method and in this case a draw method which can be though of as being like a game loop (arduino has loop instead of draw). This seems like a very convenient language for doing simple visual based code, and even complex openGL code is possible with it. Because of the simple and clear syntax I think the author has made a fine choice in languages for exploring the Kinect as this is going to be a very visual journey.

The first few projects introduce the basics of the Kinect, from how to install the libraries/drivers needed for later projects as well as the physical hardware and the underlying principles behind it. The first few coding projects will feel very simple for those with significant development backgrounds, especially the initial in depth explanations of the listings. However, I still find it very exciting to get such cool results interfacing with the Kinect so easily.

So far I have gotten up to project 7. This is the first project where I feel any truly experienced developer will want to rewrite the code significantly. The author uses a procedural style, which makes it very easy to follow and focus on the Kinect/computer vision concepts. However There is a significant amount of duplicate code here, and I found an object made short order of cleaning it up significantly.

Wednesday, October 3, 2012

GPGPU thougths

Lately I have been looking into gpgpu computing for work, and keep running across interesting things. I have been interested in gpgpu computing for a while now, and have played around with CUDA some in the past. I think that this is a great platform, but to me the future really lies with heterogenous solutions like openCL that can bridge between the gpu and cpu more easily. One big issue that I currently see with these solutions however is that they are all a C like syntax. While in many ways this makes sense, as really this is still in its early years of evolution, I think eventually we will need to develop languages that are more high level, yet allow us the flexibility and power to work on the GPU. I ran across MC# today, which is a small step in the right direction. It brings a C# like syntax to heterogenous computing, instead of the C like syntax of openCL. I would honestly prefer a more python like syntax to be honest as I think there is great power in simple expressiveness. In many ways this is critical on the gpu, since the problems solved there are likely more algorithm heavy than say on a web server. It would be great to express the essence of that more easily.

Saturday, September 29, 2012

dpi

I ran across this today, a short intro to running a django based website on the raspberry pi. To me this is really cool, as I think all of us can learn a great deal from working on limited hardware. It is challenging to make things work well there, and we really start to appreciate the cost of the things that we take for granted when working on larger systems. While obviously it isn't critical that we optimize all of our code to run on things like this, or even to be the most optimal as sometimes the real cost is developer time not execution time. However, being aware allows us ad developers to make that choice with more full knowledge, instead of making it by accident. Beyond that we are also just seeing computers everywhere, and our world is driven by them; so it is essential that we learn to make the best use of them no matter what their scale.

Friday, September 28, 2012

First presentation

Well, last night I gave my first developer related presentation on the Disco project. It was an interesting experience presenting to the Boston Python User Group, and well worth the experience. I feel that participating in groups in this manner is critical to professional development, and will force me to become a stronger developer. By presenting material to others not only do I get to share an interest with them, but I am also forced to solidify my understanding of a topic. One of the problems that I have is motivation to explore all of the random ideas that I have. I feel that presenting lightning talks may be a good way to explore them since not only will I have a deadline to get them done by, but additionally I will have the excitement and motivation of sharing those ideas and results with others who may find value in them.

Saturday, September 22, 2012

impress.js quick take

I am very much happy with impress.js as an alternative to regular powerpoint presentations. I think the process might take a bit longer, however it feels much more engaging and I am more into creating this presentation than a regular powerpoint. So I would highly recommend this for anyone with a bit of a technical background looking to put together a presentation.

Web based presentation

Today I have been working on my slides for a lightning talk I will be giving next week at the Python User Group in Boston. I decided to try something different than the normal powerpoint presentation and will be utilizing a webpage instead. I created a simple presentation using the Strut utility which generates a page utilizing impress.js. I am now going to play around with learning impress.js so that I can either modify or recreate this set of material for the presentation. The cool thing here is that it uses html5/css3 to create all of the effects needed for a really interesting presentation. I like this for a few reasons, one is that I don't need to deal with the very linear format of a pp style presentation and the other is that it will help me gain more skill with regard to css3 styling which I am weak at.

Window managers

I have been dealing a lot lately with trying to optimize my work conditions as well as my work throughput. One thing I have taken to is really looking for an optimal and minimalist user interface for development. I got very tired of the stock Unity interface on Ubuntu, so recently switched to XFCE for window management, as well as tmux and vi for a lot of simple coding. One thing that bugs me having spent my bioinformatics days on a mac is that the bar at the bottom of XFCE does not behave the same, so I end up wasting time opening extra terminals instead of switching to the terminal I already have. I might be able to deal with this through configuration. The other issue though is that I work in full screen VMs and that is where the little menu for virtualbox shows up. I am tempted to give Xmonad a try next week to see how that works out. It could fit my minimalist style. On the windows front I am using Dexpot to manage multiple desktops and assign different tasks to them. So far I have not really done anything heavy on this machine, however it will be an interesting experiment. This weekend I will be preparing my presentation using HTML5/JS/CSS3 so it will be a good first test. On the productivity side of things I am working on getting my typing speed up. I use to be a much faster typist, however all those years away from programming have done me no good. To that end I am using typing.io, a small webapp to practice typing code in various languages.

Thursday, September 20, 2012

New netbook...kind of

Last night hanging out with Andrew I decided to pick up a new netbook/ultrabook. I really don't know which it really is in all honesty. It is the Acer Aspire One, and seems to fit a land between the ultra low end netbooks and the ultra expensive ultrabooks. It has a dual core Celeron processor with the Sandybridge architecture, reasonable battery life, and capability for 8 gb of ram (which obviously happened immediately). This seems like a decent travel machine for projects, in addition to the setup that I mentioned in the previous post. Obviously not everything I do can be done from a tablet, such as the arduino stuff, android programming, and working with the kinect. Oh, and this little guy supports openCL. Lots of directions to explore. So now I have two different platforms going, so I will see how this works out. I think the first order of business might be to write a python implementation of the spigot algorithm for calculating pi. I will try using cloud9 for most of this, and then probably do some initial speed tests on the laptop thing using pypy. I am really interested here if the JIT can get it to outperform a well know C implementation such as y-cruncher. Also, this looks interesting http://www.adafruit.com/blog/2012/09/19/sneak-peek-adafruit-raspberry-pi-webide/

Tuesday, September 18, 2012

Hello everyone

So I decided that I need to get a bit more organized, and my other blog was too scattered with different things.  So I am creating this one to focus just on software with maybe a light smattering of hardware as well.  Hopefully I can get around to blogging more, and really using this as a personal note taking space.  Hopefully some of you will find this helpful as well, or at least interesting.

Yesterday I picked up a bluetooth keyboard to use with my Xoom, specifically to see how things go using this as a dev environment.  No, not coding directly on the tablet, but instead using various cloud services or network devices to do my coding on.  This way I am not tied to the physical device I am coding on, no setting up an environment, and I can always take it with me.  There are some inherent limitations here however.  Obviously I can't play around with the physical computing or NUI stuff this way.  For those projects I will be tied to a real computer.  Also, I will not be able to use any ol' tool or language that I want.  So hacking a bunch of Go or Processing is probably out for this, so again I will have to drop down to a real system for that.  However, where I think this might prove useful is for doing more web server programming, as well as light experimentation/playing.

So what are my options:

There are two ways I could really go with this.  One is to ssh into a box someplace on the cloud (rackspace/linode/AWS) set up my tools (tmux, vim, emacs) and just go to town.  This seems like a reasonable choice for a good number of things, especially when I need actual control over the libraries (numpy, twisted).  This has the disadvantages mentioned above.  Also, there is the setup time to get all the vim plugins just right, and install a vcs and get that all set to go.  Not a huge deal, but not a two second process either.

The other option is a browser based IDE.  This is kind of interesting, and worth exploring.  The one I am playing around with is Cloud 9 (www.c9.io).  They have a free account level, as well as a reasonably priced premium level should I ever need to go that way.  There is some good integration with Github and Bitbucket, which is great.  Also they have some tooling for collaborative tooling, deployment to cloudfoundary, and the such.  This makes it very attractive for server development, since I can just do stuff and push it out.   So, over the next few weeks I will likely be learning some node.js and doing everything in the cloud.  Lets see how this goes.