Warning: Undefined variable $post_id in /bitnami/wordpress/wp-content/themes/stardust/single.php on line 9
class="post-10 post type-post status-publish format-standard hentry category-android" id="post-10">

Jun 07 2017

Arduino Temperature Sensor for 3D printer

Category: Androiddq @ 9:21 PM

Problem Statement:

When producing my prints, I have a lot of failures (shifted, under/over extruding, spaghetti prints) due to inconsistent temperatures when using my 3D printer. If the temperature is in excess of the heating bed, the print slides.

Solution:

Enclose the 3D printer and turn on a fan to reduce the temperature if it exceeds the bed temperature. Use an Arduino Nano to measure the temperature of the bed to control the chamber temperature with a fan to exhaust the heat.

Use the USB to power the Nano (note: this will not be enough current to turn the fan I have on as my laptop USB puts out 4.1V).

Connections

Note: You must use the label for the pin, not the actual pin number.

Pin 3V3 connects to AREF for a stable input value

Pin A0 connects to the Chamber analog

Pin A1 connect to the Bed analog

Pin 2 connects to 2N2222 for Fan/Led

The thermistor I used is not linear and the code does not take this into account. A 1uF capacitor is placed across the thermistor (5V to Analog In) to help stabilize the analog read.

The Arduino has two methods by default which do not take input parameters:

  1. setup() // Initialize method
  2. loop() // Loop forever…..

The Arduino compiler is a set C/C++ functions. The source code below can be simplified, see the reference links at the bottom of this page. The calculations need to be moved to a method to simplify the code.

Source code (I need to move this to GitHub)

int count = 0;
int ThermistorPin0 = 0;
int ThermistorPin1 = 1;
int V0, V1;
float R1 = 10000; // Vdivide is based on 10K resistor
float logR2, R2, T0, T1, Tc0, Tc1, Tf0, Tf1;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
const int ledPin =  2;      // the digital pin number of the LED
void setup()
  {
  Serial.begin(9600);
  analogReference(EXTERNAL); // Use the External 3.3V reference for our Aref.
  pinMode(ledPin, ledPin);
  }
void loop() {
  //Temp 0
  V0 = analogRead(ThermistorPin0);
  R2 = R1 * (1023.0 / (float)V0 - 1.0);
  logR2 = log(R2);
  T0 = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
  Tc0 = T0 - 273.15;
  Tf0 = (Tc0 * 9.0)/ 5.0 + 32.0;
  // Temp 1
  V1 = analogRead(ThermistorPin1);
  R2 = R1 * (1023.0 / (float)V1 - 1.0);
  logR2 = log(R2);
  T1 = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
  Tc1 = T1 - 273.15;
  Tf1 = (Tc1 * 9.0)/ 5.0 + 32.0;
  // inc count
  count++;
  // Display it
 // Serial.print("Cnt: ");
 // Serial.print(count);
  Serial.print(" -- Chamber: ");
  Serial.print(Tf0);
  Serial.print(" F; ");
  Serial.print(Tc0);
  Serial.print(" C");
  Serial.print(" -- Bed: ");
  Serial.print(Tf1);
  Serial.print(" F; ");
  Serial.print(Tc1);
  Serial.print(" C ");
  // Test for Chamber hot enough
  if (Tf0 <= Tf1)
    {
    digitalWrite(ledPin, 0);   // turn the LED/Fan off (Low is the Chamber hotter than bed)
    Serial.print(" Fan off ");
    }
  else
    {
    digitalWrite(ledPin, 1);   // turn the LED/Fan on (High is the Bed hotter than Chamber)
    Serial.print(" Fan on ");
    }
  Serial.println(" ");
// Wait for next loop
  delay(1000);
}

Conclusion:

Enclosing the 3D printer ensured the temperatures remain the same as the heated bed throughout the print. This produced solid prints that will hold up to ABS warping and not cracking when bent.

Reference:

https://www.arduino.cc/en/Main/FAQ

http://weblaboratorium.hu/wp-content/uploads/2016/05/thermistorArduino.pdf

https://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor

https://learn.sparkfun.com/tutorials/sik-experiment-guide-for-arduino—v32/experiment-7-reading-a-temperature-sensor

Comments are closed.