From a4bd4bc22f67310c7a7edf7da57fa75bff843518 Mon Sep 17 00:00:00 2001 From: Sangbum Kim Date: Thu, 7 Sep 2017 01:49:56 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=98=EB=AA=BB=EB=90=9C=20=EC=88=98?= =?UTF-8?q?=EC=8B=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 11 +++++------ test/test.go | 16 ++++++++-------- 2 files changed, 13 insertions(+), 14 deletions(-) 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