UNIVERSAL FUZZY CONTROLLER

Readme

// fuzzyLoop

// ===== Program:program =====

//

// ==============================================================================

// UNIVERSAL FUZZY CONTROLLER PV/SP -> Y (via output increment)

// For: pressure / temperature / flow / speed / RPM, etc.

//

// Based on:

// - Timer: one-shot Clock.schedule(...) + re-create at the end of onExecute():contentReference[oaicite:0]{index=0}

// - Manual mode: full bypass of the logic (like "Service Mode"):contentReference[oaicite:1]{index=1}

// - Read BStatusNumeric only if status is OK or Overridden:contentReference[oaicite:2]{index=2}

//

// ------------------------------------------------------------------------------

// 1) WHAT THIS BLOCK DOES

// - Takes PV (measurement) and SP (setpoint)

// - Computes error: E = SP - PVf (PVf = filtered PV)

// - Computes error rate: dE/dt

// - From (E, dE/dt) selects a "level" L approximately from -2 to +2

// - Converts L to an output increment: dY = L inStepPerSec dt

// - Limits output slew rate inRateLimit and clamps to inOutMin..inOutMax

//

// Important: this is NOT a PID. There is no integral here.

// The block changes Y in "steps" based on error and error rate.

// That’s why it’s usually stable and easy to commission, but it needs tuning of Emax/DEmax/Step.

//

// ------------------------------------------------------------------------------

// 2) DEFINITIONS

// PV - measurement (Process Value), PV units (bar, °C, m3/h, rpm, ...)

// SP - setpoint (Setpoint), PV units

// PVf - filtered PV, PV units

// E - error = SP - PVf, PV units

// dE/dt - error rate, PV/s

// Y - output (command), Y units (usually %)

// Direct: Y↑ -> PV↑

// Reverse: Y↑ -> PV↓

// ------------------------------------------------------------------------------

// 5) WIRING (CONNECTIONS)

// - inPV <- temperature/pressure/... sensor (StatusNumeric)

// - inSP <- setpoint (StatusNumeric)

// - outCmd -> command to actuator/valve/VFD (usually 0..100%)

// - inEnable turn on from schedule/logic

// - inSrvMode + inManualOut for manual mode

//

// ------------------------------------------------------------------------------

// 6) FIRST COMMISSIONING (SIMPLEST)

// 1) Set output limits:

// inOutMin=0, inOutMax=100 (if %)

// 2) inDisableMode=Hold, inBadMode=Hold

// 3) Set inSrvMode=true and move inManualOut: make sure outCmd changes

// 4) inSrvMode=false, inEnable=true

// 5) Check direction:

// - if SP > PV then output must increase -> inReverseAct=false (Direct)

// - if SP > PV then output must decrease -> inReverseAct=true (Reverse)

// 6) Start with small "boldness" (inStepPerSec) and increase until the loop feels responsive.

//

// ------------------------------------------------------------------------------

// 7) STARTING POINT FOR TEMPERATURE (TYPICAL)

// (PV/SP in °C, Y in %)

// inPeriod = 500 ms

// inFilterTime = 3 s

// inDeadband = 0.2 °C

// inEmax = 3.0 °C

// inDEmax = 0.2 °C/s (for very slow air you can use 0.05)

// inStepPerSec = 4 %/s

// inRateLimit = 8 %/s

//

// ------------------------------------------------------------------------------

// 8) TUNING BY SYMPTOMS

// - Oscillates around the setpoint:

// increase inDeadband (0.3..0.5),

// or decrease inStepPerSec,

// or increase inFilterTime (5..8s).

// - Too slow:

// increase inStepPerSec,

// or decrease inEmax.

// - Overshoots:

// increase inEmax,

// or decrease inRateLimit.

//

// ------------------------------------------------------------------------------

// 9) WHAT outState MEANS

// Disabled - automation is off (inEnable=false)

// Manual - manual mode (inSrvMode=true)

// BadInput - PV/SP are bad (not OK and not Override):contentReference[oaicite:3]{index=3}

// Auto - normal operation

//

// ------------------------------------------------------------------------------

// 10) ABOUT TIME-BASED EXECUTION

// There are no while loops and no sleep here.

// Everything works via one-shot schedule and re-creating the ticket:contentReference[oaicite:4]{index=4}.

// Same style as in your updateTimer() examples:contentReference[oaicite:5]{index=5}.

//

// ==============================================================================

Comment on this Package

UNIVERSAL FUZZY CONTROLLER

Watchers
1
Stars
0
20 views • 1 download
Package Details

Direct Link

Category

Last Updated

15 hours ago

You may also like...