pid

package
v0.0.0-...-27e1478 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Toepid – totally over-engineered PID control

Copyright (C) 2024–2025 Torsten Bronger, bronger@physik.rwth-aachen.de

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Toepid – totally over-engineered PID control

Copyright (C) 2024–2025 Torsten Bronger, bronger@physik.rwth-aachen.de

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Toepid – totally over-engineered PID control

Copyright (C) 2024–2025 Torsten Bronger, bronger@physik.rwth-aachen.de

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Toepid – totally over-engineered PID control

Copyright (C) 2024–2025 Torsten Bronger, bronger@physik.rwth-aachen.de

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	ModeOff = iota
	ModeOn
	ModeAntifreeze
	ModeSetPower
)
View Source
const (
	ResetAuto = iota
	ResetFalse
	ResetTrue
	ResetDerivative
)
View Source
const (
	Basic = iota
	Saturated
	PWM
)
View Source
const (
	SaturatedNone = iota
	SaturatedLow
	SaturatedHigh
)

Variables

View Source
var ErrNotReady = errors.New("Controller is not initialised")
View Source
var ModeNames = map[int]string{ModeOff: "off", ModeOn: "on", ModeAntifreeze: "antifreeze", ModeSetPower: "set power"}
View Source
var ResetNames = map[int]string{ResetAuto: "auto", ResetFalse: "false", ResetTrue: "true", ResetDerivative: "derivative"}
View Source
var SaturationNames = map[int]string{
	SaturatedNone: "none",
	SaturatedLow:  "low",
	SaturatedHigh: "high",
}

Functions

This section is empty.

Types

type ControlParams

type ControlParams struct {
	Kp float64 `yaml:"Kp"`
	Ti float64 `yaml:"Ti"`
	Td float64 `yaml:"Td"`
}

type Controller

type Controller interface {
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
	Initialize(mode int, setPoint float64, reset int) (hasReset bool)
	SetParams(params ControlParams)
	IsReady() bool
	ControlVar(p timeseries.Point, preload UncertainFloat) (u float64, info statusInfo, err error)
	SetLimits(lower, upper float64)
}

func NewController

func NewController(logger tbr_logging.Logger,
	conType int, window float64, resetTime time.Duration) (c Controller)

NewController returns a controller with bang–bang behaviour. Use the method Controller.SetTerms for switching to general PID control. The window is given in seconds. The window should not contain more than or close to mollifySamples data points. A good number is 15 to 31 time series points. It is given in units of time. Note that the PID control will have a lag of one third of the window. If the controller was set to zero for longer than resetTime, the integral term and the time series are re-set.

type UncertainFloat

type UncertainFloat struct {
	Value, Uncertainty float64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL