Friday, September 3, 2010

it moves

hey this is some good news i did manage to bet my extruder mounted onto my Y axis. i did have to move the Y axis from the bottom of the top bar, to the top of it, so that i could mount it. but i did test it with the extruder on the top and it dose seem to work. and it seems to make less noise now too. so thats a bonus.



video

and here is my code that i managed to butcher in order to get it to work with my lcd and thermistor.



#include
#define THERMISTOR_PIN 0

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Thermistor lookup table for RepRap Temperature Sensor Boards (http://make.rrrf.org/ts)
// 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=4066 --max-adc=1023
// r0: 100000
// t0: 25
// r1: 0
// r2: 4700
// beta: 4066
// max adc: 1023
#define NUMTEMPS 20
short temptable[NUMTEMPS][2] = {
   {1, 841},
   {54, 255},
   {107, 209},
   {160, 184},
   {213, 166},
   {266, 153},
   {319, 142},
   {372, 132},
   {425, 124},
   {478, 116},
   {531, 108},
   {584, 101},
   {637, 93},
   {690, 86},
   {743, 78},
   {796, 70},
   {849, 61},
   {902, 50},
   {955, 34},
   {1008, 3}
};


void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}


void loop()
{
   int rawvalue = analogRead(THERMISTOR_PIN);
   int celsius = read_temp();
    int fahrenheit = (((celsius * 9) / 5) + 32);

   lcd.begin(0, 2);
   lcd.print("C/");
   lcd.print(celsius);
   lcd.setCursor(0, 1);
   lcd.println("F/");
   lcd.print(fahrenheit);
  
  
  
  
   delay(500);
}

int read_temp()
{
   int rawtemp = analogRead(THERMISTOR_PIN);
   int current_celsius = 0;

   byte i;
   for (i=1; i
   {
      if (temptable[i][0] > rawtemp)
      {
         int realtemp  = temptable[i-1][1] + (rawtemp - temptable[i-1][0]) * (temptable[i][1] - temptable[i-1][1]) / (temptable[i][0] - temptable[i-1][0]);

         if (realtemp > 255)
            realtemp = 255;

         current_celsius = realtemp;

         break;
      }
   }

   // Overflow: We just clamp to 0 degrees celsius
   if (i == NUMTEMPS)
   current_celsius = 0;

   return current_celsius;
}

No comments:

Post a Comment