Wednesday 25 December 2013

3D printer problems.

Seriously, who thought it would be a good idea to base a whole system around uploading an arduino sketch to something which isn't an arduino? Really not a happy chappy right now. If you hadn't already worked it out I've recently bought a 3D printer. It's a RepRap Prusa Mendel I2 from GeeeTech and it has a Sanguinololu 1.3a electronics board with an ATMEL ATMEGA1284P processor.

The whole thing has been a bit of a disaster really. When I first bought it off eBay I thought I was getting a really great deal and that I'd be printing in no time. Not so. A week after I paid for it, another similar printer appeared which could print four times more accurately and cost $200 less and when it cost a few hundred, that really makes a difference, so I wasn't too happy about that. The seller I bought it from said that they ship within 48 hours of receiving payment but after a week of waiting I spoke to them and asked what was going on, they grovelled and atoned and after yet another week it was finally on its way. Two more weeks later it arrived and I was beside myself with anticipation.

It came in kit form and I put it together over a weekend using the general plans on the RepRap Wiki. It was only after I finished it that I discovered there were plans for the exact model I had. You see, although it's an open source design and they should all be the same, each manufacturer makes lots of little changes to the ones they produce. What this means is that the general plans are useless, and that there were lots of little mistakes in mine. So I fixed the ones I could be bothered to fix and left it at that. But really, my troubles hadn't even started yet.

The fully assembled printer with everything but electronics. 

The way the whole software works on a 3D printer is fairly simple. The processor chip has a bootloader on it which allows you to actually use it and upload programs to it. Then there is the firmware which takes the form of a program, specifically an arduino sketch, this is what takes the instructions of what must be printed where and translates that into motor movements and this has to be calibrated and have various parameters set. The instructions of what must be printed where is stored in a file and is usually called G-code. The G-code is worked out by a 3D CAD program on a computer from a model of whatever your printing. Okay well maybe it's not that simple but the problem I'm having is getting the firmware onto the chip. Once you have the right software installed it should be a simple matter of configuring the firmware and uploading it to the controller board but whenever I try to do that I just get an "uploading" message for about ten minutes and then it times out without having uploaded anything.

I tried lots of different settings and software and got some help from some friends but no matter what I tried the error wouldn't go away. I got so desperate that I went to my local hackerspace for help because I knew they had a 3D printer there and that the place is full of nerds. I figured if they couldn't fix it, no one could. After a couple of hours of fiddling around with it they determined the problem was most likely the FTDI chip which allows the computer to communicate with the controller. Unfortunately this renders the whole board basically useless so because I know my arduino MEGA2560 works I'm going to use that instead and buy a 3D printer shield for it. So until that arrives, printer progress is halted.
I'll catch up with you again soon, cheers.

Sunday 29 September 2013

Sine method.

Another method I've recently made in java is a sine (sin) method which returns the sin value of a number.

public double sin(double angle, String type)
    {
        double length = 0, x;
        if(type == "deg")                                //Change to radians if not already
        {
            angle = (angle/180)*(Math.PI);
        }
       
        x = angle;                                          // x is easier to work with than a word
       
        while(x > Math.PI)                            //Bring x into the accurately represented range.
        {
            x = x-(2*Math.PI);
        }
       
        while(x < -Math.PI)
        {
            x = x+(2*Math.PI);
        }
       
        //The polinomial calculation
        length = (x-(Math.pow(x, 3)/6)+(Math.pow(x, 5)/120)-(Math.pow(x, 7)/5040)+(Math.pow(x, 9)/(362880))-(Math.pow(x, 11)/39916800));
           
        return length;
    }

