Niagara Framework Program Object components implementing an extremum-seeking control (ESC) based real-time optimization (RTO) block, plus a supporting first-order filter block.
| File | Description |
|---|---|
| ESC_RTO.java | Relay-based extremum-seeking / gradient RTO controller. Port of a MATLAB discrete algorithm. |
| FirstOrderFilter.java | Simple first-order (exponential) low-pass filter, typically used to smooth a signal feeding into ESC_RTO. |
| ESC_wiresheet_validation.pdf | Wiresheet validation showing the blocks wired up in Niagara. |
| Niagara_ESC_RTO_Documentation.docx | Full Word documentation for the ESC/RTO block. |
| Niagara_First_Order_Filter_Documentation.docx | Full Word documentation for the first-order filter block. |
These .java files are not standalone classes — they are the source pasted into a Niagara Program component's editor (onStart / onExecute / onStop lifecycle callbacks), so they rely on slot getters (getX(), getY(), ...) generated by the component's slots rather than on any imports declared in the file.
Implements a relay-feedback extremum-seeking controller that periodically nudges an output y between ymin and ymax based on the sign of a relay e, reversing direction whenever the tracked input u increases for longer than the hold time TC, or whenever y saturates at a limit.
Inputs / config slots
enable– enables/disables execution (holds last output when disabled)u– process signal being extremized (e.g. measured objective/cost)ymax,ymin– output boundsTC– hold time constant (in seconds; floored at 1.0)periodSec– execution period
Outputs
y– the optimized output, initialized to the midpoint of[ymin, ymax]gOut,eOut,ctimeOut– optional debug outputs (gradient estimate, relay sign, hold counter)
Algorithm (per execution)
- Reschedule the timer for the next period.
- Validate
enable,u,ymax,ymin,TC; setBStatus.DISABLED/BStatus.NULLand return early if invalid. - On first valid sample, initialize
yto the midpoint ande = -1. - Compute
g = u - ulast(change in tracked input) and accumulate the hold counterctime. - If
g > 0and the hold time has elapsed, flip the relay signeand resetctime. - Integrate:
y += e * K0, whereK0 = periodSec * (ymax - ymin) / (5 * TC). - Clamp
yto[ymin, ymax]; if saturated and the relay didn't already flip this step, flipeas an anti-saturation measure. - Write
yand the debug outputs.
A first-order exponential smoothing filter: y = a*ylast + (1-a)*x, with a = exp(-dt/tau). Useful for filtering a noisy input before it's used as u in ESC_RTO.
Inputs / config slots
enable,x– input signaltauSec– filter time constant (seconds, floored at 0.1)periodSec– execution period
Outputs
y– filtered signalheartbeat– initialized on start (not otherwise updated inonExecute)
The .docx files contain the full write-ups (background, tuning guidance, and slot reference) for each block, and the .pdf shows a validated wiresheet wiring of the blocks together in Niagara.