ExtruderIO

From RepRap
Revision as of 03:33, 24 January 2007 by SimonMcAuliffe (talk) (version migrated from twiki)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Extruder I/O

The temperature sensor

The temperature sensor is a thermistor. The resistance of the thermistor is dependent on temperature, so measuring the resistance is sufficient to calculate the temperature. Measuring resistance with a microcontroller is usually accomplished with an A/D converter.

The PIC16F628 doesn't have a true A/D converter. It does have a voltage reference generator and a voltage comparator that can be used as a poor-mans A/D converter but since it only has 16 levels on the voltage generator, it isn't useful for any real degree of accuracy. A common way to implement A/D conversion on the low end PIC microcontrollers is to use a slope converter. The basic approach used in the extruder module is to charge a capacitor of known value through the unkwown value resitor (the thermistor). By measuring the time it takes to charge the capacitor, the resistance can be determined and therefore also the temperature.

For calibration purposes, the implementation also includes a resistor of known value. Through software control, the capacitor can be charged through either the known resistor or through the thermistor. The known value measurement provides a calibration point that can be used to correct any errors in the measurements of the thermistor. Note: the calibration resistor is not currently used, and the temperature is calculated with a good degree of accuracy from first principles knowing the CPU clock rate etc. In future it may be useful to use the calibration resistor as a double check. Taking advantage of the calibration resistor is just a software change.

Firmware details

In general complexity is offloaded to the host software so that the firmware can be kept simple. The firmware does not perform any final temperature calculations, it just makes raw measurements of resistance and passes these to the host controller to finally determine the actual temperature.


Timing the capacitor charge involves first discharging the capacitor and then starting the capacitor charge. The number of ticks of a timer is counted until the capacitor is charged.

The complicated part of the sampling the resistance is getting the timing correct. If the capacitor charges too quickly, the number of ticks elapsed will always be very low and since it is an integer value it will have very little accuracy. To maximize accuracy, it is important that the timer counts as high as possible during the sampling period. However if it counts too high, it will overflow and the sample becomes useless.

Capacitor charging is exponential so it never quite charges fully, so rather than waiting for a 100% charge, the firmware only waits until it reaches a particular percentage of full charge. The voltage comparator threshold is the first important parameter for the timing. The PIC voltage comparator works by comparing the input voltage to the voltage reference module output. The voltage reference is set by two parameters, a 16 bit VR value and a high/low range flag. The firmware always uses the high range, so the voltage reference output is determined by the following equation:

 VREF = 1.25 + 5 * VR / 32

A powerup, by default VR is 3 however this can be changed by the host at any point in time.



Host controller details

The heater output

Firmware details

Host controller details

The motor driver

See Also

-- Main.SimonMcAuliffe - 24 Jan 2007