Tuesday, December 29, 2009

Mill: servo switch relay...

I've been using my mill quite a bit in an attempt to make a circuit board. I've finally gotten annoyed with having to turn my dremel on and off manually and decided it was time to upgrade to automation. The first step was to come up with a simple way to control a high powered device through my arduino. I thought about using a relay board. However, I went with something I thought would be a lot more fun to assemble.

All the household switch parts cost about $4. The servo was just one I had lying around. I'm sure a $12 servo would do the trick.

Next, I did a little research on G-Code, knowing the commands were already standardized. It turns out M03 is the standard command for "Turn Clockwise" and M05 is the standard for "Stop Turning". I updated my firmware and added a servo library. Here it is installed:

I am happy with the result. I did a quick search on thingiverse to see if others have done this and found a much more elegant solution: Servo Controlled Switch by oomlout

Saturday, December 19, 2009

Spiderwheels: eyes...

I have been putting a lot of thought into how to make the head of my spider and finally settled on a simple proximity sensor from SparkFun with two degrees of freedom. It is always good to start with a proof of concept and so I wired it up to my breadboard sanguino. I basically made it pan until it finds an obstacle and then nod. Here is a video:

Here is the source code:

#include <Servo.h> 
Servo zServo; //rotates about z
Servo xServo; //rotates about x

float zPos = 90; //keeps track of position. 90 degrees is resting.
float xPos = 90; //keeps track of position. 90 degrees is resting.

int milisecondsBetween = 20; 
int vMax = 300;

int sensorPin = 0;    // select the input pin for the potentiometer
int sensorValue = 0;  // variable to store the value coming from the sensor

