William PageIan Conklin
Published

Is Your 3D Print Sliding?

This is a sensor designed to send a notification to your phone and OLED Remote Screen whenever a 3D print is sliding on the print bed.

IntermediateFull instructions provided5 hours818
Is Your 3D Print Sliding?

Things used in this project

Hardware components

Capacitor 100 µF
Capacitor 100 µF
×1
Sharp GP2Y0A51SK0F Analog Distance Sensor 2-15cm
×2
Photon
Particle Photon
×2
Adafruit Monochrome 0.96" 128x64 OLED graphic display
×1

Software apps and online services

Maker service
IFTTT Maker service

Hand tools and fabrication machines

MP Select Mini 3D Printer

Story

Read more

Custom parts and enclosures

IR Sensor Tower Case Mounting Plate

This is the mounting plate that is screwed onto the top of the printer with the sendor pointing down.

IR Sensor Tower Case Front

This is the housing case for the IR Sensor mounted onto the top of the tower.

IR Sensor Build Plate Case Mounting Plate

This is the mounting plate for mounting the IR Sensor onto the build plate.

IR Sensor Build Plate Front Case

This is the IR Sensor housing that is used for the build plate sensor.

IR Sensor Distance Calibration Female End

This is one of two pieces used to calibrate the voltage output to the distance away from the sensor. It is used by placing the sensor on the plate with the pegs and sliding the plates apart to reach a specific distance.

IR Sensor Calibration Plates Male end with Mounting Pegs

This is one of two pieces used to calibrate the voltage output to the distance away from the sensor. It is used by placing the sensor on the plate with the pegs and sliding the plates apart to reach a specific distance.

Photon-OLED-Bottom

This STL is designed to fit the OLED screen provided in the Photon Maker Kit. This was designed by Gil at the following Hackster page.
https://www.hackster.io/Gill/3d-printed-enclosure-for-photon-with-oled-1306-display-793393?ref=search&ref_id=oled+photon&offset=1

Photon-OLED-Top

This STL is designed to fit the OLED screen provided in the Photon Maker Kit. This was designed by Gil at the following Hackster page.
https://www.hackster.io/Gill/3d-printed-enclosure-for-photon-with-oled-1306-display-793393?ref=search&ref_id=oled+photon&offset=1

Schematics

IR Distance Sensors Circuit Diagram

This is a basic Circuit diagram showing the points at which to plug all the components into the Particle Photon board.

Remote Circuit Diagram

This is a smiple circuit diagram to show all connection points with the Particle Photon board with the OLED Screen terminals.

Code

IR Sensors Slipping Code

Arduino
This code is used in tandem with the 2 IR Sensors mounted onto the 3D printer.
//William Page's IR Sensor Coding to See Slipping of 3D Print


/*                                   +-----+
 *                        +----------| USB |----------+
 *                        |          +-----+       *  |
 * All Component Power -->| [*] VIN           3V3 [ ] |
 *                        | [ ] GND           RST [ ] |
 *                        | [ ] TX           VBAT [ ] |
 *                        | [ ] RX  [S]   [R] GND [*] |<-- All Components Ground
 *                        | [ ] WKP            D7 [ ] |
 *                        | [ ] DAC +-------+  D6 [ ] |
 *                        | [ ] A5  |   *   |  D5 [ ] |
 *                        | [ ] A4  |Photon |  D4 [ ] |
 *                        | [ ] A3  |       |  D3 [ ] |
 *                        | [ ] A2  +-------+  D2 [ ] |
 * Gantry Tower Sensor -->| [*] A1             D1 [ ] |
 * Build Plate Sensor  -->| [*] A0             D0 [ ] |
 *                        |                           |
 *                         \    []         [______]  /
 *                          \_______________________/
 *
 *
 */



//NOTE: All variables labeled "A" belong to the IR Sensor used on the build plate. All variables labeled "B" are used with the IR sensor on the Z-Axis tower

//SENSOR ON Z-AXIS TOWER
int sensor_B=A1; //(need to connect the sensor output to A1)
double voltage_B=0;
int reading_B=0;
double distance_B=0;
double new_B=0;
double old_B=0;
double avg_B=0;
double height_B=0;

//SENSOR ON BUILD PLATE
int sensor_A=A0; //(need to connect the sensor output to A0)
double voltage_A=0;
int reading_A=0;
double distance_A=0;
double new_A=0;
double old_A=0;
double avg_A=0;
double trigger=0;





//Warning If-Statement
int warning=0;

void setup() {
    
   
    //Sensor on the Build PLate
    Particle.variable("voltage_A",voltage_A);
    Particle.variable("distance_A",distance_A);
    Particle.variable("avg_A",avg_A);
    
    Particle.variable("new_A",new_A);
    Particle.variable("trigger",trigger);
    
    //Sensor on the Z-Axis Tower
    Particle.variable("voltage_B",voltage_B);
    Particle.variable("distance_B",distance_B);
    Particle.variable("avg_B",avg_B);
        Particle.variable("height_B",height_B);
    
    //if statement
    Particle.variable("warning",warning);
    
    
}

