diff --git a/main.go b/main.go index 44a0593..94fff83 100644 --- a/main.go +++ b/main.go @@ -135,8 +135,8 @@ func CpuTempetureScraper(processorCount int, notifier <-chan TempetureChange, er P, I, D = 1.5, 0.4, 2.0 SetPoint = 40.0 SampleTime = time.Second - WindupGuard = 96.0 maxNoob, minNoob = 0x64, 0x4 + WindupGuard = float64(maxNoob - minNoob) ) noobs := make([]int, processorCount) controllers := make([]pid.Controller, 0, processorCount) @@ -152,13 +152,12 @@ func CpuTempetureScraper(processorCount int, notifier <-chan TempetureChange, er select { case change := <-notifier: controller := controllers[change.Id] - resp := controller.Update(change.Tempeture) - - adj_noob := -int(resp) + minNoob - if adj_noob > maxNoob { + adj_noob := int(-controller.Update(change.Tempeture)) + if adj_noob < minNoob { + adj_noob = minNoob + } else if adj_noob > maxNoob { adj_noob = maxNoob } - if noobs[change.Id] == adj_noob { continue } diff --git a/test/test.go b/test/test.go index 63880a0..f47b4ba 100644 --- a/test/test.go +++ b/test/test.go @@ -22,20 +22,20 @@ func test_pid(P float64, I float64, D float64, L int) { for i := 0; i < END; i++ { output := pid.Update((feedback * 1000.0) / 1000.0) - adj := output - if output > 0 { - adj = 0.0 - } else if output < -96.0 { - adj = -96.0 + adj := -output + if adj < 4.0 { + adj = 4.0 + } else if adj > 100.0 { + adj = 100.0 } - adj_noob := int(-adj + 4) + adj_noob := int(adj) adj /= 10.0 - adj += 1.1 + adj -= 1.1 fmt.Printf("feedback: %0.17f output: %0.17f adj: %0.17f noob: 0x%x\n", feedback, output, adj, adj_noob) - feedback += adj + feedback -= adj if feedback < minTemp { feedback = minTemp