choose seemingly sensible default values for pid

This commit is contained in:
00asdf 2025-04-26 01:59:29 +02:00
parent 968c47b404
commit 4fa908779d
2 changed files with 6 additions and 6 deletions

View File

@ -10,11 +10,11 @@ object GlobalDataStore {
@Volatile var lowerTime = Date() @Volatile var lowerTime = Date()
@Volatile var resetTime = Date() @Volatile var resetTime = Date()
@Volatile var targetTemp = 22.5 @Volatile var targetTemp: Double = 22.5
@Volatile var reduction = 2.0 @Volatile var reduction: Double = 2.0
@Volatile var pval = 0.0 @Volatile var pval: Double = 0.1
@Volatile var ival = 1.0 @Volatile var ival: Double = 1.0 / 120
@Volatile var dval = 2.0 @Volatile var dval: Double = 0.0
const val API = "https://api.open-meteo.com/v1/forecast?latitude=47.6649&longitude=14.3401&daily=sunshine_duration,daylight_duration,sunrise&hourly=temperature_2m&timezone=Europe/Berlin&forecast_days=1&format=json&timeformat=unixtime" const val API = "https://api.open-meteo.com/v1/forecast?latitude=47.6649&longitude=14.3401&daily=sunshine_duration,daylight_duration,sunrise&hourly=temperature_2m&timezone=Europe/Berlin&forecast_days=1&format=json&timeformat=unixtime"
} }

View File

@ -15,7 +15,7 @@ class PidController(vararg val controlUnits: Controller) {
private fun step(actual: Double, desired: Double): Double { private fun step(actual: Double, desired: Double): Double {
val error = desired - actual val error = desired - actual
errorInt = Math.clamp(errorInt + error, 0.0, 1.0) errorInt = Math.clamp(errorInt + error, 0.0 / GlobalDataStore.ival, 1.0 / GlobalDataStore.ival)
val rv = GlobalDataStore.pval * error + val rv = GlobalDataStore.pval * error +
GlobalDataStore.ival * errorInt + GlobalDataStore.ival * errorInt +
GlobalDataStore.dval * (error - errorLast) GlobalDataStore.dval * (error - errorLast)