Hacks to the RepRap Extruder Controller v2.2

From RepRap
Revision as of 18:24, 3 October 2009 by (talk) (Thermocouple input)
Jump to: navigation, search

Thermocouple input

There is an alternative to this approach [here].


This allows you to use a K-type thermocouple for temperature sensing as opposed to the standard thermistor. It uses the [MAX6675] chip, and is easily put together on a small piece of stripboard that plugs into the I2C connector on the extruder controller board.


The first thing you'll need to do is to remove the 10uF capacitor C8 from the board at B in the picture. You can also remove the thermistor connector (at A) and replace it with a pin. Alternatively, just screw the connection from the new board into the thermistor connector. Getting the capacitor off can be a bit tricky: I levered too hard as I melted the solder and so removed the pad underneath. That's why there is the short white wire connected to the top of R6 is in the picture. If you are more careful, you won't need this...

The I2C connector that you will plug the device into is the 4-pin connector just below R6 in the picture.


Here is the schematic. This is in [the RepRap subversion repository here].

Stripboard-top.jpg Stripboard-bottom.jpg

The MAX6675 is only available as an SMT device. Start by soldering fine wires onto its pins (hold it in a blob of Blu Tack). Cut the tracks on the stripboard, then solder the wires to that. Finally add the connectors, the smoothing capacitor, and the flying lead. You can probably think of a neater wire layout than mine - this evolved as I experimented with the device.

Finally, here's the code to drive it. Thanks to [Ryan Mclaughlin for this]. This will give you back the temperature in oC.


#define SO 18    // MISO
#define SCK 19   // Serial Clock
#define TC_0 17  // CS Pin

// Put this next bit in your startup function:

  pinMode(SO, INPUT);
  pinMode(SCK, OUTPUT);
  pinMode(TC_0, OUTPUT);

// End of startup

// This returns an integer which is the temperature in deg C from the MAX6675

int getTemperature()
    int value = 0;
    byte error_tc;
    digitalWrite(TC_0, 0); // Enable device

    /* Cycle the clock for dummy bit 15 */

    /* Read bits 14-3 from MAX6675 for the Temp
	 Loop for each bit reading the value 
    for (int i=11; i>=0; i--)
	digitalWrite(SCK,HIGH);  // Set Clock to HIGH
	value += digitalRead(SO) << i;  // Read data and add it to our variable
	digitalWrite(SCK,LOW);  // Set Clock to LOW
    /* Read the TC Input inp to check for TC Errors */
    error_tc = digitalRead(SO); // Read data
    digitalWrite(TC_0, HIGH); //Disable Device

      return 2000;
      return value/4;

If it detects an error, this code returns a silly high temperature rather than, say, -300. The latter obviously doesn't exist as a temperature and so might make a better error flag. But returning a big positive value is safe if the device is being used in a thermostat loop: it'll turn off the heater if there's an error, rather than locking it on. Note that the final division by four dumps a couple of bits of precision to get an integer value in oC. The MAX6675 can measure to 0.25 oC, and so you may want to preserve those bits if you need the precision.