void setup() {
  zServo.attach(13);  // attaches zServo object to pin 13 
  xServo.attach(12);  // attaches xServo object to pin 12 
void loop() {
void goLeft(){
  float z = zPos;
  sensorValue = analogRead(sensorPin); 
  while(sensorValue < vMax && z > 50){
    z -= 10;
    moveTo(xPos, z);
    sensorValue = analogRead(sensorPin); 
  if(sensorValue >= vMax){
void goRight(){
  float z = zPos;
  sensorValue = analogRead(sensorPin); 
  while(sensorValue < vMax && z < 130){
    z += 10;
    moveTo(xPos, z);
    sensorValue = analogRead(sensorPin); 
  if(sensorValue >= vMax){
void printV(int v){
  Serial.print("v: ");
void sayHi(){
  moveTo(90, zPos);
  moveTo(110, zPos);
  moveTo(90, zPos);
void moveTo(float x, float z){
  while(xPos != x|| zPos != z){
    if(xPos > x){
      xPos -= 1;
    else if(xPos < x){
      xPos += 1;
    if(zPos > z){

      zPos -= 1;
    else if(zPos < z){
      zPos += 1;

Sunday, November 29, 2009

Mill: electronics, end-stops, bed, and vacuum...

I've been adding to my mill related to-do list for several weeks and am happy to say that I finally made some progress. First, I finished installing my electronics. I was planning on borrowing my stepper driver boards from my 3d printer in order to mill another set but finally got too annoyed by switching machines so I went ahead and bought them from MakerBot.

Next, I installed the x, y, and z end-stops respectively.

I then started working on my bed. I wanted some kind of setup that would allow me to screw on the material I was milling in any orientation or size. I settled on this approach. Thankfully I was able to mill all the grooves and drill all the holes right no my mill. To accomplish this I screwed down a 1 X 3 inch board and milled down the surface so that it was level. I then pinched these 1 X 1 inch pieces of wood between two screws and milled a groove. I Flipped and repeated. I then turned and drilled the holes in the pieces of wood. I then drilled corresponding holes in my base MDF bed.

A washer will now fit in the grooves and so I have a lot of flexibility in how I screw down my milling material. I also zip-tied a Husky Wet/Dry Vac to the mill. I should have done this a long time ago. I am now in the process of milling down and leveling my new bed.

Sunday, November 22, 2009

RepStrap: cleaning day...

When I originally built my RepStrap I did it so quickly that I didn't bother making it pretty. My driver boards have been laying next to my printer with a rat's nest of wires on top for the last six months. It was time for me to get out the zip ties and make it pretty.

I also install a household power switch under my table to turning it on and off. While I was at it I installed one for my mill as well.

Saturday, November 14, 2009

Spiderwheels: How to bootload a breadboard sanguino...

Now that I have a leg constructed it is time for me to focus my attention on the circuit. I have decided to base my circuit design off of the sanguino by Zack Hoeken. I made this decision for three reasons.

  • I want to stay close to the arduino community in order to leverage all the open source work that has been done.

  • There are no surface mount parts in the design, which is good because I want to keep this at the beginner level. It's also good because I want to prototype on a breadboard and SMT doesn't play nice with breadboards.

  • It has enough pins. I need at least 18. I want 27. The sanguino has 32.

I put in orders for all the parts I need for two sanguinos, as well as a USB to TTL cable and a USBtinyISP bootloader last week. I was really lucky that all the orders came in last night.

First, I soldered together my USBtinyISP kit.

Then I followed this tutorial to construct a breadboard sanguino for prototyping.

I was a novice to AVRs and the inner workings of the arduino family of boards as of last night so I was naive enough to think that it may be possible for the bootloader to magically go onto the AVR chip when you load the firmware for the first time. Nope. I got the "avrdude: stk500_getsync(): not in sync: resp=0x00" error.

Though I was naive enough to try it I was smart enough to have already made a USBtiny bootloader. However, how do you plug the USBtiny into the breadboard sanguino?

As you can imagine this was an intimidating problem! Remember, I was a novice. It's not that the information isn't provided. Technically, all you need is the schematic of the USBtinyISP and the schematic of the sanguino to figure it out. Still... I am kind of surprised that the sanguino website doesn't say much about bootloading. I mean... this is an open source project. Furthermore, arduino bootloading tutorials are hard to come by in general. This got me thinking. Why are there no / very few tutorials on bootloading? Is it to encourage people to buy their kits which have already been bootloaded? Is it because bootloading is too technical for the average arduino hobbyist to understand? Is it because no one really cares because they have no desire to design an arduino variant on their own? Maybe it's just that no one took the time. Definitively something to think about. I welcome thoughts on this.

It took me two whole hours to check and double-check my work before I felt comfortable plugging in the USBtinyISP. Here is what you need to do if you want to bootload an ATmega644P on a breadboard with a USBtinyISP.

USBtinyISP ICSP (1) goes to (b16)

USBtinyISP ICSP (2) goes to (b19)

USBtinyISP ICSP (3) goes to (b17)

USBtinyISP ICSP (4) goes to (b15)

USBtinyISP ICSP (5) goes to (b18)

USBtinyISP ICSP (6) goes to (b20)

Now, assuming you have followed the tutorials on how to get your computer to recognize the USBtinyISP and you have successfully installed the arduino app + sanguine files, the next step is to plug in your USBtinyISP. Then open up your Arduino application, select board > sanguino, select burn bootloader > USBtinyISP and wait 5 to 10 minutes. I didn't think it would take that long but I resisted the urge to unplug it and try again. It worked the very first time with patience.

I just burnt a bootloader on a fresh chip! Now I can plug in the USB to TTL cable like this:

and burn some firmware. I successfully uploaded the blink program to the ATmega644P chip before writing this.

I hope this is of use to someone.

Saturday, November 7, 2009

Spiderwheels: snap...

Now that I have decided to use the smaller servos I have been redesigning my spider leg parts to accommodate the smaller servos. I recently had a burst of creativity. I realized that I can design these parts to snap together, instead of requiring fasteners. Here is an image and a video of the the snap together design.

CNC parts printed on a RepStrap from gavilan on Vimeo.

Sunday, November 1, 2009

Mill: bigger steppers and carbide bits...

When testing my mill out for the first time went ahead and borrowed my steppers from my 3d printer. They sell for $26 and have 156 oz-in torque. Here is a picture of one on my printer (Kelling, KL23H251-24-8B).

They worked fine for the tests but I quickly realized I needed something bigger. I went ahead and ordered some of these (Kelling, KL23H2100-30-4BM):

They are $59 a piece with 495 oz-in torque. I will be using one for each of me x and y axes and the smaller stepper for my Z axis. What these bigger steppers provide me is more speed and power. I am able to run the mill twice as fast with these steppers without skipping a single step.

I also got some new pure carbide bits in the mail for milling PCBs from Think & Tinker. I have yet to try them out, though I have complete confidence that they are up for the task.

I also ordered some carbide drill bits.

I'm looking forward to giving these a go soon.

Saturday, October 31, 2009

Spiderwheels: smaller servos...

Wow, it feels like forever since I've blogged. I learned how to design circuit boards a few weeks ago. It is a lot easier than I thought it would be. While I was waiting for some new bits to come in the mail I started working on my Spiderwheels project again. I've been experiencing issues with my netbook since I got it and just recently found out what was wrong with it. It looks like the graphics card is overheating under normal use and cannot run for more than 20 minutes. I was really upset at first. I'm over it now. EBay is not always the best option.

Considering the netbook I got for this project is non-functional I have decided to look into building a smaller robot without the burden of the 2 lb netbook. This idea hit me when I stumbled across these servos. They weigh 9 grams and cost $3.50. Compared to what I was spending for the larger 55 gram HiTec servos, +/- $30, these are a steal. I went ahead and ordered a few to do some benchmarking. So far I am very impressed. I want to construct a leg and get a feel for accuracy before ordering more. With these prices this project may well produce a six legged walker from the start.

Here they are side by side:

Here is a close up of the 9 gram servo:

Sunday, October 11, 2009

Spiderwheels: I have so much to learn...

I realize this is my first robotics project and I should stick to wire nuts and breadboards but I want to learn as much as I can from this project. Frustratingly enough, this means I must take several steps back and pursue PCB fabrication. I built a mill and am getting close to being able to mill boards. The next step is learning how to design them. This is a very overwhelming subject for me and it is hard to know where to start. I have decided to go with Eagle as my layout editor mainly because the RepRap team uses it and this is all I have to go on when it comes to board fabrication. So, I guess the first step is to follow some tutorials. I have chosen this tutorial because it will also serve as an introduction to the FT232RL chip, which is used in the Arduino. Time to learn.

Monday, October 5, 2009

Mill: starting yet another project...

Every once in a while I get the chance to re-evaluate my vision and the direction my research is going. Every time I get the chance to do so I identify a gaping hole in my current tool set. For the last six months I have had a working 3d printer at my disposal. However, when I started working on my first robotics project I found that it wasn't enough. I am missing an easy and accurate way to fabricate PCBs. Of course I could purchase the chemicals required to etch, but I have a small apartment and I haven't seen much precision out of people who have gone down this route. Since I started building a RepRap I have been aware of CNCs capable of milling PCBs and have even given this a try on my Darwin. I quickly found out that milling on a Darwin isn't the best idea.

Thus, a new project is formed. I don't have a lot of time or motivation these days and so I wanted to be smart about getting a cheap solution up and running with minimal time / resources. I decided to go with a time tested design called the Rockcliff. It's not an open source design, but the plans only cost $20. They are well worth it! Here is an animation of the design I went with:

It is mostly made out of 3/4 inch MDF and 5/8 inch steel rod, which cost $60. You will also need some bearings, motor couplings, stepper motors, and driver boards costing upwards of $400. However, considering I have a 3d printer I was able to print the bearings and couplings. Here is video of what the printed bearings look like:

CNC parts printed on a RepStrap from gavilan on Vimeo.

I am also borrowing the driver boards from my printer while I mill another set.

In total, I think this CNC will cost me around $240. Not bad for 0.003mm precision.

Here is a picture of the mill as it stands.

More to come on my goes at milling PCBs on this Rockcliff.

Sunday, October 4, 2009

RepStrap: a Darwin x motor bracket...

I finally got around to printing my x motor bracket the other day.

There are a few structural weaknesses due to my Z axis, but I think it will hold together. I am getting close to replacing all my hand made parts.

Saturday, August 22, 2009

Spiderwheels: motion...

Here is a video of a proof of concept I put together.

movement experiment of spider leg... from gavilan on Vimeo.

The materials are minimalistic and only for this experiment. You can clearly see that the leg is cycling through (D = 2, H = 3), then (D = 8, H = 3), then (D = 8, H = 4), then (D = 2, H = 4), then back. With two legs mounted on the front of my robot, this would be enough to propel it forward 6 inches per touch down.

Here is the source code:

#define servo2Pin 2
#define servo3Pin 3

int i;

void setup(){
  pinMode(servo2Pin, OUTPUT);
  pinMode(servo3Pin, OUTPUT);


float l1 = 4.5;
float l2 = 6;
float d,H;
void loop(){
  H = 3;
      goToAngle(servo3Pin, hipAngle(d, H, l1, l2));
      goToAngle(servo2Pin, kneeAngle(d, H, l1, l2));
  H = 4;
      goToAngle(servo3Pin, hipAngle(d, H, l1, l2));
      goToAngle(servo2Pin, kneeAngle(d, H, l1, l2));

int kneeAngle(float d, float H, float l1, float l2){
  return ((acos((l1*l1 + l2*l2 - d*d - H*H)/(2*l1*l2))*180)/PI);

int hipAngle(float d, float H, float l1, int l2){
  return 180 - (atan(d/H) + acos((l1*l1 - l2*l2 + d*d + H*H)/(2*l1*sqrt(d*d + H*H))))*180/PI;

void goToAngle(int pinNumber, int angle){
  if(angle <= 180 && angle >= 0){
    sendPulse(pinNumber, (600+(angle*9.72)));

void sendPulse(int pinNumber, int pulseWidth){
  digitalWrite(pinNumber, HIGH);
  digitalWrite(pinNumber, LOW);

Fun stuff! 50 or so lines can do quite a bit!

Spiderwheels: algebra, geometry, and trigonometry...

I've been wanting to build a spider robot for a log time. I remember looking around the internet years ago to see if other people have done this. One project really stands out in my mind.

You can read all about the how on Zenta's blog.

The fluid movements of Zenta's six legged robot has inspired me to really put some thought into the mathematics behind the movement of a spider before I get too far with design and coding. After a few days of diagrams, equations, and some proofs of concept I have come up with some trigonometric functions that describe a subset of the movement of a spider. Now, let's dive in.

Consider the following:

Yes. That is correct. Spiders have legs. Now, consider the following:

A picture says a thousand words. What I am trying to convey with this one is that the joints that make up the leg of a spider have ranges of motion. At one given point in time the position of this leg can be described by two angles, i.e. the hip and knee, angles. These angles are key because they are "servo speak".

Now, wouldn't be good fun if we could describe the position of the leg in terms D and H in the following diagram?

Considering I will be building these legs I will know L1 and L2. So, given L1, L2, D, and H, how do we find a1 and a2.

The first step is to find k. According to Pythagoras, a2 + b2 = c2.


k2 = D2 + H2
k = sqrt(D2 + H2).

Once we have k we can use the Law Of Cosines to find a2.

k2 = L12 + L22 - (2 * L1 * L2 * cos(a2))
cos(a2) = (L12 + L22 - D2 - H2) / (2 * L1 * L2)
a2 = cos-1( (L12 + L22 - D2 - H2) / (2 * L1 * L2) ).

Similarly, we can find a4.

a4 = cos-1( (L12 - L22 + D2 + H2) / (2 * L1 * sqrt(D2 + H2)) ).

We also know that

tan(a3) = D / H
a3 = tan-1(D / H).

Finally, we can solve for a1.

a1 = 180� - a3 - a4
a1 = 180� - tan-1(D / H) - cos-1( (L12 - L22 + D2 + H2) / (2 * L1 * sqrt(D2 + H2)) ).

In my next blog entry I will show a video of some proof of concept work, as well as share the source code that makes it all happen.

Sunday, August 16, 2009

Spiderwheels: a step in the right direction...

If you've read some of my other blogs you will know that I have been attempting to get into robotics since I graduated college in 2008. This journey lead me to create my own 3d printer with help from the RepRap team. Though I am still working to improve the quality and speed of my prints I have passed the point where it requires intellectual work. I must move on. With what I currently know about robotics (which isn't a whole lot) I've put together an idea for my first robot. This project should sharpen my abilities in writing c / c++ applications under Linux. It should give me an introduction into streaming image processing, skin detection, face detection, and potentially face recognition. It will also be a good project for getting experience using micro-controllers, and servos. Finally, and I'm not 100% sure on this, it may be a good platform for starting an open-source project.

Now that I've laid out all of these very lofty goals let me step back and describe the project that I have envisioned and where it came from.

Every interesting robot has the following characteristics:

  • sensors

  • a brain

  • interaction

In terms of hardware this implies processing power, motors, camera... among other things. I've spent quite some time thinking through the best platform for my first robot when I stumbled across the following:

Above is a picture of an MSI Wind U100-420US Netbook. The amazing thing about a Wind is it weighs 2 lbs and can be purchased off the shelf for under $300. I was fortunate enough to find one on ebay for under $200. Built into this machine is a 1+ hr power supply, 1.6Ghrz processor, 1.3Mpix webcam, mic, speakers, wifi, and a 10 inch screen. Thus, this machine alone can supply a large amount of portable computing power, vision, hearing, speaking, wireless communication, and visual expression. The only gaping hole between this machine and an interesting robot is interaction. This is where my new friend the adruino microcontroller comes in.

This micro-controller is opensource and inexpensive. It is also really easy to program. I know of it because it is the brain for the Reprap. Micro-controllers, among other things, can tell servo motors what to do. A few lines of C, and a bunch of these

and you can have pretty cool interaction. My end goal is to build a six legged spider with these parts, but the servos alone cost $30 a piece. Considering three are needed per leg your are looking at a bit of saving up. I am going to start with only two legs and some wheels.

Monday, August 10, 2009

RepStrap: a whale of a tale...

A friend stopped by to nerd it out last week. He is known for a whale that he draws as part of his signature. Thus, a key element of the nerd out was designing and printing a 3D whale. Much fun was had by all.

More images can be found here:

RepStrap: decor by repstrap...

My wife and I have been putting up curtains recently. The land lord doesn't particularly like holes in the wall so we have been using 3M tape as much as possible. I decided to have a little fun and design a kind of tieback hook that can be printed. I feel they turned out quite functional.

My dad was visiting with a new HD camera... so I had to take a video.

A RepStrap prints useful things... from gavilan on Vimeo.

Thursday, August 6, 2009

RepStrap: bigger parts...

I am finally starting to work on my projects again. I have taken an extended break from it all in order to spend more time with my wife between her classes. After returning to my projects the first challenge that I attempted to conquer was a common warping issue when printing ABS plastic. It wasn't really an issue when printing corner brackets and motor couplings. However, bigger pieces like the x carriage were near impossible. Luckily the solution was handed to me by nophead. It is clearly described in his Thoughts on rafts entry. After taking his suggestions into account I was finally able to print the x-carriage. Here are some pictures.

Wednesday, May 27, 2009

Semi-automatic: trigger mechanism...

I thought I would start with the most complex mechanical part, i.e. the trigger. The mechanical idea for this gun is not original. It was inspired by guns I have seen in the past that made me want one to begin with. Below was my first go.

It didn't work at all! I decided to completely redesign it. Below was my second go. It isn't perfect, but it works.

It is functional, but it isn't smooth. Still, I think I want to move on to other areas of the gun. The next challenge will be designing the barrel and handle in such a way as to snap together in some way. I realize nuts and bolts are cheap, but I welcome the added challenge of making them unnecessary in the design.

As this is a mechanical project (read moving parts) I thought it would be appropriate to include a short video of my second attempt.

Beginnings of a rubber band gun... from gavilan on Vimeo.

Tuesday, May 26, 2009

Semi-automatic: a beginning...

Why am I designing a printable semi-automatic rubber band gun?...

I enjoy working on things that have an immediate purpose and a higher purpose. The immediate purpose is that this was the gift Santa never got me. The higher purpose is that it will serve as a proof of concept that software engineering practices can be carried over to mechanical engineering. Now that I have a 3d printer I want to see if I will be able to quickly prototype a small subset of the overall mechanical functionality, test it, and repeat.

RepStrap: parts update...

This is where I currently stand with my RepRap parts.

I had a realization recently that I should stop focusing exclusively on passing the RepStrap -> RepRap threshold. I have been focusing all of my energy on finishing a set of parts because I should get a shorter print time and more precision with these parts. Still, I am currently getting an acceptable print quality / time... and I freaking have a 3d printer! So, I decided to start using it for more than just Darwin part creation. There were reasons why I wanted a 3d printer after all.

One thing I love about software engineering is that you can design a small component, test it, get a feel for how the technology and concepts work, and then use it as a building block in the big picture and end result. Ever since I started building a 3d printer I wanted to try these techniques on a mechanical problem. I have decided to start doing just that.

As a parallel thread of effort I have decided to create a printable semi-automatic rubber band gun. Should be fun... and keep me busy while my Darwin parts are printing.

Friday, May 22, 2009

RepStrap: starting to trust...

Before last night I had no trust in my RepStrap, and for good reason. I have dealt with lots of hardware crashes and software crashes since my first print. On the hardware side the Z axis has given me real difficulty. The last issue I faced was that the calibration would slowly drift after several prints. This was due to the belt slipping only slightly, and only from time to time. Two or three prints later and I had to recalibrate. I know that there are other belt tension solutions around the RepRap blogs, but I needed something a bit more flexible. I came up with this.

It's just an extra bit of thread rod, a printed idler pulley, and some rubber bands and string. I have printed 10 parts since I put this on and have yet to recalibrate.

My software problems ended as soon as I switched to Skeinforge. Last night was the first time I trusted enough to let the printer run all night. I am now letting the printer run 24 /7 and my collection of parts is quickly growing. Here are some images of my most impressive print. The three objects that make up this part took a total of 8 hours to print. Its a bed corner, constraint bracket, and bearing insert for the Darwin.

Next on my agenda is to tackle my warping issue. Basically, the corners of the base of my print are pulling up, making the bottom not completely flat. It hasn't bothered me as of yet because all the parts I have printed are relatively small. I will eventually be wanting to print the X carriage, which is quite large. I am concerned that if I don't solve for warping before attempting this part that the part will be unusable.

I will be looking into different printing surfaces(right now I am using Plexiglas), cooling techniques, and printing speed to see if I can solve this.

Tuesday, May 19, 2009

RepStrap: a software comparison...

As soon as I got Skeinforge working I wanted to do a comparison. For each pair of images the first is an image of an optoswitch-bracket printed by the host software GCode. The second is an image of the same produced by Skeinforge GCode. With no further ado: