I’m an Arduino-head

November 10, 2011

For Hallowe’en just gone I printed out an Elvis Skull with blue PLA from Ultimachine. I had some trouble with missed steps early on due to my SFACT not being well calibrated and causing the printer to push out more filament than needed… but I tried to correct the position a few times… with mixed results. Nevertheless it was usable so I drilled out some holes in the eyes/nose and popped in some blue LED’s that were lying around. I had modified the arduino fade sketch to control some laser diodes so I put it to use to make the LEDs glow in a slightly spooky fashion. The kids loved it!

The LEDs pulse 6 times with slightly longer on-times for each successive pulse and at the end they rapidly flash a few times individually. Lather, rinse, repeat.  Here’s the modified code:

/*
This is a variation of Fade from http://www.arduino.cc/en/Tutorial
The no of pulses, their ramping up/down and 'full-on' times can be set.
*/

// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin

// variables will change:

int brightness = 0; // how bright the LED is

/***** main pulse parameters here: pulse ramping, on-time and no of pulses *****/
int pulses = 6; //no of pulses per burst
int maxtime = 100; // time pulse is at max value: 'full-on'
int upduration = 1020; //pulse ramp-up duration in ms
int dnduration = 255; //pulse ramp-down duration in ms

// parameters for ramping output up to max from zero
int upfadeStep = 5; // how many points to fade by
int upfadeAmount = upfadeStep;
int upsteps = (255/upfadeAmount);
int updelaytime = upduration / upsteps;// delay to give above pulse duration

// parameters for ramping output from max back down to zero
int dnfadeStep = 5; // how many points to fade by
int dnfadeAmount = dnfadeStep;
int dnsteps = (255/dnfadeAmount);
int dndelaytime = dnduration / dnsteps;// delay to give above pulse duration

void setup() {
// initialize the LED pin as an output:
// pinMode(ledPin, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);

}

void loop(){
brightness = 5;
// turn LED on:
digitalWrite(ledPin, HIGH);
maxtime = 500;

for(int p=0;p< pulses; p++){

brightness = 5;
upfadeAmount = upfadeStep;
for (int i=0; i< upsteps; i++){
analogWrite(9, brightness);
analogWrite(10, brightness);
analogWrite(11, brightness);

// change the brightness for next time through the loop:
brightness = brightness + upfadeAmount;

// reverse the direction of the fading at the ends of the fade:
// if (brightness == 0 || brightness == 255) {
// fadeAmount = -fadeAmount ;
//}
// wait for 30 milliseconds to see the dimming effect
delay(updelaytime);
}
brightness = 255;
analogWrite(9, brightness);
analogWrite(10, brightness);
analogWrite(11, brightness);
delay(maxtime);
dnfadeAmount = dnfadeStep;
for (int j=0; j< dnsteps; j++){

// reverse the direction of the fading at the ends of the fade:
if (brightness == 5 || brightness == 255) {
dnfadeAmount = -dnfadeAmount ;
}
// change the brightness for this time through the loop:
brightness = brightness + dnfadeAmount;

analogWrite(9, brightness);
analogWrite(10, brightness);
analogWrite(11, brightness);
// wait for 30 milliseconds to see the dimming effect
delay(dndelaytime);
}

brightness = 5;
analogWrite(9, brightness);
analogWrite(10, brightness);
analogWrite(11, brightness);
maxtime = maxtime * 1.5;
}
// code to flash LEDs individually at end of fading cycle
for (int k=0; k< 5; k++){
analogWrite(9, 255);
delay(100);
analogWrite(9, 0);
delay(25);
}
analogWrite(9, 5);

for (int l=0; l< 5; l++){
analogWrite(10, 255);
delay(100);
analogWrite(10, 0);
delay(25);
}
analogWrite(10, 5);

for (int m=0; m< 5; m++){
analogWrite(11, 255);
delay(100);
analogWrite(11, 0);
delay(25);
}
analogWrite(9, 0);
analogWrite(10, 0);
analogWrite(11, 0);
delay(3000);
}

I imagine there are neater ways to code it but it does the job. I’ve been messing with controlling it from an Android smartphone using Python (SL4A) and a bluesmirf bluetooth module. More on that in a future post.

Advertisements

Prusa Mendel up and running

April 22, 2011

After almost 3 weeks of printing the parts using my Repstrap I’ve finally got a RepRap! 13 mm/s was the top speed of the repstrap, limited by the leadscrews…. the Prusa will be limited by the extruders ability to keep up but I’ve been printing at 30 mm/s for now as 50 mm/s was a little sparse and any faster and its difficult to see whats happening (I’m used to slow prints remember!) .

I’ve also printed out an Accessible Wade’s Extruder by GregFrost to replace the plywood extruder.

Here is the printer…

and the extruder…

So its back to some optimising…. happy days.

Recently I bought a micro SD card reader from Kliment (hes always in #reprap irc channel), so when I’ve the skeinforge settings under control I’ll upload his firmware and print from SD which will make life easier for my rusty old pc.


my repstrap’s first printout!

February 24, 2011

In the past few days I’ve tested the hotend (pla is melting nicely from 200 degrees C upwards) and I’m happy enough with that. I’ve also installed and leveled the dibond bed – this post has good pointers to help. I’ve setup the opto-endstops and I have a build envelope of  approx 195x135x100. I’ll post photos in a few days.  At the end of all that today, I managed to print a small 10 mm cube (designed in 3 seconds in openscad):

This was printed onto kapton tape (heated bed not yet setup) and obviously theres plenty of fun optimisation to be done…. but its nice to finally print a solid object 8)

Printer settings were mostly Araspitfire’s with a feed rate of 5, flow rate of 10 and max z speed of 2 (all mm/s I believe) as I didn’t want to push things too hard just yet (i have heatsinks to bond to the pololu drivers for doing that!).