This is where maths and technology come together beautifully. You see, a computer is a very stupid thing, literally the only piece of maths it can do at it's most basic level is add. Luckily maths at its most basic level is also just adding. So to do other maths functions we need to add in a certain way a certain number of times. For example subtraction is just adding a negative number, multiplication is just adding a number several times. You get the idea. However trigonometry functions(sin, cos, tan etc) are different, they cannot be calculated using addition alone so they pose a serious problem to computers. This is where maths comes to the rescue. In the area of sequences and series there is a special kind of series called a Maclaurin series, I won't bore you with how it's calculated but the great thing about them is that they can be used to model other functions in maths, like sin, with only the use of adding! Here's the formula for them:
f(x) = f(0)+ f '(0)*x + f "(0)* x^2/2!+ f "'(0)*x^3/3!+...+ f(n)(0)*x^n/n!+....
I say "model" because this formula is almost never totally precise but it's pretty good. If you were to work out this formula to infinite terms ie: n = ∞, then you would get an exact answer but we don't have enough time to do that, not even with a very very fast computer. It's alright to stop calculating at about the fifteenth term because the number you calculate would be accurate to about the tenth decimal place which is plenty for most applications. So when you do a trig function on your calculator it's not actually giving you back the trig function, just something very much like it.
When you actually implement a piece of code to calculate sin you have to handle the input number being greater than PI or less than -PI because sin goes for ever to infinity and to negative infinity and the pattern repeats every 2PI. The polynomial which is the Maclaurin series only accurately models sin from about -PI to PI which means if the input number passed into the method is grater than Pi you have to subtract 2PI from it over and over again until the number is within the accurate range. Or if it's less that -PI, you must add 2PI onto it until it's within range. Doing this doesn't change the output number because the value at any one point is equal to the value at that point +/- 2PI. It's a repeating pattern.

This is what y = sin(x) looks like.


 This is what the Maclaurin series representation of y = sin(x) looks like.

And this is them laid on top of one another. As you can see, they're basically identical from about   - 4 to 4.

Sunday 18 August 2013

Factorial method.

One of the things we have been learning about in computer science at college is using methods in programming. Methods are an absolute god-send. Rather than having to write big long strings of code, instead you can group a small chunk together and give it a name, and then retrieve that small piece of code at any time with just one line.
Here is an example method.

int a_plus_b;

Public void add(int a, int b)
{
                a_plus_b = a + b;             
}

"Int a_plus_b" is a global variable, that means it can be used or changed at anytime, anywhere in the program. The bit between the curly brackets is the code that the method executes. ‘a’ and ‘b’ are the formal parameters of the method. "Public" means the method can be called from anywhere in the program. "Void" means the method doesn’t return a value.  "add" is simply the name of the method and this could be anything you like, it could be "pony" or "omnibus", but it's convention to call methods something to do with what they do. "Int a_plus_b" isn’t part of the method, but I had to declare that variable. "Int" just means that the variable type is a number. To implement or "call" this method you would write the following line:

add(2, 3);

Where 2 and 3 are the actual parameters you put into the method but these can be any number you want. So when you write “ add(2, 3); ” the value of “a_plus_b” becomes 5, similarly if you were to write “ add(18, 5) “, “a_plus_b” would be equal to 23.


This is a method I wrote to return the factorial of a number.
If you don't know what a factorial is, it is when you multiply a number by each number that comes before it. The symbol for factorial is '!'. So, 3! = 3x2x1 = 6. Similarly 5! = 5x4x3x2x1 = 120.

public int factorial(int a)                 //Method declaration. The input to this method must be
{                                                  // an integer (a)
int afact = 1;                                 //afact will be used to generate the factorial and will     
    //be equal to the factorial of a.
boolean neg = false;                      //Declaration of a Boolean variable to state if ‘a’ is positive
                                                    //or negative.
if(a < 0)                                        //If a is negative (less than zero) neg, which stands for                                                     //negative will be set to true.
    //else it will stay as false.
{
                neg = true;
                a*= -1;                        //If a is negative, it must be changed to positive.
}

if(a == 0)                                     //The factorial of 0 is one, so if a is 0, afact must be 1.
{
                afact = 1;
}
else                                               //a will only get here if it is a positive integer.
{
                while(a >= 1)                 //In the while loop, afact gets multiplied by (a) and then
     //(a-1), and then (a-2) and so on down to 2 and 1.
                {
                                afact=afact*a;
                                a--;
                }
}
                               
if(neg == true)                               //Finally, if the input number was negative, which was
   //checked for earlier, the output number gets changed to 
   //negative.
{
                afact*= -1;
}
return afact;

}

And that is how you calculate a factorial, at least it’s one way, there are more mathematically precise ways of doing it, but this method works for integers and I’m happy with it. A few weeks after I wrote this method, my teacher taught the whole class a factorial method which was amusing for me as I’d already written this one.

Saturday 17 August 2013

ALBATROSS!!!

It’s been a long time since I’ve posted here, more than six months in fact. But I’ve been very busy with college work lately so I haven’t had much time to make things. So rest assured I haven’t forgotten about this blog, I’m just concentrating on school at the moment. I’m currently studying maths specialised, physics, advanced electronics and computer science at college. For you American readers out there, that’s a Tasmanian college, it’s not like a university. It’s years 11 and 12, just before university. We’ve just had our mid-year exams and I thought this was a good time to write about my most recent project.

