RepRap Firmware heating

From RepRap
Revision as of 18:52, 3 May 2016 by PRZ (talk | contribs) (links to forum thread)
Jump to: navigation, search

Introduction

On all printer firmwares, you find heating loops, mostly controlled with PID algorithm. All self-build printers and a lot of commercial printer suffers from heterogeneity in temperature displayed values. This does have many sources.

Calibration is needed for the heating loops:

  • G-code for thermistor and ADC calibration is M305 (was M304 on old firmware version)
  • G-code for PID loop is M301 (alternatively M304 could be used for BED PID)

Temperature measurement

Due to very low sensor cost and simplicity of the electronic, most printers are using thermistors for temperature measurement. The resistance of a thermistor with "negative temperature coefficient" (NTC) reduce while its temperature increase. This is not linear and for the type of thermistor used in printers, the resistance became fairly low when approaching 300°C, decreasing the precision in this range. In addition, 300°C is the maximum temperature usable for most thermistors and they tend to failed if used over this temperature.

In the simplest approximation method, 2 parameters are used to qualify a thermistor: first its resistance at a fixed temperature, generally 25°C then the rate of resistance change for a temperature modification named "Beta". It is an approximation and so this Beta coefficient is only valid for a reduced range of temperature. This is the method used in RepRap Firmware. Other firmware may use tables instead of this formula, which may be more precise but the tables are not always available.

Common resistance for printer thermistors is 100 kOhm at 25°C, sometimes 10kOhm thermistors are used for Bed.

Typically for 100k NTC thermistors the Beta coefficient vary from 3800 to 4200.

Unfortunately, for a same reference, the parameters varies for each manufactured part.

Analog converter

For thermistor, this is a voltage which is measured by the microcontroller. A current flows through the thermistor and the voltage drop in thermistor is measured. To limit the current flow, a fixed resistor is installed. The value of this resistor have an important effect on the measure. On the first batches of Duet 0.6 boards, these resistors were 1kOhm and later this was modified to 4.7kOhm. It shall be noted that Replikeo clone boards v0.6 are in principle, still using 1kOhm resistors. All 0.8.5 boards are using 4.7kOhm resistors. The electronic circuit measuring the voltage in the micro-controller is called an Analog to Digital converter, ADC in short. The values given by these ADC have also significant variation for each manufactured unit, and for all ADC within the same controller.

The parameters of M305 command are :

  • Tnnn ;thermistor resistance at 25°C, typically T100000 (100k), sometimes T10000
  • Bnnn ; beta coefficient , shall be defined for the usable range, typically B4200 for a 100k thermistor
  • Rnnn ; value of the board resistor 1000 for old 0.6 boards, 4700 for others – see your board documentation.
  • Lnnn ; ADC low offset – shall be measured according below method
  • Hnnn ; ADC high offset – shall be measured according below method
  • Xnnn ; Heater ADC channel . Sensor remapping – mostly used if the thermal sensor is not a thermistor. See other sensor type

Typical example :

M305 P1 T100000 R1000 B4200

Heating power

Most heaters use resisting material which heats while current flows. The resistance varies somewhat while the material is heating, but a measure of resistance while cold gives a valuable element of comparison within different units.

Again, there is significant manufacturing variability of power for a given model of heater.

The power (often noted W) of a resistive heater is equal to = Resistance * Current^2.

The current is : Voltage / resistance, so W = Voltage^2 / resistance. So the power rise very quickly with voltage.

RRF allow power limitation for heaters in M301/M304 codes. If your voltage exceed the nominal voltage of the heater or if the heater resistance is lower than expected, You may want to limit the power, which can be done with a coefficient limiting the PWM ratio. This coefficient default to 1 and is names S. So S0.8 will cap the PWM ratio to 80% of the time.

This also may be used if your power supply power is a bit insufficient, however this only will work if your power supply have high capacitors on their output to limit the pulse due to the PWM. The power of an heater increase as the square of the voltage, so the limit shall be approximately the inverse of square of the extra voltage. e.g. if you are using 14V power supply for a 12V cartridge, the coefficient shall be (12/14)^2 = 0.735, entered as S0.735.

Calibration

To compare temperatures, you need to calibrate the equipment. This is especially important for a multi head printer to have the same behaviour within all the heads. For measure, two thing shall be calibrated :

  • The Analog to Digital converter (ADC)
  • The Thermistor
  • A third element is of utmost importance for calibration, this is the board resistor value, you shall rely on documentation or board inspection to confirm it.

Sometimes, at room temperature, the temperature indicated by the software is -273 °C (absolute zero), which indicates the measure temperature is out of the range, due either to wrong parameters or ADC variability in excess of what can be measured. If you get this temperature, if your parameters are correct and the thermistor is properly wired, you shall calibrate the ADC (see below), as software will not start the heating loop without a temperature measurement.

ADC calibration

Duet ADC calibration.jpg

