Skip to content

Repository files navigation

ESC-RTO

Niagara Framework Program Object components implementing an extremum-seeking control (ESC) based real-time optimization (RTO) block, plus a supporting first-order filter block.

Contents

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.

ESC_RTO.java

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 bounds
  • TC – 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)

  1. Reschedule the timer for the next period.
  2. Validate enable, u, ymax, ymin, TC; set BStatus.DISABLED / BStatus.NULL and return early if invalid.
  3. On first valid sample, initialize y to the midpoint and e = -1.
  4. Compute g = u - ulast (change in tracked input) and accumulate the hold counter ctime.
  5. If g > 0 and the hold time has elapsed, flip the relay sign e and reset ctime.
  6. Integrate: y += e * K0, where K0 = periodSec * (ymax - ymin) / (5 * TC).
  7. Clamp y to [ymin, ymax]; if saturated and the relay didn't already flip this step, flip e as an anti-saturation measure.
  8. Write y and the debug outputs.

FirstOrderFilter.java

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 signal
  • tauSec – filter time constant (seconds, floored at 0.1)
  • periodSec – execution period

Outputs

  • y – filtered signal
  • heartbeat – initialized on start (not otherwise updated in onExecute)

Documentation

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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages