From 7800cd04394c76a05a7caeff7f185552b527228c Mon Sep 17 00:00:00 2001 From: egonl Date: Fri, 8 May 2026 13:13:33 +0200 Subject: [PATCH 1/3] Added i-term-wind-up decay gain parameter --- bin/minimize.lua | 2 ++ src/SCRIPTS/RF2/MSP/mspPidTuning.lua | 14 +++++++++++++- src/SCRIPTS/RF2/PAGES/profile_pids.lua | 5 +++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/bin/minimize.lua b/bin/minimize.lua index 6a5d3f3c..d91b7a40 100644 --- a/bin/minimize.lua +++ b/bin/minimize.lua @@ -205,6 +205,8 @@ local mspPidTuningReplacements = { { ".yaw_b", "[14]" }, { ".roll_o", "[15]" }, { ".pitch_o", "[16]" }, + { ".roll_s", "[17]" }, + { ".pitch_s", "[18]" }, } local mspPidProfileReplacements = { diff --git a/src/SCRIPTS/RF2/MSP/mspPidTuning.lua b/src/SCRIPTS/RF2/MSP/mspPidTuning.lua index b2b4f9b9..ad6e6548 100644 --- a/src/SCRIPTS/RF2/MSP/mspPidTuning.lua +++ b/src/SCRIPTS/RF2/MSP/mspPidTuning.lua @@ -17,6 +17,10 @@ local function getDefaults() defaults.yaw_b = { min = 0, max = 1000 } defaults.roll_o = { min = 0, max = 1000 } defaults.pitch_o = { min = 0, max = 1000 } + --if rf2.apiVersion >= 12.10 then -- TODO + defaults.roll_s = { min = 0, max = 1000 } + defaults.pitch_s = { min = 0, max = 1000 } + --end return defaults end @@ -42,9 +46,13 @@ local function getPidTuning(callback, callbackParam, data) data.yaw_b.value = rf2.mspHelper.readU16(buf) data.roll_o.value = rf2.mspHelper.readU16(buf) data.pitch_o.value = rf2.mspHelper.readU16(buf) + --if rf2.apiVersion >= 12.10 then -- TODO + data.roll_s.value = rf2.mspHelper.readU16(buf) + data.pitch_s.value = rf2.mspHelper.readU16(buf) + -- end callback(callbackParam, data) end, - simulatorResponse = {70, 0, 225, 0, 90, 0, 120, 0, 100, 0, 200, 0, 70, 0, 120, 0, 100, 0, 125, 0, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 0, 25, 0 }, + simulatorResponse = {70, 0, 225, 0, 90, 0, 120, 0, 100, 0, 200, 0, 70, 0, 120, 0, 100, 0, 125, 0, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 0, 25, 0, 0, 0, 0, 0 }, } rf2.mspQueue:add(message) end @@ -72,6 +80,10 @@ local function setPidTuning(data) rf2.mspHelper.writeU16(message.payload, data.yaw_b.value) rf2.mspHelper.writeU16(message.payload, data.roll_o.value) rf2.mspHelper.writeU16(message.payload, data.pitch_o.value) + --if rf2.apiVersion >= 12.10 then -- TODO + rf2.mspHelper.writeU16(message.payload, data.roll_s.value) + rf2.mspHelper.writeU16(message.payload, data.pitch_s.value) + --end rf2.mspQueue:add(message) end diff --git a/src/SCRIPTS/RF2/PAGES/profile_pids.lua b/src/SCRIPTS/RF2/PAGES/profile_pids.lua index 0df77eb9..52b733d0 100644 --- a/src/SCRIPTS/RF2/PAGES/profile_pids.lua +++ b/src/SCRIPTS/RF2/PAGES/profile_pids.lua @@ -94,6 +94,11 @@ labels[#labels + 1] = { t = "HSI Offset Gain", x = x, y = incY(l fields[#fields + 1] = { t = "Roll", x = x + indent, y = incY(lineSpacing), sp = x + sp, data = pids.roll_o } fields[#fields + 1] = { t = "Pitch", x = x + indent, y = incY(lineSpacing), sp = x + sp, data = pids.pitch_o } +incY(lineSpacing * 0.5) +labels[#labels + 1] = { t = "Error Decay Stick Gain", x = x, y = incY(lineSpacing) } +fields[#fields + 1] = { t = "Roll", x = x + indent, y = incY(lineSpacing), sp = x + sp, data = pids.roll_s } +fields[#fields + 1] = { t = "Pitch", x = x + indent, y = incY(lineSpacing), sp = x + sp, data = pids.pitch_s } + local function receivedPidTuning(page, data) rf2.onPageReady(page) end From 47b0a3e57ac0ba9f6a926db4fc182e06532d4228 Mon Sep 17 00:00:00 2001 From: egonl Date: Fri, 8 May 2026 14:37:15 +0200 Subject: [PATCH 2/3] Added TODO for MSP 12.10 --- src/SCRIPTS/RF2/PAGES/profile_pids.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SCRIPTS/RF2/PAGES/profile_pids.lua b/src/SCRIPTS/RF2/PAGES/profile_pids.lua index 52b733d0..60ca211a 100644 --- a/src/SCRIPTS/RF2/PAGES/profile_pids.lua +++ b/src/SCRIPTS/RF2/PAGES/profile_pids.lua @@ -94,10 +94,12 @@ labels[#labels + 1] = { t = "HSI Offset Gain", x = x, y = incY(l fields[#fields + 1] = { t = "Roll", x = x + indent, y = incY(lineSpacing), sp = x + sp, data = pids.roll_o } fields[#fields + 1] = { t = "Pitch", x = x + indent, y = incY(lineSpacing), sp = x + sp, data = pids.pitch_o } +--if rf2.apiVersion >= 12.10 then -- TODO incY(lineSpacing * 0.5) labels[#labels + 1] = { t = "Error Decay Stick Gain", x = x, y = incY(lineSpacing) } fields[#fields + 1] = { t = "Roll", x = x + indent, y = incY(lineSpacing), sp = x + sp, data = pids.roll_s } fields[#fields + 1] = { t = "Pitch", x = x + indent, y = incY(lineSpacing), sp = x + sp, data = pids.pitch_s } +--end local function receivedPidTuning(page, data) rf2.onPageReady(page) From d661c419dae6db0bf8c23596b57467337551b31a Mon Sep 17 00:00:00 2001 From: egonl Date: Mon, 18 May 2026 21:33:08 +0200 Subject: [PATCH 3/3] Aligned with firmware --- bin/minimize.lua | 3 +-- src/SCRIPTS/RF2/MSP/mspPidProfile.lua | 11 ++++++++++- src/SCRIPTS/RF2/MSP/mspPidTuning.lua | 14 +------------- src/SCRIPTS/RF2/PAGES/profile_pidcon.lua | 3 +++ src/SCRIPTS/RF2/PAGES/profile_pids.lua | 7 ------- 5 files changed, 15 insertions(+), 23 deletions(-) diff --git a/bin/minimize.lua b/bin/minimize.lua index d91b7a40..5d8b7c07 100644 --- a/bin/minimize.lua +++ b/bin/minimize.lua @@ -205,8 +205,6 @@ local mspPidTuningReplacements = { { ".yaw_b", "[14]" }, { ".roll_o", "[15]" }, { ".pitch_o", "[16]" }, - { ".roll_s", "[17]" }, - { ".pitch_s", "[18]" }, } local mspPidProfileReplacements = { @@ -255,6 +253,7 @@ local mspPidProfileReplacements = { { ".bterm_cutoff_yaw", "[40]" }, { ".yaw_inertia_precomp_gain", "[41]" }, { ".yaw_inertia_precomp_cutoff", "[42]" }, + { ".error_decay_gain_cyclic", "[43]" }, } local mspEscAm32Replacements = { diff --git a/src/SCRIPTS/RF2/MSP/mspPidProfile.lua b/src/SCRIPTS/RF2/MSP/mspPidProfile.lua index 9ce937e7..50701168 100644 --- a/src/SCRIPTS/RF2/MSP/mspPidProfile.lua +++ b/src/SCRIPTS/RF2/MSP/mspPidProfile.lua @@ -49,6 +49,9 @@ local function getDefaults() data.yaw_inertia_precomp_gain = { min = 0, max = 250 } data.yaw_inertia_precomp_cutoff = { min = 0, max = 250, scale = 10, unit = rf2.units.herz } end + --if rf2.apiVersion >= 12.10 then + data.error_decay_gain_cyclic = { min = 0, max = 250 } + --end return data end @@ -110,9 +113,12 @@ local function getPidProfile(callback, callbackParam, data) data.yaw_inertia_precomp_gain.value = rf2.mspHelper.readU8(buf) data.yaw_inertia_precomp_cutoff.value = rf2.mspHelper.readU8(buf) end + --if rf2.apiVersion >= 12.10 then + data.error_decay_gain_cyclic.value = rf2.mspHelper.readU8(buf) + --end callback(callbackParam, data) end, - simulatorResponse = { 3, 25, 250, 0, 12, 0, 1, 30, 30, 45, 50, 50, 100, 15, 15, 20, 2, 10, 10, 15, 100, 100, 5, 0, 30, 0, 25, 0, 40, 55, 40, 75, 20, 25, 0, 15, 45, 45, 15, 15, 20, 0, 0 }, + simulatorResponse = { 3, 25, 250, 0, 12, 0, 1, 30, 30, 45, 50, 50, 100, 15, 15, 20, 2, 10, 10, 15, 100, 100, 5, 0, 30, 0, 25, 0, 40, 55, 40, 75, 20, 25, 0, 15, 45, 45, 15, 15, 20, 0, 0, 0 }, } rf2.mspQueue:add(message) end @@ -177,6 +183,9 @@ local function setPidProfile(data) rf2.mspHelper.writeU8(message.payload, data.yaw_inertia_precomp_gain.value) rf2.mspHelper.writeU8(message.payload, data.yaw_inertia_precomp_cutoff.value) end + --if rf2.apiVersion >= 12.10 then + rf2.mspHelper.writeU8(message.payload, data.error_decay_gain_cyclic.value) + --end rf2.mspQueue:add(message) end diff --git a/src/SCRIPTS/RF2/MSP/mspPidTuning.lua b/src/SCRIPTS/RF2/MSP/mspPidTuning.lua index ad6e6548..b2b4f9b9 100644 --- a/src/SCRIPTS/RF2/MSP/mspPidTuning.lua +++ b/src/SCRIPTS/RF2/MSP/mspPidTuning.lua @@ -17,10 +17,6 @@ local function getDefaults() defaults.yaw_b = { min = 0, max = 1000 } defaults.roll_o = { min = 0, max = 1000 } defaults.pitch_o = { min = 0, max = 1000 } - --if rf2.apiVersion >= 12.10 then -- TODO - defaults.roll_s = { min = 0, max = 1000 } - defaults.pitch_s = { min = 0, max = 1000 } - --end return defaults end @@ -46,13 +42,9 @@ local function getPidTuning(callback, callbackParam, data) data.yaw_b.value = rf2.mspHelper.readU16(buf) data.roll_o.value = rf2.mspHelper.readU16(buf) data.pitch_o.value = rf2.mspHelper.readU16(buf) - --if rf2.apiVersion >= 12.10 then -- TODO - data.roll_s.value = rf2.mspHelper.readU16(buf) - data.pitch_s.value = rf2.mspHelper.readU16(buf) - -- end callback(callbackParam, data) end, - simulatorResponse = {70, 0, 225, 0, 90, 0, 120, 0, 100, 0, 200, 0, 70, 0, 120, 0, 100, 0, 125, 0, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 0, 25, 0, 0, 0, 0, 0 }, + simulatorResponse = {70, 0, 225, 0, 90, 0, 120, 0, 100, 0, 200, 0, 70, 0, 120, 0, 100, 0, 125, 0, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 0, 25, 0 }, } rf2.mspQueue:add(message) end @@ -80,10 +72,6 @@ local function setPidTuning(data) rf2.mspHelper.writeU16(message.payload, data.yaw_b.value) rf2.mspHelper.writeU16(message.payload, data.roll_o.value) rf2.mspHelper.writeU16(message.payload, data.pitch_o.value) - --if rf2.apiVersion >= 12.10 then -- TODO - rf2.mspHelper.writeU16(message.payload, data.roll_s.value) - rf2.mspHelper.writeU16(message.payload, data.pitch_s.value) - --end rf2.mspQueue:add(message) end diff --git a/src/SCRIPTS/RF2/PAGES/profile_pidcon.lua b/src/SCRIPTS/RF2/PAGES/profile_pidcon.lua index 073785e8..5b72cdf2 100644 --- a/src/SCRIPTS/RF2/PAGES/profile_pidcon.lua +++ b/src/SCRIPTS/RF2/PAGES/profile_pidcon.lua @@ -29,6 +29,9 @@ labels[#labels + 1] = { t = "Error Decay Ground", x = x, y = incY( fields[#fields + 1] = { t = "Time", x = x + indent, y = incY(lineSpacing), sp = x + sp, data = pidProfile.error_decay_time_ground } labels[#labels + 1] = { t = "Error Decay Cyclic", x = x, y = incY(lineSpacing) } fields[#fields + 1] = { t = "Time", x = x + indent, y = incY(lineSpacing), sp = x + sp, data = pidProfile.error_decay_time_cyclic } +--if rf2.apiVersion >= 12.10 then -- TODO +fields[#fields + 1] = { t = "Stick Gain", x = x + indent, y = incY(lineSpacing), sp = x + sp, data = pidProfile.error_decay_gain_cyclic } +--end fields[#fields + 1] = { t = "Limit", x = x + indent, y = incY(lineSpacing), sp = x + sp, data = pidProfile.error_decay_limit_cyclic } labels[#labels + 1] = { t = "Error Decay Yaw", x = x, y = incY(lineSpacing) } fields[#fields + 1] = { t = "Time", x = x + indent, y = incY(lineSpacing), sp = x + sp, data = pidProfile.error_decay_time_yaw } diff --git a/src/SCRIPTS/RF2/PAGES/profile_pids.lua b/src/SCRIPTS/RF2/PAGES/profile_pids.lua index 60ca211a..0df77eb9 100644 --- a/src/SCRIPTS/RF2/PAGES/profile_pids.lua +++ b/src/SCRIPTS/RF2/PAGES/profile_pids.lua @@ -94,13 +94,6 @@ labels[#labels + 1] = { t = "HSI Offset Gain", x = x, y = incY(l fields[#fields + 1] = { t = "Roll", x = x + indent, y = incY(lineSpacing), sp = x + sp, data = pids.roll_o } fields[#fields + 1] = { t = "Pitch", x = x + indent, y = incY(lineSpacing), sp = x + sp, data = pids.pitch_o } ---if rf2.apiVersion >= 12.10 then -- TODO -incY(lineSpacing * 0.5) -labels[#labels + 1] = { t = "Error Decay Stick Gain", x = x, y = incY(lineSpacing) } -fields[#fields + 1] = { t = "Roll", x = x + indent, y = incY(lineSpacing), sp = x + sp, data = pids.roll_s } -fields[#fields + 1] = { t = "Pitch", x = x + indent, y = incY(lineSpacing), sp = x + sp, data = pids.pitch_s } ---end - local function receivedPidTuning(page, data) rf2.onPageReady(page) end