From a9f5c20d205a856b4bf364cccdf7e6b59c8bbe00 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Thu, 20 Jun 2024 17:39:43 +0800 Subject: [PATCH] update --- .settings/language.settings.xml | 4 +- a8000_protocol | 2 +- sdk | 2 +- .../subboard40_and_50_temperature_ctrl/pri_board.h | 4 +- .../zcan_fan_ctrl_module.cpp | 10 +- .../subboard90_optical_module/optical_module.cpp | 6 +- utils/.gitignore | 1 + utils/README.md | 0 utils/build.bat | 3 + utils/f_potentiometer_val_and_gain.csv | 255 +++++++++++++++++++++ utils/potentiometer_and_gain_convert.cpp | 63 +++++ utils/t_potentiometer_val_and_gain.csv | 255 +++++++++++++++++++++ 12 files changed, 591 insertions(+), 14 deletions(-) create mode 100644 utils/.gitignore create mode 100644 utils/README.md create mode 100644 utils/build.bat create mode 100644 utils/f_potentiometer_val_and_gain.csv create mode 100644 utils/potentiometer_and_gain_convert.cpp create mode 100644 utils/t_potentiometer_val_and_gain.csv diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index cddd77d..68ccc9d 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/a8000_protocol b/a8000_protocol index 62762ee..256fe59 160000 --- a/a8000_protocol +++ b/a8000_protocol @@ -1 +1 @@ -Subproject commit 62762eee6e2c0cda5971dffe58d68bc10a5207cb +Subproject commit 256fe59bfa94c74048a27af152a76d4ffa649578 diff --git a/sdk b/sdk index b316b30..e22be7d 160000 --- a/sdk +++ b/sdk @@ -1 +1 @@ -Subproject commit b316b30462b063f2ec6dbfb8a1b342c935d840cb +Subproject commit e22be7dd51ddd673d8e4cb67700b62dce5afd548 diff --git a/usrc/subboards/subboard40_and_50_temperature_ctrl/pri_board.h b/usrc/subboards/subboard40_and_50_temperature_ctrl/pri_board.h index 3093896..a2382a9 100644 --- a/usrc/subboards/subboard40_and_50_temperature_ctrl/pri_board.h +++ b/usrc/subboards/subboard40_and_50_temperature_ctrl/pri_board.h @@ -12,7 +12,7 @@ #define EXT_INPUT_IO0 PC6, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true #define EXT_INPUT_IO1 PC7, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true -#define EXT_INPUT_IO2 PA0, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true +#define EXT_INPUT_IO2 PA0, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false #define EXT_INPUT_IO3 PinNull, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true #define EXT_INPUT_IO4 PinNull, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true #define EXT_INPUT_IO5 PinNull, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true @@ -21,7 +21,7 @@ #define EXT_INPUT_IO8 PinNull, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true #define EXT_INPUT_IO9 PinNull, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true -#define EXT_OUTPUT_IO0 PD0, ZGPIO::kMode_nopull, false /*mirror*/, true /*init val*/ +#define EXT_OUTPUT_IO0 PD0, ZGPIO::kMode_nopull, true /*mirror*/ , true/*init val*/ #define EXT_OUTPUT_IO1 PinNull, ZGPIO::kMode_nopull, false /*mirror*/, true /*init val*/ #define EXT_OUTPUT_IO2 PinNull, ZGPIO::kMode_nopull, false /*mirror*/, true /*init val*/ #define EXT_OUTPUT_IO3 PinNull, ZGPIO::kMode_nopull, false /*mirror*/, true /*init val*/ diff --git a/usrc/subboards/subboard40_and_50_temperature_ctrl/zcan_fan_ctrl_module.cpp b/usrc/subboards/subboard40_and_50_temperature_ctrl/zcan_fan_ctrl_module.cpp index b9f52e1..27c1acf 100644 --- a/usrc/subboards/subboard40_and_50_temperature_ctrl/zcan_fan_ctrl_module.cpp +++ b/usrc/subboards/subboard40_and_50_temperature_ctrl/zcan_fan_ctrl_module.cpp @@ -10,13 +10,13 @@ void ZcanFanCtrlModule::initialize(int32_t id, ZIPWMFanCtrlModule* fanmodule, in OSDefaultSchduler::getInstance()->regPeriodJob( [this](OSDefaultSchduler::Context& context) { // - if (creg.m_module_status == 1) { + if (creg.module_status == 1) { if (m_fanmodule->isError()) { ZLOGE(TAG, "detect fan error,stop fan"); creg.module_errorcode = err::kfan_hardware_fault; m_fanmodule->clearError(); m_fanmodule->stop(); - creg.m_module_status = 2; + creg.module_status = 2; } } }, @@ -39,7 +39,7 @@ int32_t ZcanFanCtrlModule::module_xxx_reg(int32_t param_id, bool read, int32_t& int32_t ZcanFanCtrlModule::module_stop() { return fan_controler_set_speed(0); } int32_t ZcanFanCtrlModule::fan_controler_set_speed(int32_t fanspeed100) { - if (creg.m_module_status == 2) { + if (creg.module_status == 2) { ZLOGE(TAG, "fan error trigger, do nothing"); if (fanspeed100 == 0) { return 0; @@ -51,10 +51,10 @@ int32_t ZcanFanCtrlModule::fan_controler_set_speed(int32_t fanspeed100) { if (m_now_speed == 0) { m_fanmodule->stop(); - creg.m_module_status = 0; + creg.module_status = 0; } else { m_fanmodule->setFanSpeed(m_now_speed); - creg.m_module_status = 1; + creg.module_status = 1; creg.module_errorcode = 0; } diff --git a/usrc/subboards/subboard90_optical_module/optical_module.cpp b/usrc/subboards/subboard90_optical_module/optical_module.cpp index 936500d..182072b 100644 --- a/usrc/subboards/subboard90_optical_module/optical_module.cpp +++ b/usrc/subboards/subboard90_optical_module/optical_module.cpp @@ -228,14 +228,14 @@ int32_t OpticalModule::module_xxx_reg(int32_t param_id, bool read, int32_t& val) PROCESS_REG(kreg_boditech_optical_scan_step_interval, REG_GET(m_reg.scan_step_interval), REG_SET(m_reg.scan_step_interval)); PROCESS_REG(kreg_boditech_optical_scan_pointnum, REG_GET(m_reg.scan_pointnum), REG_SET(m_reg.scan_pointnum)); PROCESS_REG(kreg_boditech_optical_channel_select_num, REG_GET(m_reg.channel_select_num), REG_SET(m_reg.channel_select_num)); - PROCESS_REG(kreg_boditech_optical_laster_gain, REG_GET(m_reg.laster_gain), REG_SET(m_reg.laster_gain)); - PROCESS_REG(kreg_boditech_optical_scan_gain, REG_GET(m_reg.scan_gain), REG_SET(m_reg.scan_gain)); + PROCESS_REG(kreg_boditech_optical_laster_gain_potentiometer_val, REG_GET(m_reg.laster_gain), REG_SET(m_reg.laster_gain)); + PROCESS_REG(kreg_boditech_optical_scan_gain_potentiometer, REG_GET(m_reg.scan_gain), REG_SET(m_reg.scan_gain)); PROCESS_REG(kreg_boditech_optical_trf_uvled_on_duration_us, REG_GET(m_reg.trf_uvled_on_duration_us), REG_SET(m_reg.trf_uvled_on_duration_us)); PROCESS_REG(kreg_boditech_optical_trf_uvled_off_duration_us, REG_GET(m_reg.trf_uvled_off_duration_us), REG_SET(m_reg.trf_uvled_off_duration_us)); PROCESS_REG(kreg_boditech_optical_trf_scan_delay_us, REG_GET(m_reg.trf_scan_delay_us), REG_SET(m_reg.trf_scan_delay_us)); PROCESS_REG(kreg_boditech_optical_trf_scan_duration_us, REG_GET(m_reg.trf_scan_duration_us), REG_SET(m_reg.trf_scan_duration_us)); - PROCESS_REG(kreg_boditech_optical_scan_gain_adjust_suggestion, REG_GET(m_reg.scan_gain_adjust_suggestion), ACTION_NONE); + PROCESS_REG(kreg_boditech_optical_scan_gain_potentiometer_adjust_suggestion, REG_GET(m_reg.scan_gain_adjust_suggestion), ACTION_NONE); PROCESS_REG(kreg_boditech_optical_adc_result_overflow, REG_GET(m_reg.adc_result_overflow), ACTION_NONE); PROCESS_REG(kreg_boditech_optical_laster_intensity, REG_GET(m_reg.laster_intensity), ACTION_NONE); default: diff --git a/utils/.gitignore b/utils/.gitignore new file mode 100644 index 0000000..128fe13 --- /dev/null +++ b/utils/.gitignore @@ -0,0 +1 @@ +potentiometer_and_gain_convert.exe \ No newline at end of file diff --git a/utils/README.md b/utils/README.md new file mode 100644 index 0000000..e69de29 diff --git a/utils/build.bat b/utils/build.bat new file mode 100644 index 0000000..9de3bee --- /dev/null +++ b/utils/build.bat @@ -0,0 +1,3 @@ +g++ -static -static-libgcc -static-libstdc++ -lwsock32 -lstdc++ ^ + .\potentiometer_and_gain_convert.cpp -o potentiometer_and_gain_convert.exe + diff --git a/utils/f_potentiometer_val_and_gain.csv b/utils/f_potentiometer_val_and_gain.csv new file mode 100644 index 0000000..9496182 --- /dev/null +++ b/utils/f_potentiometer_val_and_gain.csv @@ -0,0 +1,255 @@ +potentiometer_val ,gain +1 ,1.24 +2 ,1.42 +3 ,1.60 +4 ,1.78 +5 ,1.97 +6 ,2.15 +7 ,2.33 +8 ,2.51 +9 ,2.69 +10 ,2.88 +11 ,3.06 +12 ,3.24 +13 ,3.42 +14 ,3.60 +15 ,3.78 +16 ,3.97 +17 ,4.15 +18 ,4.33 +19 ,4.51 +20 ,4.69 +21 ,4.87 +22 ,5.06 +23 ,5.24 +24 ,5.42 +25 ,5.60 +26 ,5.78 +27 ,5.96 +28 ,6.15 +29 ,6.33 +30 ,6.51 +31 ,6.69 +32 ,6.87 +33 ,7.05 +34 ,7.24 +35 ,7.42 +36 ,7.60 +37 ,7.78 +38 ,7.96 +39 ,8.14 +40 ,8.33 +41 ,8.51 +42 ,8.69 +43 ,8.87 +44 ,9.05 +45 ,9.23 +46 ,9.42 +47 ,9.60 +48 ,9.78 +49 ,9.96 +50 ,10.14 +51 ,10.32 +52 ,10.51 +53 ,10.69 +54 ,10.87 +55 ,11.05 +56 ,11.23 +57 ,11.41 +58 ,11.60 +59 ,11.78 +60 ,11.96 +61 ,12.14 +62 ,12.32 +63 ,12.50 +64 ,12.69 +65 ,12.87 +66 ,13.05 +67 ,13.23 +68 ,13.41 +69 ,13.59 +70 ,13.78 +71 ,13.96 +72 ,14.14 +73 ,14.32 +74 ,14.50 +75 ,14.68 +76 ,14.87 +77 ,15.05 +78 ,15.23 +79 ,15.41 +80 ,15.59 +81 ,15.77 +82 ,15.96 +83 ,16.14 +84 ,16.32 +85 ,16.50 +86 ,16.68 +87 ,16.86 +88 ,17.05 +89 ,17.23 +90 ,17.41 +91 ,17.59 +92 ,17.77 +93 ,17.95 +94 ,18.14 +95 ,18.32 +96 ,18.50 +97 ,18.68 +98 ,18.86 +99 ,19.05 +100 ,19.23 +101 ,19.41 +102 ,19.59 +103 ,19.77 +104 ,19.95 +105 ,20.14 +106 ,20.32 +107 ,20.50 +108 ,20.68 +109 ,20.86 +110 ,21.04 +111 ,21.23 +112 ,21.41 +113 ,21.59 +114 ,21.77 +115 ,21.95 +116 ,22.13 +117 ,22.32 +118 ,22.50 +119 ,22.68 +120 ,22.86 +121 ,23.04 +122 ,23.22 +123 ,23.41 +124 ,23.59 +125 ,23.77 +126 ,23.95 +127 ,24.13 +128 ,24.31 +129 ,24.50 +130 ,24.68 +131 ,24.86 +132 ,25.04 +133 ,25.22 +134 ,25.40 +135 ,25.59 +136 ,25.77 +137 ,25.95 +138 ,26.13 +139 ,26.31 +140 ,26.49 +141 ,26.68 +142 ,26.86 +143 ,27.04 +144 ,27.22 +145 ,27.40 +146 ,27.58 +147 ,27.77 +148 ,27.95 +149 ,28.13 +150 ,28.31 +151 ,28.49 +152 ,28.67 +153 ,28.86 +154 ,29.04 +155 ,29.22 +156 ,29.40 +157 ,29.58 +158 ,29.76 +159 ,29.95 +160 ,30.13 +161 ,30.31 +162 ,30.49 +163 ,30.67 +164 ,30.85 +165 ,31.04 +166 ,31.22 +167 ,31.40 +168 ,31.58 +169 ,31.76 +170 ,31.94 +171 ,32.13 +172 ,32.31 +173 ,32.49 +174 ,32.67 +175 ,32.85 +176 ,33.03 +177 ,33.22 +178 ,33.40 +179 ,33.58 +180 ,33.76 +181 ,33.94 +182 ,34.12 +183 ,34.31 +184 ,34.49 +185 ,34.67 +186 ,34.85 +187 ,35.03 +188 ,35.22 +189 ,35.40 +190 ,35.58 +191 ,35.76 +192 ,35.94 +193 ,36.12 +194 ,36.31 +195 ,36.49 +196 ,36.67 +197 ,36.85 +198 ,37.03 +199 ,37.21 +200 ,37.40 +201 ,37.58 +202 ,37.76 +203 ,37.94 +204 ,38.12 +205 ,38.30 +206 ,38.49 +207 ,38.67 +208 ,38.85 +209 ,39.03 +210 ,39.21 +211 ,39.39 +212 ,39.58 +213 ,39.76 +214 ,39.94 +215 ,40.12 +216 ,40.30 +217 ,40.48 +218 ,40.67 +219 ,40.85 +220 ,41.03 +221 ,41.21 +222 ,41.39 +223 ,41.57 +224 ,41.76 +225 ,41.94 +226 ,42.12 +227 ,42.30 +228 ,42.48 +229 ,42.66 +230 ,42.85 +231 ,43.03 +232 ,43.21 +233 ,43.39 +234 ,43.57 +235 ,43.75 +236 ,43.94 +237 ,44.12 +238 ,44.30 +239 ,44.48 +240 ,44.66 +241 ,44.84 +242 ,45.03 +243 ,45.21 +244 ,45.39 +245 ,45.57 +246 ,45.75 +247 ,45.93 +248 ,46.12 +249 ,46.30 +250 ,46.48 +251 ,46.66 +252 ,46.84 +253 ,47.02 +254 ,47.21 \ No newline at end of file diff --git a/utils/potentiometer_and_gain_convert.cpp b/utils/potentiometer_and_gain_convert.cpp new file mode 100644 index 0000000..78ac8f9 --- /dev/null +++ b/utils/potentiometer_and_gain_convert.cpp @@ -0,0 +1,63 @@ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int32_t t_detector_gain_to_potentiometer_val(float scan_gain) { + int32_t potentiometer_val = 0; + potentiometer_val = (scan_gain * 4.7 - 2.4) * 256. / 100. + 0.5; + if (potentiometer_val < 1) potentiometer_val = 1; + if (potentiometer_val > 255) potentiometer_val = 255; + return potentiometer_val; +} +float t_detector_potentiometer_val_to_gain(int32_t potentiometer_val) { + float scan_gain = 0; + scan_gain = (((100.0 * (float)potentiometer_val) / 256) + 2.4) / 4.7; + return scan_gain; +} + +int32_t f_detector_gain_to_potentiometer_val(float scan_gain) { + // int32_t scan_gain = (((100. / 256.) * (float)potentiometer_val) + 0.125) / 2.15 + 1.; + int32_t potentiometer_val = 0; + potentiometer_val = ((scan_gain - 1.0) * 2.15 - 0.125) * 255. / 100. + 0.5; + if (potentiometer_val < 1) potentiometer_val = 1; + if (potentiometer_val > 255) potentiometer_val = 255; + return potentiometer_val; +} +float f_detector_potentiometer_val_to_gain(int32_t potentiometer_val) { + float scan_gain = 0; + scan_gain = (((100. / 256.) * (float)potentiometer_val) + 0.125) / 2.15 + 1.; + return scan_gain; +} + +int main(int argc, char const *argv[]) { + printf("-----------------------------t table -------------------------------\n"); + + printf("%-20s,%-20s\n", "potentiometer_val", "gain"); + for (size_t i = 1; i < 255; i++) { + float gain = t_detector_potentiometer_val_to_gain(i); + printf("%-20d,%-20.2f\n", i, gain); + } + + printf("-----------------------------f table -------------------------------\n"); + + printf("%-20s,%-20s\n", "potentiometer_val", "gain"); + for (size_t i = 1; i < 255; i++) { + float gain = f_detector_potentiometer_val_to_gain(i); + printf("%-20d,%-20.2f\n", i, gain); + } + + while (1) { + Sleep(2000); + } + + return 0; +} diff --git a/utils/t_potentiometer_val_and_gain.csv b/utils/t_potentiometer_val_and_gain.csv new file mode 100644 index 0000000..0355c56 --- /dev/null +++ b/utils/t_potentiometer_val_and_gain.csv @@ -0,0 +1,255 @@ +potentiometer_val ,gain +1 ,0.59 +2 ,0.68 +3 ,0.76 +4 ,0.84 +5 ,0.93 +6 ,1.01 +7 ,1.09 +8 ,1.18 +9 ,1.26 +10 ,1.34 +11 ,1.42 +12 ,1.51 +13 ,1.59 +14 ,1.67 +15 ,1.76 +16 ,1.84 +17 ,1.92 +18 ,2.01 +19 ,2.09 +20 ,2.17 +21 ,2.26 +22 ,2.34 +23 ,2.42 +24 ,2.51 +25 ,2.59 +26 ,2.67 +27 ,2.75 +28 ,2.84 +29 ,2.92 +30 ,3.00 +31 ,3.09 +32 ,3.17 +33 ,3.25 +34 ,3.34 +35 ,3.42 +36 ,3.50 +37 ,3.59 +38 ,3.67 +39 ,3.75 +40 ,3.84 +41 ,3.92 +42 ,4.00 +43 ,4.08 +44 ,4.17 +45 ,4.25 +46 ,4.33 +47 ,4.42 +48 ,4.50 +49 ,4.58 +50 ,4.67 +51 ,4.75 +52 ,4.83 +53 ,4.92 +54 ,5.00 +55 ,5.08 +56 ,5.16 +57 ,5.25 +58 ,5.33 +59 ,5.41 +60 ,5.50 +61 ,5.58 +62 ,5.66 +63 ,5.75 +64 ,5.83 +65 ,5.91 +66 ,6.00 +67 ,6.08 +68 ,6.16 +69 ,6.25 +70 ,6.33 +71 ,6.41 +72 ,6.49 +73 ,6.58 +74 ,6.66 +75 ,6.74 +76 ,6.83 +77 ,6.91 +78 ,6.99 +79 ,7.08 +80 ,7.16 +81 ,7.24 +82 ,7.33 +83 ,7.41 +84 ,7.49 +85 ,7.58 +86 ,7.66 +87 ,7.74 +88 ,7.82 +89 ,7.91 +90 ,7.99 +91 ,8.07 +92 ,8.16 +93 ,8.24 +94 ,8.32 +95 ,8.41 +96 ,8.49 +97 ,8.57 +98 ,8.66 +99 ,8.74 +100 ,8.82 +101 ,8.90 +102 ,8.99 +103 ,9.07 +104 ,9.15 +105 ,9.24 +106 ,9.32 +107 ,9.40 +108 ,9.49 +109 ,9.57 +110 ,9.65 +111 ,9.74 +112 ,9.82 +113 ,9.90 +114 ,9.99 +115 ,10.07 +116 ,10.15 +117 ,10.23 +118 ,10.32 +119 ,10.40 +120 ,10.48 +121 ,10.57 +122 ,10.65 +123 ,10.73 +124 ,10.82 +125 ,10.90 +126 ,10.98 +127 ,11.07 +128 ,11.15 +129 ,11.23 +130 ,11.32 +131 ,11.40 +132 ,11.48 +133 ,11.56 +134 ,11.65 +135 ,11.73 +136 ,11.81 +137 ,11.90 +138 ,11.98 +139 ,12.06 +140 ,12.15 +141 ,12.23 +142 ,12.31 +143 ,12.40 +144 ,12.48 +145 ,12.56 +146 ,12.64 +147 ,12.73 +148 ,12.81 +149 ,12.89 +150 ,12.98 +151 ,13.06 +152 ,13.14 +153 ,13.23 +154 ,13.31 +155 ,13.39 +156 ,13.48 +157 ,13.56 +158 ,13.64 +159 ,13.73 +160 ,13.81 +161 ,13.89 +162 ,13.97 +163 ,14.06 +164 ,14.14 +165 ,14.22 +166 ,14.31 +167 ,14.39 +168 ,14.47 +169 ,14.56 +170 ,14.64 +171 ,14.72 +172 ,14.81 +173 ,14.89 +174 ,14.97 +175 ,15.06 +176 ,15.14 +177 ,15.22 +178 ,15.30 +179 ,15.39 +180 ,15.47 +181 ,15.55 +182 ,15.64 +183 ,15.72 +184 ,15.80 +185 ,15.89 +186 ,15.97 +187 ,16.05 +188 ,16.14 +189 ,16.22 +190 ,16.30 +191 ,16.38 +192 ,16.47 +193 ,16.55 +194 ,16.63 +195 ,16.72 +196 ,16.80 +197 ,16.88 +198 ,16.97 +199 ,17.05 +200 ,17.13 +201 ,17.22 +202 ,17.30 +203 ,17.38 +204 ,17.47 +205 ,17.55 +206 ,17.63 +207 ,17.71 +208 ,17.80 +209 ,17.88 +210 ,17.96 +211 ,18.05 +212 ,18.13 +213 ,18.21 +214 ,18.30 +215 ,18.38 +216 ,18.46 +217 ,18.55 +218 ,18.63 +219 ,18.71 +220 ,18.80 +221 ,18.88 +222 ,18.96 +223 ,19.04 +224 ,19.13 +225 ,19.21 +226 ,19.29 +227 ,19.38 +228 ,19.46 +229 ,19.54 +230 ,19.63 +231 ,19.71 +232 ,19.79 +233 ,19.88 +234 ,19.96 +235 ,20.04 +236 ,20.12 +237 ,20.21 +238 ,20.29 +239 ,20.37 +240 ,20.46 +241 ,20.54 +242 ,20.62 +243 ,20.71 +244 ,20.79 +245 ,20.87 +246 ,20.96 +247 ,21.04 +248 ,21.12 +249 ,21.21 +250 ,21.29 +251 ,21.37 +252 ,21.45 +253 ,21.54 +254 ,21.62 \ No newline at end of file