Thursday, August 26, 2010

CNC Machine Build - Part II


I bet you'd all thought I'd given up on this! Well, I just got a little sidetracked with a few other projects - the main one being the play-structure restoration and a load of garden "improvements" (I hope the landlord agrees!).

Well, I was wondering if I could finish it before posting again, but I got impatient. Most of the hardware is done, but there's still some fine tuning to do on the axes and I still have all the electronics to sort out.

I've been really happy with the plans I bought from solsylva.com, they are detailed and straightforward to follow. Most of this has been new to me, so I've taken my time (not that I had much choice) and it's been working out ok. It must have been comedic seeing my sleep deprived carcass hanging around the wood or screws/bolts at Home Depot around midnight on Saturdays, looking confused and eyeing everything up suspiciously. I had no idea what all the numbers and specifications meant on the parts when I was first buying them... trying to match up what was in the plans with what was on the shelves took a lot longer than I'm willing to admit.

There were a few choices to make when building the machine:
  1. What wood to use.
  2. What leadscrews/leadnuts to use (ACME rod or hardware store threaded rod).
  3. What bearings to use.
  4. What stepper motors, power supply and controller board to use (main choices seemed to be hobbycnc and xylotex.
Since cost is definitely an issue for me, I mostly went with the cheapest options. So, whatever wood was available at Lowe's/HD (pine and Douglas-Fir); threaded rod leadscrews (I can always upgrade to ACME later); hardware store tee-nuts as the leadnuts; skateboard bearings from Slam N City's ebay store; and I ended up choosing the xylotex 3 axis system kit for the electronics/steppers. I went with Xylotex over HobbyCNC mainly because the HobbyCNC kit appeared to require more work to get it up and running (like buying a separate transformer and fitting it in with the rest of the kit).

Here's a few in-progress shots:



This is after installing the y-gantry on the x-rails.



These are the bearing flanges cut out of kitchen cutting board. I bought some Forstner bits from ebay in order to cut the recesses. There are a few holes in the wood that require either spade or forstner bits as well -> the bits have been handy on other projects like drilling recesses for the bolts on the play-structure and making holes in our upside-down tomato plant buckets (you can see them somewhere in the middle of one of Lin's more epic posts).



This image shows the machine after the x-axes leadscrews and nuts have been added - there's one on each side of the machine. The x-axes stepper motor is connected to the two leadscrews by a belt and pulley system (suppliers and part numbers were given in the plans for these, so there was no confusion).



This is the cage that moves along the y-gantry rails and houses the z-axes spindle plate.




This shows the cage in position with the z-axes leadscrew assembly and stepper motor. The rods in the right hand picture are tension rods to press the bearings into the rails and allow the cage to run smoothly along the y-gantry black piping.




and here's the z-axes complete with spindle plate. The metal band at the front is used to clamp the router onto the spindle plate (as you can see in the picture below).




So, I think all I have left to do is to wire up the steppers, controller board and power supply; connect these to a computer (I'm planning to use linuxcnc on an old disused laptop - so old it has a parallel port!) and then work out how to use the software. Can't wait to carve out my first test pattern!

Saturday, July 31, 2010

Rescuing a CedarWorks Swing Set


We had the good fortune recently of being offered an old play-structure by a lovely couple who'd recently bought a house with it in the garden, but their kid was too old for it. They'd tried to give it away a few times over the last year or so, but no one who came to look at it had any clue how to take it apart - I'm beginning to suspect that they were just sensible and realised how much work would be involved in deconstructing and reconstructing it all ;)

It was completely worth the effort though. These CedarWorks play-structures are fantastic (seriously, check out that link, it's like swing set porn) and there's no way our kids would ever have had anything like this under other circumstances. We managed to salvage the whole thing for about the cost of the metal steering wheel it came with (~$160).

I took a look and thought, yeah, that'll come apart easy and should squeeze in our back-yard. So the missus and I went down one Sunday with a big U-Haul truck (one of these) and spent about 4 1/2 hours taking it apart with the help of the original owners (and Jessen and Lani who were looking after the filthwizards). We'd actually been down the day before to show the kids and to get started (we spent about 1 1/2 hours there that day). These things are definitely built to stay up!

Most of it was pretty straightforward to deconstruct, it's mostly held together by long bolts and hex-screws. The hardest part was removing all the dowel rods... These were all kept in place with nails driven through the main posts... this turned out to be the biggest pita time-sink of the day. I ended up clearing some of the wood around each of the nail heads by hammering a 7mm socket around the top of them and then using a claw hammer to pull the nail out. We left parts of the structure intact (the smaller tower, the monkey bars and 3 rows of the larger tower). Phew! That was quite hard in the midday sunshine... and guess who forgot his hat! Doh!

We did joke a couple of times that we may have landed ourselves some very elaborate firewood.

Here it is, taken apart and stored down the side of our house waiting for some attention (both of us quietly hoping not of the bonfire variety):


Whilst taking it apart we found that the lower 6 inches of the structure was rotten (including the A-frame support beams/crossmembers) so we'd have to come up with a plan for fixing it up. A few of the dowels were rotten as well and one of them wouldn't come out, so we ended up sawing it in half in order to get the frame apart and out of the garden.


We decided to stain the wood to protect it from further water damage and to make it look a bit nicer. We picked up the stain from Home Depot (Red, Brown and a small pot of green for the horse swing) and set to work.


It took a couple of weeks of preparation (mainly painting and grabbing some supplies) and an entire weekend of painting, sawing, hammering, drilling, lifting, squeezing, sneezing, spluttering (I got a lot of sawdust up my nose and in my mouth) and standing on-top of things with my mate, Jessen, bashing away with a big rubber mallet to get it finished and in a good state to play on. I sawed off the lower 6" or so of the entire structure (16 vertical legs and 3 A-frame legs) and replaced the unsalvageable, A-frame crossmembers with some 8' 4"x4" from Home Depot.

It was going dark on Monday night by the time the kids got a chance to test it out - They were very excited and I had to fend them off for a little while whilst finishing up the A-frames. You would have thought the sight of me running back and forth with a big drill in the twilight would have been intimidating enough... apparently not.


Well, it's still not quite finished. The platforms that go inside the main structure still need sanding and painting, but we can do those piecemeal. Hopefully this means I've got some time to get back to building that CNC machine!

It feels like we're pretty good at not necessarily biting off more than we can chew, but rather biting off enough to give us very sore jaws... It really felt worthwhile when Ffion came running over and hugged my leg, saying "you're the best dad ever!" and Carys shouts out (from the apex of a high swing) "This is AWESOME!". Yeah fine... they have me wrapped around their little fingers...


Wednesday, June 23, 2010

CNC Machine Build - Part I



I've started a 'little' project that promises to take up most of my free time (what little there seems to be of it at the moment) - I've decided to build a CNC machine.

To be honest, I've had gadget lust for a CNC machine for some time now... all the talk on the blogs about Cupcakes and Makerbots and RepRaps got me looking into CNC machines some time ago. I could never bring myself to spend the money on one though since they're a little pricey. The cheapest options that looked any good were the Zen Toolworks machines, which came with stepper motors but no power supply, controller boards or router/spindle. The cheapest of these can be got from Amazon for under 350 dollars. Still, it only works on a 7"x7"x2" area. The next machine up is around $600 and works on a larger area of 12"x12"x2". At this price I get a little scared and only being able to carve a foot is a little disapointing.

Anyway, I held off for ages but then came across these plans at solsylva.com which detailed the construction of a CNC machine that would cost a little bit more than the larger zen toolworks one (all inclusive), would use mostly materials from Lowes or Home Despot and also promised to be pretty easy to follow (a definite bonus for me, since I chose to do needlework and cookery rather than woodwork and metalwork when given the choice at age 13...). I've seen lots of online instructions for building various types of CNC machine (like this one, and this one, and this one... well, you get the idea), but they all left me a bit confused and unconfident about being able to build something worthwhile.

The promise of the solsylva plans were enough to make me order the 25"x25"x7" plans to see if they were idiot proof enough to give me the confidence to get started.

I received the plans a few weeks ago, read them over and then excitedly started to spend money on wood, bolts, washers, screws, pipes, all thread (threaded rod), forstner bits and skate bearings. So, yes, they appeared to be detailed and simple enough for me to follow from start to finish.

I like the fact that the solsylva plans allow for someone who doesn't have a truck. The wood measurements are for planks 8' and smaller, which fit fine in my little Nissan disappointment (with the back seats down). Recently I've been taking advantage of craigslist in order to pick up a few power tools on the cheap. I got hold of a drill-press ($50) and a miter saw ($60), which have been very useful so far. You'll laugh at me, but they were a bit intimidating to use at first - especially the miter saw. I kept having these images running through my mind of flying fingers and trips to the ER (in my defense, the miter saw is very loud). After a bit of practice I've become flamboyantly reckless much more confident. I'm definitely enjoying learning the new skills involved.

The pictures at the start of this post are the main base of the machine, put together over a few hours on the weekend. In the picture below I've added the X-rails and X-stepper motor support (this was done on the following weekend).



So far, it seems that things are going well. I'll keep you posted.

Wednesday, June 16, 2010

Upcycling: wine rack to doll bed



We found this little wine rack in the local thrift store (savers). Lin thought it'd be cool to turn it into a bed for the kids baby dolls. We bought an American Girl doll crib ages ago at a garage sale that was made of plastic and it inevitably fell to pieces... So the idea of the girls playing with a more sturdy one that I'd made was appealing, especially since they had a lot of make believe fun with the old one.

The idea was very simple: Take the rack apart, stick it back together again with some wood-glue for added strength, cut out a base, screw this on and then paint.

I was going to make a crib by adding doweling bars between the cross beams, but the way the rack was put together made this a bit too fiddly so I decided to just replace the bottom beams and make a baby bed instead.

I sanded the pieces to get rid of some of the murky dirt. Then I painted on some wood-glue to the ends of the beams, reattached them and left it all to dry overnight (with a toolbox weighing it all down from above so that it'd set straight).



I used one of our "new" purchases (a very old scroll saw) to cut out a base. Very straightforward really, just measure the distances on the wine rack, mark those out on some wood and then cut.



Ooo look, a rectangular bit of wood ;)

I drilled out holes at the points where the new base board met the cross beams and then fixed the base to the frame using some wood screws.



Then I let the kids paint on a layer of primer. I think they quite enjoyed it.




After the primer had dried I painted on a coat of gloss. Hopefully that'll keep it in good condition for a while.

I wasn't sure if the kids were taken with it or not until the next morning when a couple of their friends came over for a play date. "Dylan! Dylan! Come and see! I've got something AMAZING to show you!" cried Carys. To be honest I wasn't sure what she was going to show off, but was very touched to find out that it was the baby bed we'd made. Poor Dylan was a little bemused as to why she was so excited ;)

Monday, May 17, 2010

Pixie-Dust Bottles




It occurred to me whilst making some RGB nightlights for the kids that it'd be fun if they could make the lights change to whatever colour they wanted; kinda like the Philips LivingColors lamp, but about $100 cheaper. Lin suggested that having a few of these (say 5 - 7) would give the kids more room for imaginative fun, so I set about making a prototype and then a few more when that was up and working.

The kids love them (which is always good) and have been claiming that the bottles contain pixie dust (hence the title of this post).

Can you guess what Ffion's favourite colour is? She claims that this is the 'right colour' for pixie dust.


The hardware is pretty straight forward. I used a potentiometer with an in-built on/off switch, like this one, to simplify things. I thought it'd look much nicer than having a separate switch. The rest of the parts are the same as for the RGB nightlights project. The trickiest part was the coding, mainly because I'm doing it late at night when my brain isn't working quite so well...

Ingredients:



1. Potentiometer with switch
2. ATtiny45
3. 8-pin IC socket
4. coin cell battery holder
5. RGB LED (common anode) - I bought mine from EMSL. These are 10mm diffused RGB LEDs.
6. hookup wire, solder etc.

Methods:

I soldered the coin cell holder onto the potentiometer first.

Then I hooked up the RGB LED to the DIP socket. I'm using common anode LEDs so the long LED lead is soldered onto pin 8 of the IC socket. I have the RGB channels/leads connected to pins 5, 6 and 7 and the potentiometer output (middle pin from the pot) connected to pin 3.




After that, all you have to do is solder on the potentiometer's middle terminal to the IC socket and finish off connecting the ground and power connections.




And there we have it. Some kind of strange Borg eye ready to be put somewhere.

We had some plastic kids drink bottles sitting in the recycling bin - they're made from white plastic so I thought they'd diffuse the light nicely. I drilled a hole in the bottle cap for the potentiometer shaft and fitted it all together. Finally, I added a knob (radioshack purchase) to make it a bit prettier and easier to use.



Coding:

I'd already worked out how to do the software PWM (pulse width modulation) and how to measure a variable voltage input using ADC (analogue to digital conversion) so all that needed to be figured out, for this project, was how to map the ADC input values to the desired range of colours.

I wanted to let the kids cycle through the entire spectrum in much the same way the previous night-lights cycled automatically.

So, in the RGB nightlights project there were 6 transitions/steps:
stepRed channel valueGreen channel valueBlue channel valuechanging channelcolour range
125500increase GreenRed to Yellow
22552550decrease RedYellow to Green
302550increase BlueGreen to Cyan
40255255decrease GreenCyan to Blue
500255increase RedBlue to Purple
62550255decrease BluePurple to Red


If we use a 10-bit ADC we have 1024 values (2^10) available for mapping to colours in the above steps. This means that each step can contain 170 values/colours (1024/6 = 170.666...).

So, to map the ADC value to a colour we first assign it to one of the 6 steps and then use it to determine the value of the varying channel (Red/Green/Blue) for that step.

There are 6 steps and each step can have 170 ADC values associated with it. So I binned the ADC values into steps like so:
stepADC value
1< 170
2< 342
3< 512
4< 683
5< 854
6>= 854


Here's an example to clarify: Say the potentiometer is set just over half way, then the ADC value should be between 512 and 683; this would put us in step 4 where the red channel is off, the blue channel is completely on (255) and the green channel is varying (in this step the green levels are decreasing from 255 -> 0 as the ADC value increases from 512 -> 683). We calculate the green level by translating the ADC range to 0 - 170 (in this case by subtracting 512) and then multiplying by a scaling factor (255/170) to transform the 0 -> 170 range to a 0 -> 255 range. If we're increasing the level of the channel (steps 1, 3 and 5) then we just use this scaled value as the channel value. If we're decreasing the level of the channel (as is the case for step 4) then we inverse the scaled value by subtracting it from 255.

Here's the bit of code that sets the RGB values (see the complete listing here: selectableColourLight.c):

#define SCALING_RANGE 170
#define SCALING_FACTOR 255/SCALING_RANGE

...

void setRgbLevels(uint16_t pValue)
{
 if(pValue < SCALING_RANGE)
 {
  mRgbValues[RED_INDEX]   = 255;
  mRgbValues[GREEN_INDEX] = pValue * SCALING_FACTOR;
  mRgbValues[BLUE_INDEX]  = 0;

 }
 else if(pValue < 342) //SCALING_RANGE * 2
 {
  mRgbValues[RED_INDEX]   = 255 - ((pValue - SCALING_RANGE) * SCALING_FACTOR);
  mRgbValues[GREEN_INDEX] = 255;
  mRgbValues[BLUE_INDEX]  = 0;
 }
 else if(pValue < 512) //SCALING_RANGE * 3
 {
  mRgbValues[RED_INDEX]   = 0;
  mRgbValues[GREEN_INDEX] = 255;
  mRgbValues[BLUE_INDEX]  = (pValue - 342) * SCALING_FACTOR;
 }
 else if(pValue < 683)//SCALING_RANGE * 4
 {
  mRgbValues[RED_INDEX]   = 0;
  mRgbValues[GREEN_INDEX] = 255 - ((pValue - 512) * SCALING_FACTOR);
  mRgbValues[BLUE_INDEX]  = 255;
 }
 else if(pValue < 854)//SCALING_RANGE * 5
 {
  mRgbValues[RED_INDEX]   = (pValue - 683) * SCALING_FACTOR;
  mRgbValues[GREEN_INDEX] = 0;
  mRgbValues[BLUE_INDEX]  = 255;
 }
 else
 {
  mRgbValues[RED_INDEX]   = 255;
  mRgbValues[GREEN_INDEX] = 0;
  mRgbValues[BLUE_INDEX]  = 255 - ((pValue - 854) * SCALING_FACTOR);
 }
}

Monday, March 22, 2010

Saving a Disney Princess Remote Controlled Car

During a trip to Savers I spotted this Disney princess car:

I noticed the sensors in the head and tail lights, they looked like IR receivers. At first I thought the LED in the body of the car was an IR LED and that the IR receivers detected the IR light bouncing off objects in the cars path (not that the tail lights would make much sense in this context), but when I got it home and put batteries in it, the LED turned out to be just a colour changing LED put there for decoration.

A while back I headed over to Noisebride on a Monday night to check out their circuit hacking/soldering workshop (hosted by Mich Altman). During the workshop I put together one of Mitch's kits - "The Trippy RGB Waves" kit (here's my Noisebridge post if you're interested in reading about the experience). The point is that this gizmo uses an IR LED and an IR receiver to detect overhead objects. The LED pulses IR light at 38KHz (not to be confused with the actual frequency of IR light which is ~ 3THz or 3 x 1012 Hz) which the IR receiver detects if there's an object above the LED reflecting the pulses back down.

I wondered if the car has a similar set-up and was just missing the remote control (which would have a pulsing IR LED). First off I tried a regular remote control, which had no effect so then I tried pointing the Trippy RGB LED kit at the car and voila! It reacted to the light. So, I set about creating a wand/gun for the kids to use to interact with the car.

First off I tried setting up a 555 timer to pulse an IR LED at 38KHz. It worked but the signal was weak (maybe I got the values off a little). I decided to use a microcontroller instead. The ATtiny range are pretty cheap - I bought some ATtiny45s for $1.20 each which is ~3x the cost of a 555. The hardest part was finding/creating a housing for the circuit. I looked around and decided to make my own out of PVC piping. They look like tiny guns and work a treat :)



Methods:


Here are the final "guns".



Ingredients:


The pipe is 1/2" PVC piping from Lowes (Home Depot have it too).
  • PVC elbow joint
  • PVC pipe (cut to a v.small length 1 1/2")
  • PVC pipe cap
  • Coin battery holder (3v, 20mm)
  • 8-pin DIP socket
  • momentary push button
  • IR LED
  • ATtiny45 (originally made with an ATtiny13).

The plastic dome is the case from a 25c toy from our local taqueria. The base fits snuggly on the end of the elbow joint and I've used it to cover the battery holder in the final 'product'. The piping paraphernalia was all left over from the marshmallow-gun fun.

The wiring is all very straightforward. The hardest part was adjusting the elbow joint so that my coin cell holders fitted snuggly inside (and getting the pushbutton in place).

So, first off is to drill some holes: 1 in the end cap for the LED and one in the elbow joint for the pushbutton. Then I used a rotary tool (Proxxon) to carve out some of the innards of the elbow joint until the battery holder fitted snuggly inside.

Then I soldered one short and one long lead to the pushbutton and fitted it into the elbow joint (see below).



Then I soldered a long ground lead to the battery holder and connected the short positive wire from the pushbutton and placed the battery holder in the end of the elbow joint.



Solder on the DIP socket. Using a socket was a great choice for me because it turns out that the code I was running was not getting the best results from the car. Having the socket let me replace the uC after I'd worked out the kinks. I guess it'll also let me easily recover the uC when the kids are bored of this toy. I stripped a little bit of insulation from near to the end of the ground lead and soldered it to the ground pin (rather than adding a couple of wire ends at that point).



Then it's just a matter of connecting the LED, placing the uC in the socket and fitting the remaining piping.





I made two so both girls could play. Although that also opens up a huge opportunity to fight over who's in control as well...



And here's the code (for some reason the car reacted best if the IR was pulsed for ~170 microseconds with a 400 microsecond pause before the next set of pulses):
/*
* IrLedPulse.c
*
* Distributed under Creative Commons 3.0 -- Attib & Share Alike
*
* Created on: Dec 26, 2009
* Author: Paul
*/
#include <avr/io.h>
#include <avr/delay.h>

#ifndef F_CPU
#define F_CPU 1000000UL
#endif


// Use Timer 0 to pulse the IR LED at 38KHz
void pulseIr()
{
TCCR0A = 0 | (1 << COM0A0) | (1 << WGM01); // COM0A0=1 to toggle OC0A on Compare Match

TCCR0B = 0 | (1 << CS01); // 1/8 prescale
OCR0A = 104; // to output 38KHz on OC0A (PB0, pin 5)

_delay_us(170); // delay 170 microseconds

// turn off Timer0 to stop 38KHz pulsing of IR
TCCR0B = 0; // Stop Timer0 (turn off IR emitter)
TCCR0A = 0; // Disconnect OC0A from PB0 (pin 5)
}

int main(void)
{
DDRB |= (1 << PB0); // set PB0 to output
PORTB = 0xFF; // all PORTB output pins high (LED off).
while(1)
{
pulseIr();
_delay_us(400);
}
}