void loop() {
    
  
  delay(500); //delay to slow down the rate of recording
  
 
  //START OF z-AXIS TOWER IR SENSOR SEARCHING FOR GANTRY DISTANCE TO BE 1 UP
  
  
  reading_B=analogRead(sensor_B);  //Gets the ADC Reading
  voltage_B=3300.0*reading_B/4095.0; //converts to mV
  distance_B=-0.0000000505255603183952*(voltage_B*voltage_B*voltage_B)+0.000242612411146567*(voltage_B*voltage_B)-0.411007366409474*(voltage_B)+271.29413959704;
  //NOTE: When calculating the formula in Excel, you MUST change the available decimals in the formula to 15+ in order to get and accurate equation
  
  new_B=distance_B;
  

    

    avg_B=((new_B+((old_B)*16)))/17; //averages the new and old distances to ensure wild fluctuations are kept to a minium
    
    height_B=123-avg_B;
    
  
    old_B=new_B;
  
  
  
  
  //END of Z-AXIS TOWER IR SENSOR
  
  
  //START OF BUILD PLATE IR SENSOR CODE SEARCHING FOR CHANGE IN DISTANCE
    reading_A=analogRead(sensor_A);  //Gets the ADC Reading
    voltage_A=3300.0*reading_A/4095.0; //converts to mV
    distance_A=-0.0000000505255603183952*(voltage_A*voltage_A*voltage_A)+0.000242612411146567*(voltage_A*voltage_A)-0.411007366409474*(voltage_A)+271.29413959704;
  //NOTE: When calculating the formula in Excel, you MUST change the available decimals in the formula to 15+ in order to get and accurate equation
  
    new_A=distance_A;
  

    avg_A=((new_A+((old_A)*16)))/17; //averages the new and old distances to ensure wild fluctuations are kept to a minimum
    
    trigger=abs(avg_A-new_A);
 
  
    old_A=new_A;
  //END OF BUILD PLATE IR SENSOR CODE
  
  
  //Start of If Statement to Activate Readings from Base Sensor
  
 
  if (height_B > 30)   //if the height of the nozzle is above 30 mm
   {
    if (trigger > 10)  //and the change in distance on the build plate is more than 10 mm at any time
        {
         warning=1; //then the warning is changed from 0 to 1, thus informing IFTTT that a slip has occured and to send a notification to my phone
         
         delay(1000);
         Particle.publish("Slipping-Print","Your Print is Slipping!", PUBLIC);
        }
   }
   else //otherwise, continue with business as usual.
  {
      warning=0;
  }
 
}

OLED Display Remote

Arduino
This code is used to tell the screen what information to display, along with connecting to the "3D Printer" photon.
 //OLED connections into Photon
 
 /*                           +-----+
 *                 +----------| USB |----------+
 *                 |          +-----+       *  |
 *                 | [ ] VIN           3V3 [*] |<-- VCC
 *                 | [ ] GND           RST [*] |<-- RES
 *                 | [ ] TX           VBAT [ ] |
 *                 | [ ] RX  [S]   [R] GND [*] |<-- Ground
 *                 | [ ] WKP            D7 [ ] |
 *                 | [ ] DAC +-------+  D6 [ ] |
 *           D1 -->| [*] A5  |   *   |  D5 [ ] |
 *                 | [ ] A4  |Photon |  D4 [*] |<-- CS
 *           D0 -->| [*] A3  |       |  D3 [*] |<-- DC
 *                 | [ ] A2  +-------+  D2 [ ] |
 *                 | [ ] A1             D1 [ ] |
 *                 | [ ] A0             D0 [ ] |
 *                 |                           |
 *                  \    []         [______]  /
 *                   \_______________________/
 *
 *
 */

// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_SSD1306.h>

FuelGauge fuel;

// use hardware SPI
// OLED_D0 -> A3 (SPI CLK)
// OLED_D1 -> A5 (SPI MOSI)
#define OLED_DC     D3
#define OLED_CS     D4
#define OLED_RESET  D5
Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);


#define NUMFLAKES  10
#define XPOS  0
#define YPOS  1
#define DELTAY  2


#define LOGO16_GLCD_HEIGHT  16 
#define LOGO16_GLCD_WIDTH   16


#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

void setup()   {     

    Particle.subscribe("Slipping-Print", PrintDisplay, "290029001951353337343731");


 // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  display.begin(SSD1306_SWITCHCAPVCC);
  display.clearDisplay();
  delay(500);
}


void PrintDisplay(const char *event, const char *data)
{
   display.setTextSize(1);
   display.setTextColor(WHITE);
   display.setCursor(0,0);
   display.print("Print is Sliding");
   
   
   display.display();
   delay(2000);
}




void loop() {
    
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  
  
  
  display.println("___________________");
  //Set time zone to EST
  Time.zone(-4);
  //Format time using : http://strftime.net/
  display.println(Time.format(Time.now(), "%a %b,%e %l:%M%p"));

  //Battery Voltage
  //display.print("BATT VOLTAGE: ");
  //display.print( fuel.getVCell() );
  //display.println("V");
  
  //Battery State Of Charge
  //display.print("SOC: ");
  //display.print( fuel.getSoC() );
  //display.println("%");
  
  


  display.display();
  delay(2000);
}

Credits

William Page

William Page

1 project • 0 followers
Ian Conklin

Ian Conklin

1 project • 0 followers
Mechanical Engineering student at UNCC

Comments