Monday, April 7, 2014

Ardunino Leonardo Heated Bed Temperature Controller

Ardunino Leonardo Heated Bed Temperature Controller

The temperature controller is attached to the prusa i3 and controlled by a serial connection over usb to the prusa i3 raspberry pi module that uses OCTOPRINT webserver to controll the prusa i3.
The controller uses a dual MOSFET chip to drive the current through the heated bed up to 12V 10A from a PC power supply. A freetronics arduino protoype board was used to mount the electronics on to.




Some close up pictures of the controller.




 Dual 30V N Channel MOSFET in a surface mount SOIC-8 package was mounted to a SOIC dip 8 pin dip adpater from texas instruments. A small heat sink was placed on top and a fan mount above the socket for cooling. These transistors can sink up to 9.4Amps each.

Two mosfets were connected in parallel and gates were connected as below with a pulll down 10k resistor each to pins 1 and 3 on the Arduino. These mosfets are switched opposingly with a maxium duty cycle of 50% each enough to handle 10A together. This is enough to drive a heated bed for the prusa i3.
The thermistor circuit was connected to arduino's analog pin A0.

This video shows the controller working with the printer.



Program Code


The timerone package must be installed in Ardunino 1.0.5


#include "TimerOne.h"
// EPCOS 100K Thermistor #3(B57560G104F)
// Made with createTemperatureLookup.py (http://svn.reprap.org/trunk/reprap/firmware/Arduino/utilities/createTemperatureLookup.py)
// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=4036 --max-adc=1023
// r0: 100000
// t0: 25
// r1: 0
// r2: 4700
// beta: 4036
// max adc: 1023
#define NUMTEMPS 20
// {ADC, temp }, // temp
float temptable1[20]={
    864.165363324,
    258.53991594, 
   211.310066205 ,
    185.861725716 ,
    168.31793816, 
   154.754297589 ,
   143.52544406 ,
    133.784751118, 
   125.033500921 ,
    116.945124847 ,
    109.283980973 ,
   101.861768746 ,
    94.5095302806 ,
   87.0542728805 ,
    79.2915563492 ,
    70.9409729952,
    61.5523326183 ,
   50.25271896 ,
    34.7815846664, 
   2.86606331838 
};

int temptable2[]={1,54,107,160,213,266,319,372,425,478,531,584,637,690,743,796,849,902,955,1008};

unsigned int timer_count=0;
unsigned int period=256;
unsigned int ticks_on=0;

void setup(){

  pinMode(1,OUTPUT);
  pinMode(3,OUTPUT);
  
  digitalWrite(1,LOW);
  digitalWrite(3,LOW);
  
  

  
  
  Timer1.initialize(30);
  Timer1.attachInterrupt(tick);
  
Serial.begin(9600);
while(!Serial);

  
  Serial.println("Temperature Controller v0.1 by Pamela Hauff");
  
  
}

int value=0;

void loop(){
  
  int i=0;
  int adc=analogRead(A0);
  Serial.print("(");Serial.print(adc);Serial.print(")");
  while(adc>=temptable2[i]){
    //Serial.print("(");Serial.print(temptable1[i]);Serial.print(")");
    i++;
    if(i>20)break;
  }
  i--;
  Serial.print("(");Serial.print(i);Serial.print(")");
  if(i>=19)i=19;
  float m=(temptable1[i]-temptable1[i+1])/(temptable2[i]-temptable2[i+1]);
  
  float temp=m*(adc-temptable2[i+1])+(float)temptable1[i+1];
  Serial.println(temp);
  delay(100);
  
  if(Serial.available() > 0) {
                // read the incoming byte:
                value=Serial.parseInt();
                Serial.println(value);
                Serial.read();
                              
                  
                 if(value<=126 && value>=0){
                       // Serial.print(value);
                       if(value==0){
                         Serial.println("OFF");
                       }
                       else {Serial.println(" set.");
                        
                       }
                       ticks_on=value; 
                    } 
                 else {
                     Serial.println("Value is larger than 126."); 
                    }
                    
                    
                
  
  }
        
  


}




void tick(){

  
  timer_count++;  

if(timer_count==ticks_on){
  digitalWrite(1,LOW);
}
if(timer_count==ticks_on+period/2){
  digitalWrite(3,LOW);
}
if(timer_count==period/2 && ticks_on!=0){
 digitalWrite(3,HIGH); 
}
if(timer_count==period && ticks_on!=0){
 digitalWrite(1,HIGH);
 timer_count=0;
}





}




1 comment:

  1. bonjour superbe votre montage pour le contrôleur Chambre de température Leonardo chauffée
    mois jais un imprimant 3d du type RepRap en cour de finition
    http://frenois.com/

    ReplyDelete