Reprap/Quick thermistor hack: Unterschied zwischen den Versionen

aus Metalab Wiki, dem offenen Zentrum für meta-disziplinäre Magier und technisch-kreative Enthusiasten.
Zur Navigation springenZur Suche springen
(in real: Phantasus, just forgot my password)
 
(just writing it different, doesn't mean it's the solution. whatever..)
Zeile 1: Zeile 1:
int pwm_c = 11;
int pwm_c = 11;
int thermistorpin=0;
int thermistorpin=0;
float fraction=0;
float fraction=0;
int i;
int i;


void setup()
void setup()
{
{
pinMode(pwm_c, OUTPUT);
  pinMode(pwm_c, OUTPUT);
        Serial.begin(9600);
  Serial.begin(9600);
}
}


/* my first time on the arduino, the damn thing doesnt
/* my first time on the arduino, the damn thing doesnt
work, the calculation is dumb simple, but I must admit,
work, the calculation is dumb simple, but I must admit,
that I'm too stupid to get the error solved */
that I'm too stupid to get the error solved */


/* it should sets the motor due to the value of
/* it should sets the motor due to the value of
the thermistor, but the thermistor produces (for me: Phantasus)
the thermistor, but the thermistor produces (for me: Phantasus)
weird values, which produce a result of 100% */
weird values, which produce a result of 100% */


void loop()
void loop()
{
{
    int therm;
  int therm;
    therm=analogRead(thermistorpin)-238;
  therm=analogRead(thermistorpin)-238;
    Serial.println("Thermistor value:");
  Serial.println("Thermistor value:");
    Serial.println(therm, DEC);
  Serial.println(therm, DEC);
      fraction = (therm/750)*255;
  fraction = ((therm*255)/750);
    analogWrite(pwm_c,(int)fraction);
  analogWrite(pwm_c,(int)fraction);
    Serial.println("Result");
  Serial.println("Result");
    Serial.println(fraction,DEC);     
  Serial.println(fraction,DEC);     
}
}

Version vom 19. November 2007, 21:35 Uhr

int pwm_c = 11;
int thermistorpin=0;
float fraction=0;
int i;
void setup()
{
  pinMode(pwm_c, OUTPUT);	
  Serial.begin(9600);
}
/* my first time on the arduino, the damn thing doesnt
work, the calculation is dumb simple, but I must admit,
that I'm too stupid to get the error solved */
/* it should sets the motor due to the value of
the thermistor, but the thermistor produces (for me: Phantasus)
weird values, which produce a result of 100% */
void loop()
{
  int therm;	
  therm=analogRead(thermistorpin)-238;
  Serial.println("Thermistor value:");
  Serial.println(therm, DEC);
  fraction = ((therm*255)/750);
  analogWrite(pwm_c,(int)fraction);	
  Serial.println("Result");
  Serial.println(fraction,DEC);    
}