A few weeks ago my friend had a fancy dress birthday party, I went as the albatross seller as played by John Cleese in Monty Python. It’s something I’ve always wanted to do, don’t judge me. The outfit wasn’t difficult to find, I just went to a costume hire shop but the albatross proved to be much harder. Weeks before the event, I scoured the internet looking for stuffed toy albatrosses. Or any sort of albatross at all. I looked through EBay, model shops, toy shops and Monty Python even had their own albatross-in-a-tray plush toy. But there was nothing in stock or in my price range anywhere. Buying albatrosses is harder than you might imagine! So in a moment of desperation, I decided to make the damn thing myself.

John Cleese (left) and Terry Jones (right) Performing live at the Hollywood bowl.
This is pretty much what I looked like on the night. 
 Here is a link to that Performance, and a warning, this does contain coarse language.

The first thing I had to do was decide what materials to make it out of. To start with, all of this was very hard for me; I hadn’t made a model of an animal since grade 2. That was a Platypus and it was made from chicken wire and paper mache. After talking to some of my more artistic friends, who do this sort of thing a lot, chicken wire and paper mache is what I went for. I made a wire frame in the general shape of an albatross, just based on pictures from the internet. It has a wingspan slightly narrower than a doorway; I did this deliberately just to make it practical. 

The wire frame then had to be covered with chicken wire, and for this I used ½ inch hexagonal chicken wire. It wouldn’t be good enough to simply stretch chicken wire over the frame because it would flatten out in the sections between the frame wires. So to give it some “form”, I stuffed the body and part of the wings with tissue paper. That certainly made it more "solid".

I’m not really sure why I did this, it just seemed right at the time. I covered the whole thing with masking tape. I think it was to smooth-out the surface a bit before applying the paper mache. If that is indeed what it was for, it certainly seemed to work.

The tail was very satisfying, it looks really nice but it was so simple to make. All I did was poke wooden skewers into the rear end in a sort-of fan pattern and then put masking tape over it. I think the effect works really well. 

The paper mache was pretty easy. It was suggested to me to use PVA mixed 50/50 with water and really long strips of paper, again by my artistic friends. 

Next was the beak. At last back to familiar territory, because it’s made from balsa wood. Before I even started to make the frame, I cut out two pieces of 12mm balsa easily big enough to make the beak and glued them together side by side. I made two of these in case I messed the first one up. But the carving and sanding all went fine and it looks just like an albatross beak.



The next thing was to paint it. This is where I needed help; I’m not that good when it comes to painting things artistically, which is what was needed here. So I asked my good friend Kat to paint it for me because she’s really good with those sorts of things and I’m glad I did because, as I’m sure you’ll agree, it looks great! 



The day of the party: First class has just finished, I rush to the shops to buy the rest of the things I need to finish the albatross box, and I then go home in my free to work on it. I still had the box and the straps to make so it was a bit of a rush job. The box is made of 3mm corflute and the straps are just one inch wide red ribbon. The box is simply taped together, nothing fancy, and the straps are stapled on. But it all held together and that night, I had a lot of fun making everyone at La-Porchetta have a good laugh.

Sunday 3 February 2013

RC kart

I've set it up to run now, so the brakes work, the steering works and the fuel and exhaust systems are in place and lately I've been having a little bit of fun, err... I mean practice, at driving it. And I can report that there is plenty of power, there's no shortage on the power front, everything is hunky-dory there. In fact there may be a bit too much power, every time I accelerate the wheels spin and because it has such a short wheel base, the back flicks round and it's facing in the opposite direction in an instant. So there's not much more I an tell you about the handling of this kart because it spends most of the time going round in circles. However I have only tested it on gravel so far and wheel spinning is probably entirely expectable, so I will report back to you the moment I get to test it out on a a proper tarmac surface. And frankly I can't wait, because I expect this to be seriously fast!



You can really see the shape starting to emerge now, especially when you compare it to a picture of the real one. 

Lately I have been working on the go-karts brakes and bodywork. The brakes that I've used are actually for a model motorbike but they are a good scale match for the kart. As you can see in the picture, I had to make some modifications to the brake caliper to make it fit.

To mount the caliper I simply made a small aluminium bracket which bolts onto the left side bearing. It took a long time to make because it has to be in a very specific position. 

The servo which operates the cable operated brakes is mounted on the chassis, exactly where the brake master cylinder is located on the chassis of a real kart.     



