Skip to the content ForoHackers
Log inJoin

PID para un horno tostador: el integrador que se vuelve loco (windup)

Control systemsElectronics tinkeringMicrocontrollers
#1100 · ElTioDeLosLeds · · Report

Estoy convirtiendo un horno tostador viejo en un horno de pruebas para soldar placas mías. Un termopar con su amplificador, un microcontrolador y un relé de estado sólido (SSR) para la resistencia. Para mantener una temperatura, un PID.

Primer intento: la temperatura subía, pasaba de largo la consigna en 30 °C y tardaba un siglo en volver. Culpable: el windup del integrador. Mientras el horno está lejos de la consigna, el término integral sigue acumulando error aunque la salida ya está saturada al 100 %. Cuando por fin llegas, el integrador va cargadísimo y empuja de más.

La solución sencilla, anti-windup por limitación:

float pid_step(float sp, float pv, float dt) {
    static float integral = 0.0f;
    float err = sp - pv;
    float p = KP * err;
    integral += KI * err * dt;
    if (integral > 1.0f) integral = 1.0f;     // la salida va de 0 a 1
    if (integral < 0.0f) integral = 0.0f;
    float out = p + integral;
    if (out > 1.0f) out = 1.0f;
    if (out < 0.0f) out = 0.0f;
    return out;                               // fracción de tiempo encendido
}

Como el SSR es de todo o nada, convierto la salida en una ventana de 2 segundos (la resistencia está encendida out * 2 segundos). Y un consejo de seguridad: caja cerrada, fusible, y un termostato mecánico en serie que corte si el software se cuelga. La red eléctrica no perdona los bugs.

#1755 · eeprom_eraser · · Report

In English for the others: yes, clamp the integrator, and ideally stop integrating while the output is saturated (conditional integration). One more thing for relay or SSR control: use a window of a few cycles of the mains, otherwise you get weird beats with the heater. And I fully endorse the hardware thermostat in series. I have bricked enough boards to know software is the optimistic part of the system.

#1756 · JamonYBash · · Report

Lo del termostato mecánico en serie, +1 mil. Para registrar la curva, escupe tiempo,consigna,temperatura por el puerto serie y lo guardas con cat /dev/ttyUSB0 > curva.csv. Luego a graficar y a ajustar con calma.

#1757 · ElTioDeLosLeds · · Report

Gracias a los dos. Ya lo tengo con el log en CSV: con la ventana de 2 s y el anti-windup, el sobrepaso ha bajado de 30 °C a unos 4 °C. Ahora toca ajustar el derivativo, que con el ruido del termopar es una montaña rusa.

#1758 · solder_smoke_sniffer · · Report

One more thing about thermocouples: the amplifier chip does cold-junction compensation, so it must sit at the same temperature as the connector where the thermocouple wire ends. If it sits near the hot oven wall, the reading drifts by several degrees. Keep it on the cool side of the enclosure.

Log in or join to reply.