Parameters for thermistor and ADC are handled by M305 code. DC42 fork of RepRap Firmware added parameters for ADC calibration since v 0.57u (march 2014) For ADC calibration, you will need two resistors, one of 220 Ohm (1%) and one of 100kOhm (1%). It is practical to connect these resistors to Dupont connectors, which may help to avoid false contact while measuring. Connect the 100K resistor at the thermistor pins and adjust the H parameter to get a reading as close to 25°C as possible (you probably won't manage exactly 25°C because the ADC quantum is about 0.6°C at this temperature). Then substitute a 220 ohm 1% resistor and adjust the L parameter to get a reading of 260.1°C. Then change the resistor back to 100K, check you are still getting a reading close to 25°C, and fine-tune the H parameter if necessary. This shall be done for all the ADC of your board, as there could be more than 10°C variation within different ADC on the same board. Note: Software will indicate a temperature of 2000°C for a shorted thermistor.

Thermistor calibration

While buying a thermistor, check that either the exact model or NTC coefficient is supplied. You may check a thermistor by measuring its resistance at known temperatures if you have the appropriate tools. The room temperature resistance is easy to check and you also can easily check 100°C (boiling water at sea level) , which is nice for a bed thermistor, but far from the used range for a hotend thermistor. If you have a trustable thermometer for comparison, you can test with a hot oil bath (dangerous!). Then you can enter the measured resistances in this calculator or this Libre office sheet which will give you the Beta coefficient. It shall be noted that the beta parameter is an approximation which is only valid in a given temperature range.

Remember water boiling temperature change with altitude, e.g. you will have 90.5°C boiling temperature in Quito (Equator). You already have 99°C at 305m altitude.

Control loop PID parameters

Presentation

PID algorithm is the most used control method for closed loop system. It stand for Proportional, Integral and Derivative and is described in details in many web pages. It does exist algorithms which can test the feedback of the heating loop and evaluate automatically the PID parameters. However (as of May 2016), there is not yet any auto-tuning algorithm in RepRap Firmware and you have to adjust parameters manually. RRF DC42 fork added a few parameters to improve the control (command M301 and M304).

Tuning a PID loop is not an easy task. Some are using a mathematical method named Ziegler-Nichols, which may be long to undertake and may not give convincing results. One manual strategy is defined Here

The RRF default values are a good starting point.

M301/304 parameters

  • Hn : Heater number (only for M301) H0: bed, H1: E0, H2: E1…
  • Pnnn : Proportional coefficient
  • Inn : Integral coefficient
  • Dnn : Derivative coefficient
  • Wnnn : Maximum value of the integral ‘accumulator’. Limit the effect of integral after long heat/cool phase

Tnn: Percentage of PWM (scale 0:255) to maintain 1°C temperature rise. To get it, run a few times M573 to get the average percentage, then T value shall be : (M573 result)*255/(temperature rise over ambient). This parameter is specific to RRF, but when properly adjusted, it will improve notably the control.

  • Bnn : When measured temperature difference with the set-point temperature exceed this value, control is on/off

Hotend parameters

Hotend default parameters are reasonably accurate on all metal hotends and others (e.g. RepRapPro hotends).

Default parameters :

M301 Hn P10 I0.1 D100 T0.4 W180 B30 ;n being the heater number: 0 for bed, 1 for hotend 0, etc.

For an hotend with low inertia and high power as the Fisher delta hotend, other parameters were used (with a heating block insulated with Kapton and no part cooling).

M301 H1 P12 I0.25 T0.21 D70 W150 B20 S0.7; power is limited as the cartridge is 50~60W

It shall be noted that if you insulate your Hotend with polyimide tape or use a part cooling fan, that will modify the loop feedback, and you may modify its parameters. Try first to re-evaluate T parameter (which is linked to the thermal loss).

Bed parameters

Bed control is set by default to ‘bang-bang’ control, which is just an on/off switch while measured temperature exceed a given difference with the setpoint. It is quite unstable with oscillation within 10/15°C range, so it is recommended to use PID control. It shall be noted that for bed control, the PWM frequency is lowered to 10Hz (on recent firmware) and so is compatible with SSR.

'P-1' proportional coefficient is used to indicate bang-bang control so there is no default proportional coefficient for a PID loop, but a starting point is setting the proportional coefficient to 85.

With this proportional coefficient, the default for bed PID control became:

M304 P85 I5 D500 T2.7 W255 B5

These default may be reasonable values for relatively high inertia bed (Glass bed or thick aluminium).

Another example with a top surface which create insulation on the top of the bed (printbite) with 280W for a bed of 700 cm2.

M301 H0 P85 I0.25 D750 T1.3 W200 B5; 'M301 H0' is equivalent to M304

Other sensor type

Why using other sensor

Due to the limitation of thermistors, other type of thermal sensors may be used. They need external small conversion boards with serial communication (SPI) to the main board. You shall be cautious not using boards with 5V level shifters, which may kill your main board (maximum signal voltage is 3.3V on Due processor).

Thermocouples

Thermocouples are the most frequently used sensor type in industrial environment. They are rugged and can stand high temperature. They produce a very low voltage while submitted to temperature. They are reasonably precise even when not calibrated (~2°C). The terminals and cables metallurgy shall be specific and related to the thermocouple type (most frequently ‘K’ type). These constraints explains why they are less frequently used than thermistors in printers.

However, some are using them because of their better reliability at high temperature.

See Using_thermocouples_with_the_Duet_and_RepRapFirmware.

Pt100

Pt100 are another type of resistive sensor.

The name stand for Platinum (Pt) resistance of 100 Ohm at 0°C.

It can be very precise and is usable with higher temperatures than thermistors (max ~600°C), but it is sensitive to parasites if connected with only two wires.

See Using_PT100_temperature_sensors_with_the_Duet_and_RepRapFirmware.


See also

Thread about ADC calibration on RepRap Forum Thread about PID tuning on RepRap Forum