Printsense

The CAD files for this post are available here

This week, I did an experiment to sense when the print completed. In order to do this, I needed to consider the following:

1. What actions occur when a print ends?

2. What sensors can we use to detect those actions?

3. How can those sensors be incorporated into a print?

A few weeks ago, I got my hands on SparkFun’s ProtoSnap – Pro Mini, which consists of an Arduino mini, a light sensor, an LED, a buzzer, and a pushbutton all on one board, which you can test easily and then snap apart once you’re done with testing code. One thing that you probably already know about coprocessing is that you use the printer head to cover non printed material. Via a suggestion from my faculty adviser, I decided to look into using the light sensor to detect the end of the print. So after some programming and debugging, I managed to stick a battery, Arduino mini, light sensor, and LED into my print job to make a “print detection” sensor.

Coprocessing an Arduino Mini, an RGB LED, batteries, and a light sensor into the print.
Coprocessing an Arduino Mini, an RGB LED, batteries, and a light sensor into the print.

The printer prints over the light sensor, and once the sensor has detected that it is fully covered, it waits for about a minute, and then turns the light on.

The print covered the light sensor, and via the Arduino mini, the LED turned on!
The print covered the light sensor, and via the Arduino mini, the LED turned on!

This experiment is a proof of concept about sensing when the print is done via coprocessed components. To iterate on this experiment, the Arduino, instead of turning on a light, could do something else, say, turn on a motor, which is a system I designed in a previous blog post without the sensor.

The one issue that I faced involved removing components from the coprocessed part. I have been designing all of my parts for ease of disassembly, because I am going through lots of iterations on coprocessed parts and I don’t want to have to buy dozens of Arduinos. but the light sensor needed to be enclosed to work. So I ran into some issues getting it out.

The light sensor stuck in my print job. After some careful work with an exacto knife, I was able to remove the covering.
The light sensor stuck in my print job. After some careful work with an exacto knife, I was able to remove the covering.

Apart from that issue, the sensor worked great! I’ll be using this system to get prints to move themselves off the build plate and iterate on past designs.

Here is the arduino code, I’ll have a github running so it will be cleaner soon:

int redPin = 3; // red RGB LED
int greenPin = 5; // green RGB LED
int bluePin = 6; // blue RGB LED
int lightPin = A0; // Light sensor’s connected to analog pin 0
int lightReading; // variable we’ll use to store light sensor reading
int LightValues[200]; // array of light values
int islight=0; //either a 1 or a 0, depending on the state of the sensor
int i = 0; //iterating integer in the for loop
int count=0; //counts how many times the loop has run
int sum=0; //sum of the last number of values in the array
const int time = 120; //seconds to wait before the light turns on

void setup() {
Serial.begin(9600);
//sets up the RGB LED as an output
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);

//turns the LED all off
analogWrite(redPin, 255); //
analogWrite(greenPin, 255); //
analogWrite(bluePin, 255); //
}

void loop() {
lightReading = analogRead(lightPin); // read the light sensor
delay(1000); // delay for a second
if (lightReading <= 50){
islight = 1;} //if sensor is covered
else{
islight = 0;} //if sensor is not covered
Serial.println(islight);
LightValues[count]=islight; //fill up array with light values
if (count>=time){ //if array is longer than the time, it starts to check
sum=0;
for (i=0; i<=time; i++){
sum += LightValues[count-i];} //sums previous values of the array
if (sum >= time-10){ //if the sum is greater than time values, the lights turned on
analogWrite(redPin, 0); // Turn the red LED all the way on
analogWrite(greenPin, 0); // Turn green fully on
analogWrite(bluePin, 0); // turn blue on
}
else{
analogWrite(redPin, 255); // Turn the red LED all the way on
analogWrite(greenPin, 255); // Turn green fully on
analogWrite(bluePin, 255); // turn blue on
}}
count+=1;
}

Happy printing! Alex

Advertisements

One thought on “Printsense

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s