The front nose cone, ready for painting. 

This is what the model and the original one look like together. Hopefully the model will end up looking a little less battered and bruised than the real one. 


Monday 21 January 2013

1/3 scale RC Go-Kart


By all measures this project has surely got to be the definition of ambition. The project is to build, from scratch, an RC third scale go-kart on a shoestring budget. I've already spent about three years on it.

Now I realise that, for “RC people”, 1/3 scale may sound very big but you have to remember that a real kart is quite small anyway so it’s about the size of an eighth or tenth scale car, quite manageable.

Why did I decide to build an RC go-kart? Well I love RC, and I like building things and I used to race ‘real’ karts. So I thought why don’t I combine the three and build a remote control go-kart?

You might be thinking why didn't you just buy an RC go-kart? Well there’s no shortage of RC karts on the market, some of them quite cheaply too, take the Turnigy kart: http://www.hobbyking.com/hobbyking/store/__15284__TURNIGY_1_4_Scale_Brushless_GoKart_ARR_.html or for a slightly more expensive option, how about the Kyosho BIREL R31-SE? http://www.kyosho.com/eng/products/rc/detail.html?product_id=104501 And of course there are several others. Now these are all very well but none of them are really true to scale. In terms of their structure, they have mock frames which are there only for aesthetics, and then they have sub-chassis which are load bearing. They also have features that are very different to a real go-kart like the fuel tank in the wrong place, the break disc on the wrong side and in the Turnigy’s case being electric powered. These are things which, in my mind, shake their very identity as go-karts.  They are also not true to scale in a rather more literal sense, let me explain. The Turnigy claims to be 1/4 scale but the Kyosho, which is exactly the same size to within a few millimetres, claims to be 1/5 scale. But in fact they’re both wrong, and I know because I've checked this, they are both about 1/4.5. So how could I be expected to buy something that doesn’t even know what size it is? Another reason I went with the DIY option is that I had a TRAXXAS T-MAXX and I was getting a little board with it so I thought I’d take the engine and radio and so-on out of it and make something else for them. The engine was, in terms of external dimensions, a perfect 1/3 scale match for the full-size kart I had but there was no one who sold 1/3 scale karts, not even 1/3 scale kart chassis. Most of the karts on the market were smaller than 1/3 scale and frankly, I wanted my go-kart to be bigger than that.    

If there is anyone out there selling 1/3 scale karts or someone who has made one, I would love to hear from you. 


This is what it will eventually look like. This is the ‘real’ kart I used to own and race.


For the frame I used 6mm copper tube which is not ideal as it should be 11mm to be true to scale but that’s all I could find, compromises must be made. My thanks to my grandpa who helped me silver solder the chassis. You may have noticed that the steering arms are bamboo skewers, that’s just because I don’t have some threaded rod for them yet.  



The engine I’m using is a Traxxas TRX2.5 which I ripped out of my old T-MAXX. I made the rear axle and stub axles at school where I had access to a lathe. On a real kart the drive is transferred to the axle via chain and sprockets, which means the engine rotates in the same direction as the axle. The problem with the TRX2.5 is that is rotates in the opposite direction to the axle, and it has a gear, not a sprocket. The solution I chose for this was to have the pinion gear on the motor meshed with the spur gear, from the T-MAXX, on the axle. This solution eliminates the need for a chain and sprocket and also reverses the rotation from the engine so the kart actually goes forwards. Unfortunately this means that the drive system is not true to scale but I think it was the best compromise. Another thing that’s a compromise is the rear wheels, well it’s not really a compromise, as there was no other option for them. They are a few millimetres small in diameter, they’re way too narrow and they have studs on them as opposed to racing slicks. The go-kart tire is such a unique shape that there is simply no 1/3 scale substitute. However the studs will come off with a few donuts so I’m not worried there.       



I’ve started working on the body panels now. They will be made from fibreglass even though the real ones are made of plastic; this is because I wanted to make something out of fibreglass as I haven’t used it before, you won’t tell the difference. I’ve made the body panel moulds out of polystyrene and I’ll cover them with fibreglass, and then dissolve away the foam. After that they’ll need a little bit of cleaning up and then they’ll be ready for painting.  



The original nose cone and the 1/3 scale nose cone mould.



Once I laid out the chassis and the body panels, I suddenly got an idea of just how big this model is actually going to be. The rear track is about 415mm and the front, 325. It’s about 530mm in length which is roughly comparable to a 1/10 scale car or off-road truck.