SOC.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  1. #include "SOC.h"
  2. #include "rtwtypes.h"
  3. #include <math.h>
  4. #include "rt_nonfinite.h"
  5. #include "SOC_private.h"
  6. #include "BCUDisp.h"
  7. #include "zero_crossing_types.h"
  8. #include "look1_iflf_binlcapw.h"
  9. #include "BCUCal.h"
  10. MdlrefDW_SOC_T SOC_MdlrefDW;
  11. B_SOC_c_T SOC_B;
  12. DW_SOC_f_T SOC_DW;
  13. ZCE_SOC_T SOC_PrevZCX;
  14. void SOC_FristEn_Init(DW_FristEn_SOC_T *localDW)
  15. {
  16. localDW->UnitDelay_DSTATE = true;
  17. }
  18. void SOC_FristEn(boolean_T *rty_Out1, DW_FristEn_SOC_T *localDW)
  19. {
  20. *rty_Out1 = localDW->UnitDelay_DSTATE;
  21. localDW->UnitDelay_DSTATE = false;
  22. }
  23. void SOC_Subsystem(real32_T rtu_x, real32_T rtu_xdat, real32_T rtu_xdat_o,
  24. real32_T rtu_xdat_d, real32_T rtu_ydat, real32_T rtu_ydat_e,
  25. real32_T *rty_y)
  26. {
  27. if (rtu_x <= rtu_xdat_d) {
  28. *rty_y = rtu_ydat_e;
  29. } else if (rtu_x >= rtu_xdat) {
  30. *rty_y = rtu_ydat;
  31. } else if (rtu_x > rtu_xdat_o) {
  32. *rty_y = (rtu_x - rtu_xdat_o) * (rtu_ydat - rtu_xdat_o) / fmaxf(0.1F,
  33. rtu_xdat - rtu_xdat_o) + rtu_xdat_o;
  34. } else {
  35. *rty_y = (rtu_x - rtu_xdat_d) * (rtu_xdat_o - rtu_ydat_e) / fmaxf(0.1F,
  36. rtu_xdat_o - rtu_xdat_d) + rtu_ydat_e;
  37. }
  38. }
  39. void SOC_UpLim(real32_T rtu_In1, real32_T *rty_Out1, real32_T rtp_m, real_T
  40. rtp_n)
  41. {
  42. real32_T rtb_Add_e;
  43. rtb_Add_e = (real32_T)(rtp_m + rtp_n);
  44. if (rtu_In1 <= rtb_Add_e) {
  45. *rty_Out1 = rtu_In1;
  46. } else {
  47. *rty_Out1 = rtb_Add_e;
  48. }
  49. }
  50. void SOC_fit_Init(DW_fit_SOC_T *localDW)
  51. {
  52. localDW->icLoad = true;
  53. }
  54. void SOC_fit_Reset(DW_fit_SOC_T *localDW)
  55. {
  56. localDW->icLoad = true;
  57. }
  58. void SOC_fit(real32_T rtu_data, real32_T *rty_Fitdata, real32_T rtp_m,
  59. DW_fit_SOC_T *localDW)
  60. {
  61. real32_T rtb_Add6;
  62. uint8_T rtb_Switch_d;
  63. if (localDW->icLoad) {
  64. localDW->Delay_DSTATE = rtu_data;
  65. }
  66. *rty_Fitdata = localDW->Delay_DSTATE;
  67. rtb_Add6 = rtu_data - *rty_Fitdata;
  68. if (rtb_Add6 > rtp_m) {
  69. rtb_Switch_d = 2U;
  70. } else {
  71. rtb_Switch_d = (uint8_T)(rtb_Add6 < -rtp_m);
  72. }
  73. localDW->icLoad = false;
  74. if (rtb_Switch_d == 2) {
  75. localDW->Delay_DSTATE = rtp_m + *rty_Fitdata;
  76. } else if (rtb_Switch_d == 1) {
  77. localDW->Delay_DSTATE = -rtp_m + *rty_Fitdata;
  78. } else {
  79. localDW->Delay_DSTATE = rtu_data;
  80. }
  81. }
  82. void SOC_LowLim(real32_T rtu_In1, real32_T *rty_Out1, real32_T rtp_m, real_T
  83. rtp_n)
  84. {
  85. real32_T rtb_Add_g;
  86. rtb_Add_g = (real32_T)(rtp_m + rtp_n);
  87. if (rtu_In1 >= rtb_Add_g) {
  88. *rty_Out1 = rtu_In1;
  89. } else {
  90. *rty_Out1 = rtb_Add_g;
  91. }
  92. }
  93. void SOC_UpLim_n(uint16_T rtu_In1, uint16_T *rty_Out1, uint16_T rtp_m, real_T
  94. rtp_n)
  95. {
  96. real_T tmp;
  97. uint16_T rtb_Add_g;
  98. tmp = floor((real_T)rtp_m + rtp_n);
  99. if (rtIsNaN(tmp) || rtIsInf(tmp)) {
  100. tmp = 0.0;
  101. } else {
  102. tmp = fmod(tmp, 65536.0);
  103. }
  104. rtb_Add_g = (uint16_T)(tmp < 0.0 ? (int32_T)(uint16_T)-(int16_T)(uint16_T)-tmp
  105. : (int32_T)(uint16_T)tmp);
  106. if (rtu_In1 <= rtb_Add_g) {
  107. *rty_Out1 = rtu_In1;
  108. } else {
  109. *rty_Out1 = rtb_Add_g;
  110. }
  111. }
  112. void SOC_Conditionalcounter1_Reset(DW_Conditionalcounter1_SOC_T *localDW)
  113. {
  114. localDW->UnitDelay_DSTATE = 0U;
  115. }
  116. void SOC_Conditionalcounter1(uint16_T *rty_Nr, uint16_T rtp_n,
  117. DW_Conditionalcounter1_SOC_T *localDW)
  118. {
  119. SOC_UpLim_n((uint16_T)(localDW->UnitDelay_DSTATE + 1U), rty_Nr, rtp_n, 1.0);
  120. }
  121. void SOC_Conditionalcounter1_Update(boolean_T rtu_Flg, uint16_T *rty_Nr,
  122. DW_Conditionalcounter1_SOC_T *localDW)
  123. {
  124. localDW->UnitDelay_DSTATE = (uint16_T)(rtu_Flg ? (int32_T)*rty_Nr : 0);
  125. }
  126. void SOC_Subsystem1(boolean_T rtu_Trigger, real32_T rtu_in1, real32_T rtu_in2,
  127. real32_T *rty_out1, real32_T *rty_out2, ZCE_Subsystem1_SOC_T
  128. *localZCE)
  129. {
  130. if (rtu_Trigger && (localZCE->Subsystem1_Trig_ZCE != POS_ZCSIG)) {
  131. *rty_out1 = rtu_in1;
  132. *rty_out2 = rtu_in2;
  133. }
  134. localZCE->Subsystem1_Trig_ZCE = rtu_Trigger;
  135. }
  136. void SOC_TimeCounter_Reset(DW_TimeCounter_SOC_T *localDW)
  137. {
  138. localDW->UnitDelay_DSTATE = 0.0;
  139. }
  140. void SOC_TimeCounter(real_T *rty_Nr, real_T rtp_n, DW_TimeCounter_SOC_T *localDW)
  141. {
  142. if (localDW->UnitDelay_DSTATE + 1.0 <= rtp_n + 1.0) {
  143. *rty_Nr = localDW->UnitDelay_DSTATE + 1.0;
  144. } else {
  145. *rty_Nr = rtp_n + 1.0;
  146. }
  147. localDW->UnitDelay_DSTATE = *rty_Nr;
  148. }
  149. void SOC_Conditionalcounter_Reset(DW_Conditionalcounter_SOC_T *localDW)
  150. {
  151. localDW->UnitDelay_DSTATE = 0U;
  152. }
  153. void SOC_Conditionalcounter(uint16_T *rty_Nr, uint16_T rtp_n,
  154. DW_Conditionalcounter_SOC_T *localDW)
  155. {
  156. SOC_UpLim_n((uint16_T)(localDW->UnitDelay_DSTATE + 1U), rty_Nr, rtp_n, 0.0);
  157. }
  158. void SOC_Conditionalcounter_Update(boolean_T rtu_Flg, uint16_T *rty_Nr,
  159. DW_Conditionalcounter_SOC_T *localDW)
  160. {
  161. localDW->UnitDelay_DSTATE = (uint16_T)(rtu_Flg ? (int32_T)*rty_Nr : 0);
  162. }
  163. void SOC_Init(void)
  164. {
  165. SOC_DW.If_ActiveSubsystem = -1;
  166. SOC_DW.If_ActiveSubsystem_j = -1;
  167. SOC_DW.icLoad = true;
  168. SOC_DW.icLoad_j = true;
  169. SOC_DW.icLoad_o = true;
  170. SOC_DW.icLoad_i = true;
  171. SOC_DW.icLoad_p = true;
  172. SOC_DW.P_Delay_DSTATE[0] = 0.001F;
  173. SOC_DW.P_Delay_DSTATE_k[0] = 0.001F;
  174. SOC_DW.P_Delay_DSTATE[1] = 0.0F;
  175. SOC_DW.P_Delay_DSTATE_k[1] = 0.0F;
  176. SOC_DW.P_Delay_DSTATE[2] = 0.0F;
  177. SOC_DW.P_Delay_DSTATE_k[2] = 0.0F;
  178. SOC_DW.P_Delay_DSTATE[3] = 0.001F;
  179. SOC_DW.P_Delay_DSTATE_k[3] = 0.001F;
  180. SOC_DW.icLoad_a = true;
  181. SOC_DW.icLoad_l = true;
  182. SOC_DW.icLoad_m = true;
  183. SOC_DW.socd_pct_battSoc0_Delay_DSTATE = 1.0F;
  184. SOC_DW.socd_pct_bcuSoc0_Delay_DSTATE = 1.0F;
  185. SOC_FristEn_Init(&SOC_DW.FristEn);
  186. SOC_FristEn_Init(&SOC_DW.FristEn_n);
  187. SOC_fit_Init(&SOC_DW.fit);
  188. SOC_fit_Init(&SOC_DW.fit_j);
  189. }
  190. void SOC_Disable(void)
  191. {
  192. SOC_DW.If_ActiveSubsystem = -1;
  193. SOC_DW.If_ActiveSubsystem_j = -1;
  194. }
  195. void SOC(void)
  196. {
  197. real_T rtb_Switch;
  198. int32_T Switch;
  199. real32_T rtb_Add_ij[4];
  200. real32_T rtb_Add_ob[4];
  201. real32_T rtb_MatrixConcatenate[4];
  202. real32_T tmp[4];
  203. real32_T rtb_Divide_f[2];
  204. real32_T rtb_MathFunction1_b[2];
  205. real32_T rtb_MathFunction1_l[2];
  206. real32_T rtb_Abs;
  207. real32_T rtb_Abs1;
  208. real32_T rtb_Add_f_tmp_tmp;
  209. real32_T rtb_Delay_j;
  210. real32_T rtb_Divide_l;
  211. real32_T rtb_MathFunction1_g;
  212. real32_T rtb_Merge3;
  213. real32_T rtb_OCVSOC1;
  214. real32_T rtb_Switch2_l;
  215. real32_T rtb_Switch7;
  216. real32_T tmp_0;
  217. real32_T tmp_1;
  218. uint16_T Switch_cz;
  219. uint16_T rtb_Gain3;
  220. uint16_T rtb_Gain3_l;
  221. int8_T rtPrevAction;
  222. boolean_T rtb_RelationalOperator_pu;
  223. SOC_FristEn(&rtb_RelationalOperator_pu, &SOC_DW.FristEn);
  224. if (rtb_RelationalOperator_pu) {
  225. rtb_OCVSOC1 = look1_iflf_binlcapw(ihd_V_cellUAvrg, &cmnm_V_ocv[0],
  226. &cmnm_pct_soc[0], 12U);
  227. if (ihv_flg_EESt[1] || (socd_pct_battSocEi > 100.0F) || (socd_pct_bcuSocEi >
  228. 100.0F)) {
  229. SOC_B.Switch1 = rtb_OCVSOC1;
  230. SOC_B.Switch_d = rtb_OCVSOC1;
  231. } else {
  232. SOC_B.Switch1 = socd_pct_battSocEi;
  233. SOC_B.Switch_d = socd_pct_bcuSocEi;
  234. }
  235. rtb_RelationalOperator_pu = ((ihd_tm_parkTime >= cmnc_tm_parkTime) &&
  236. ((rtb_OCVSOC1 >= 95.0F) || (rtb_OCVSOC1 <= 30.0F)));
  237. if (rtb_RelationalOperator_pu) {
  238. SOC_B.Switch1 = rtb_OCVSOC1;
  239. }
  240. if ((fabsf(SOC_B.Switch1 - SOC_B.Switch_d) > 50.0F) &&
  241. rtb_RelationalOperator_pu) {
  242. SOC_B.Switch_d = rtb_OCVSOC1;
  243. }
  244. SOC_B.Divide = sohd_pct_bcuSoh * cmnc_Q_ratedCp / 100.0F;
  245. }
  246. if (SOC_DW.icLoad) {
  247. SOC_DW.Delay_DSTATE = SOC_B.Switch_d;
  248. }
  249. if (SOC_DW.Delay_DSTATE > socc_pct_battSocUp) {
  250. socd_pct_bcuSocEo = socc_pct_battSocUp;
  251. } else if (SOC_DW.Delay_DSTATE < socc_pct_battSocLow) {
  252. socd_pct_bcuSocEo = socc_pct_battSocLow;
  253. } else {
  254. socd_pct_bcuSocEo = SOC_DW.Delay_DSTATE;
  255. }
  256. rtb_OCVSOC1 = -0.5F * ihd_I_battCurr_T2;
  257. if (dcmd_st_chrgSt_T2 == chrging) {
  258. uint8_T tmp_2;
  259. rtb_Abs = fabsf(ihd_pct_socCor);
  260. SOC_DW.UnitDelay_DSTATE_o += rtb_OCVSOC1 * socc_tm_step;
  261. rtb_Divide_l = SOC_DW.UnitDelay_DSTATE_o / 3600.0F;
  262. rtb_MathFunction1_g = floorf(1000.0F * ihd_V_cellUMax);
  263. if (rtIsNaNF(rtb_MathFunction1_g) || rtIsInfF(rtb_MathFunction1_g)) {
  264. rtb_MathFunction1_g = 0.0F;
  265. } else {
  266. rtb_MathFunction1_g = fmodf(rtb_MathFunction1_g, 65536.0F);
  267. }
  268. rtb_Gain3 = (uint16_T)(rtb_MathFunction1_g < 0.0F ? (int32_T)(uint16_T)
  269. -(int16_T)(uint16_T)-rtb_MathFunction1_g : (int32_T)(uint16_T)
  270. rtb_MathFunction1_g);
  271. rtb_RelationalOperator_pu = (rtb_Gain3 > SOC_DW.UnitDelay5_DSTATE);
  272. if (rtb_RelationalOperator_pu) {
  273. SOC_B.SignalConversion = rtb_Divide_l - SOC_DW.Delay_DSTATE_f[0];
  274. SOC_B.LogicalOperator_j = ((SOC_B.SignalConversion -
  275. SOC_DW.UnitDelay_DSTATE_i < -0.01F) && (SOC_DW.UnitDelay2_DSTATE -
  276. SOC_DW.UnitDelay3_DSTATE >= 0.01F));
  277. for (Switch = 0; Switch < 9; Switch++) {
  278. SOC_DW.Delay_DSTATE_f[Switch] = SOC_DW.Delay_DSTATE_f[Switch + 1];
  279. }
  280. SOC_DW.Delay_DSTATE_f[9] = rtb_Divide_l;
  281. SOC_DW.UnitDelay_DSTATE_i = SOC_B.SignalConversion;
  282. SOC_DW.UnitDelay2_DSTATE = SOC_B.SignalConversion;
  283. SOC_DW.UnitDelay3_DSTATE = SOC_DW.UnitDelay1_DSTATE_a;
  284. SOC_DW.UnitDelay1_DSTATE_a = SOC_B.SignalConversion;
  285. }
  286. if ((SOC_DW.UnitDelay1_DSTATE_h <= 1.0F) && (rtb_Abs >= 1.0F)) {
  287. tmp_2 = 2U;
  288. } else {
  289. tmp_2 = (uint8_T)(SOC_B.LogicalOperator_j && (ihd_V_cellUMax <= 3.4F));
  290. }
  291. switch (tmp_2) {
  292. case 0:
  293. rtb_Merge3 = 0.0F;
  294. break;
  295. case 1:
  296. rtb_Merge3 = 50.0F - socd_pct_ekfSoc;
  297. break;
  298. default:
  299. rtb_Merge3 = ihd_pct_socCor;
  300. break;
  301. }
  302. socd_Q_dMax = SOC_B.SignalConversion;
  303. rtb_MathFunction1_g = floorf(1000.0F * ihd_V_cellUMin);
  304. if (rtIsNaNF(rtb_MathFunction1_g) || rtIsInfF(rtb_MathFunction1_g)) {
  305. rtb_MathFunction1_g = 0.0F;
  306. } else {
  307. rtb_MathFunction1_g = fmodf(rtb_MathFunction1_g, 65536.0F);
  308. }
  309. rtb_Gain3_l = (uint16_T)(rtb_MathFunction1_g < 0.0F ? (int32_T)(uint16_T)
  310. -(int16_T)(uint16_T)-rtb_MathFunction1_g : (int32_T)(uint16_T)
  311. rtb_MathFunction1_g);
  312. if (rtb_Gain3_l > SOC_DW.UnitDelay5_DSTATE_k) {
  313. SOC_B.SignalConversion_b = rtb_Divide_l - SOC_DW.Delay_DSTATE_lp[0];
  314. for (Switch = 0; Switch < 9; Switch++) {
  315. SOC_DW.Delay_DSTATE_lp[Switch] = SOC_DW.Delay_DSTATE_lp[Switch + 1];
  316. }
  317. SOC_DW.Delay_DSTATE_lp[9] = rtb_Divide_l;
  318. SOC_DW.UnitDelay5_DSTATE_k = rtb_Gain3_l;
  319. }
  320. socd_Q_dMin = SOC_B.SignalConversion_b;
  321. if (rtb_RelationalOperator_pu) {
  322. SOC_DW.UnitDelay5_DSTATE = rtb_Gain3;
  323. }
  324. SOC_DW.UnitDelay1_DSTATE_h = rtb_Abs;
  325. } else {
  326. socd_Q_dMin = 0.0F;
  327. socd_Q_dMax = 0.0F;
  328. rtb_Abs = fabsf(ihd_pct_socCor);
  329. if ((SOC_DW.UnitDelay1_DSTATE <= 1.0F) && (rtb_Abs >= 1.0F)) {
  330. rtb_Merge3 = ihd_pct_socCor;
  331. } else {
  332. rtb_Merge3 = 0.0F;
  333. }
  334. SOC_DW.UnitDelay1_DSTATE = rtb_Abs;
  335. }
  336. if (SOC_DW.icLoad_j) {
  337. SOC_DW.Delay_DSTATE_l = SOC_B.Switch1;
  338. }
  339. rtb_MathFunction1_g = fabsf(rtb_Merge3);
  340. if (rtb_MathFunction1_g >= 1.0F) {
  341. SOC_DW.Delay_DSTATE_l = (rtb_OCVSOC1 * socc_tm_step / 36.0F / SOC_B.Divide +
  342. SOC_DW.Delay_DSTATE_l) + rtb_Merge3;
  343. } else {
  344. SOC_DW.Delay_DSTATE_l += rtb_OCVSOC1 * socc_tm_step / 36.0F / SOC_B.Divide;
  345. }
  346. rtb_MatrixConcatenate[0] = 1.0F;
  347. rtb_MatrixConcatenate[1] = 0.0F;
  348. if (SOC_DW.icLoad_o) {
  349. SOC_DW.Delay1_DSTATE = SOC_B.Switch1;
  350. }
  351. if (rtb_MathFunction1_g >= 1.0F) {
  352. SOC_DW.Delay1_DSTATE += rtb_Merge3;
  353. }
  354. rtb_Abs = expf(-socc_tm_step / look1_iflf_binlcapw(SOC_DW.Delay1_DSTATE,
  355. &cmnm_pct_soc[0], &cmnm_tm_polar[0], 12U));
  356. rtb_MatrixConcatenate[2] = 0.0F;
  357. rtb_MatrixConcatenate[3] = rtb_Abs;
  358. for (Switch = 0; Switch < 2; Switch++) {
  359. tmp[Switch] = 0.0F;
  360. tmp[Switch] += SOC_DW.P_Delay_DSTATE[Switch];
  361. rtb_Divide_l = SOC_DW.P_Delay_DSTATE[Switch + 2];
  362. tmp[Switch] += rtb_Divide_l * 0.0F;
  363. tmp[Switch + 2] = 0.0F;
  364. tmp[Switch + 2] += SOC_DW.P_Delay_DSTATE[Switch] * 0.0F;
  365. tmp[Switch + 2] += rtb_Divide_l * rtb_Abs;
  366. }
  367. rtb_MathFunction1_b[0] = (look1_iflf_binlcapw(SOC_DW.Delay1_DSTATE + 0.01F,
  368. &cmnm_pct_soc[0], &cmnm_V_ocv[0], 12U) - look1_iflf_binlcapw
  369. (SOC_DW.Delay1_DSTATE - 0.01F, &cmnm_pct_soc[0], &cmnm_V_ocv[0], 12U)) /
  370. SOC_ConstB.Add4_j;
  371. rtb_MathFunction1_b[1] = 1.0F;
  372. rtb_Divide_l = 0.0F;
  373. for (Switch = 0; Switch < 2; Switch++) {
  374. rtb_Switch7 = rtb_MatrixConcatenate[Switch + 2];
  375. rtb_Delay_j = (rtb_Switch7 * tmp[1] + rtb_MatrixConcatenate[Switch] * tmp[0])
  376. + 0.0005F;
  377. rtb_Add_ob[Switch] = rtb_Delay_j;
  378. rtb_Switch7 = (rtb_Switch7 * tmp[3] + rtb_MatrixConcatenate[Switch] * tmp[2])
  379. + 0.0005F;
  380. rtb_Add_ob[Switch + 2] = rtb_Switch7;
  381. rtb_Delay_j = rtb_Delay_j * rtb_MathFunction1_b[0] + rtb_Switch7;
  382. rtb_Divide_l += rtb_MathFunction1_b[Switch] * rtb_Delay_j;
  383. rtb_Divide_f[Switch] = rtb_Delay_j;
  384. }
  385. rtb_Delay_j = rtb_Divide_f[0] / (rtb_Divide_l + 0.5F);
  386. rtb_Switch7 = rtb_Divide_f[1] / (rtb_Divide_l + 0.5F);
  387. if (SOC_DW.icLoad_i) {
  388. SOC_DW.Delay2_DSTATE = 0.0F;
  389. }
  390. rtb_Divide_f[1] = (1.0F - rtb_Abs) * (0.001F * look1_iflf_binlcapw
  391. (SOC_DW.Delay1_DSTATE, &cmnm_pct_soc[0], &cmnm_ohm_polar[0], 12U)) *
  392. rtb_OCVSOC1 + (0.0F * SOC_DW.Delay1_DSTATE + rtb_Abs * SOC_DW.Delay2_DSTATE);
  393. rtb_Divide_l = ihd_V_cellUMax - ((0.001F * look1_iflf_binlcapw
  394. (SOC_DW.Delay1_DSTATE, &cmnm_pct_soc[0], &cmnm_ohm_Ro[0], 12U) * rtb_OCVSOC1
  395. + look1_iflf_binlcapw(SOC_DW.Delay1_DSTATE, &cmnm_pct_soc[0], &cmnm_V_ocv[0],
  396. 12U)) + rtb_Divide_f[1]);
  397. rtb_Abs1 = socc_tm_step / SOC_B.Divide * 0.027777778F * rtb_OCVSOC1;
  398. SOC_DW.Delay1_DSTATE = ((0.0F * SOC_DW.Delay2_DSTATE + SOC_DW.Delay1_DSTATE) +
  399. rtb_Abs1) + rtb_Delay_j * rtb_Divide_l;
  400. rtb_MatrixConcatenate[0] = 1.0F;
  401. SOC_DW.Delay2_DSTATE = rtb_Switch7 * rtb_Divide_l + rtb_Divide_f[1];
  402. rtb_MatrixConcatenate[1] = 0.0F;
  403. if (SOC_DW.icLoad_p) {
  404. SOC_DW.Delay1_DSTATE_a = SOC_B.Switch1;
  405. }
  406. if (rtb_MathFunction1_g >= 1.0F) {
  407. SOC_DW.Delay1_DSTATE_a += rtb_Merge3;
  408. }
  409. rtb_Abs = expf(-socc_tm_step / look1_iflf_binlcapw(SOC_DW.Delay1_DSTATE_a,
  410. &cmnm_pct_soc[0], &cmnm_tm_polar[0], 12U));
  411. rtb_MatrixConcatenate[2] = 0.0F;
  412. rtb_MatrixConcatenate[3] = rtb_Abs;
  413. for (Switch = 0; Switch < 2; Switch++) {
  414. tmp[Switch] = 0.0F;
  415. tmp[Switch] += SOC_DW.P_Delay_DSTATE_k[Switch];
  416. rtb_MathFunction1_g = SOC_DW.P_Delay_DSTATE_k[Switch + 2];
  417. tmp[Switch] += rtb_MathFunction1_g * 0.0F;
  418. tmp[Switch + 2] = 0.0F;
  419. tmp[Switch + 2] += SOC_DW.P_Delay_DSTATE_k[Switch] * 0.0F;
  420. tmp[Switch + 2] += rtb_MathFunction1_g * rtb_Abs;
  421. }
  422. rtb_MathFunction1_l[0] = (look1_iflf_binlcapw(SOC_DW.Delay1_DSTATE_a + 0.01F,
  423. &cmnm_pct_soc[0], &cmnm_V_ocv[0], 12U) - look1_iflf_binlcapw
  424. (SOC_DW.Delay1_DSTATE_a - 0.01F, &cmnm_pct_soc[0], &cmnm_V_ocv[0], 12U)) /
  425. SOC_ConstB.Add4;
  426. rtb_MathFunction1_l[1] = 1.0F;
  427. rtb_MathFunction1_g = 0.0F;
  428. for (Switch = 0; Switch < 2; Switch++) {
  429. rtb_Add_f_tmp_tmp = rtb_MatrixConcatenate[Switch + 2];
  430. rtb_Merge3 = (rtb_Add_f_tmp_tmp * tmp[1] + rtb_MatrixConcatenate[Switch] *
  431. tmp[0]) + 0.0005F;
  432. rtb_Add_ij[Switch] = rtb_Merge3;
  433. rtb_Add_f_tmp_tmp = (rtb_Add_f_tmp_tmp * tmp[3] +
  434. rtb_MatrixConcatenate[Switch] * tmp[2]) + 0.0005F;
  435. rtb_Add_ij[Switch + 2] = rtb_Add_f_tmp_tmp;
  436. rtb_Merge3 = rtb_Merge3 * rtb_MathFunction1_l[0] + rtb_Add_f_tmp_tmp;
  437. rtb_MathFunction1_g += rtb_MathFunction1_l[Switch] * rtb_Merge3;
  438. rtb_Divide_f[Switch] = rtb_Merge3;
  439. }
  440. rtb_Add_f_tmp_tmp = rtb_Divide_f[0] / (rtb_MathFunction1_g + 0.5F);
  441. rtb_MathFunction1_g = rtb_Divide_f[1] / (rtb_MathFunction1_g + 0.5F);
  442. if (SOC_DW.icLoad_a) {
  443. SOC_DW.Delay2_DSTATE_k = 0.0F;
  444. }
  445. rtb_Merge3 = (1.0F - rtb_Abs) * (0.001F * look1_iflf_binlcapw
  446. (SOC_DW.Delay1_DSTATE_a, &cmnm_pct_soc[0], &cmnm_ohm_polar[0], 12U)) *
  447. rtb_OCVSOC1 + (0.0F * SOC_DW.Delay1_DSTATE_a + rtb_Abs *
  448. SOC_DW.Delay2_DSTATE_k);
  449. rtb_Abs = ihd_V_cellUMin - ((0.001F * look1_iflf_binlcapw
  450. (SOC_DW.Delay1_DSTATE_a, &cmnm_pct_soc[0], &cmnm_ohm_Ro[0], 12U) *
  451. rtb_OCVSOC1 + look1_iflf_binlcapw(SOC_DW.Delay1_DSTATE_a, &cmnm_pct_soc[0],
  452. &cmnm_V_ocv[0], 12U)) + rtb_Merge3);
  453. SOC_DW.Delay1_DSTATE_a = ((0.0F * SOC_DW.Delay2_DSTATE_k +
  454. SOC_DW.Delay1_DSTATE_a) + rtb_Abs1) + rtb_Add_f_tmp_tmp * rtb_Abs;
  455. if (SOC_DW.Delay1_DSTATE >= 80.0F) {
  456. rtb_Abs1 = 1.0F;
  457. } else if (SOC_DW.Delay1_DSTATE_a <= 20.0F) {
  458. rtb_Abs1 = 0.0F;
  459. } else {
  460. rtb_Abs1 = (SOC_DW.Delay1_DSTATE_a - 20.0F) / ((80.0F -
  461. (SOC_DW.Delay1_DSTATE - SOC_DW.Delay1_DSTATE_a)) - 20.0F);
  462. }
  463. socd_pct_ekfSoc = (1.0F - rtb_Abs1) * SOC_DW.Delay1_DSTATE_a +
  464. SOC_DW.Delay1_DSTATE * rtb_Abs1;
  465. SOC_Conditionalcounter1(&rtb_Gain3, socc_Nr_judge, &SOC_DW.Conditionalcounter1);
  466. rtb_RelationalOperator_pu = (rtb_Gain3 >= socc_Nr_judge);
  467. SOC_Subsystem1(!rtb_RelationalOperator_pu, SOC_DW.Delay_DSTATE_l,
  468. socd_pct_ekfSoc, &SOC_B.in1_ix, &SOC_B.in2_fe,
  469. &SOC_PrevZCX.Subsystem1);
  470. if (!rtb_RelationalOperator_pu) {
  471. rtb_Abs1 = (SOC_DW.Delay_DSTATE_l - SOC_B.in1_ix) + SOC_B.in2_fe;
  472. } else {
  473. rtb_Abs1 = socd_pct_ekfSoc;
  474. }
  475. rtPrevAction = SOC_DW.If_ActiveSubsystem;
  476. SOC_DW.If_ActiveSubsystem = (int8_T)(dcmd_st_chrgSt_T2 != chrging);
  477. if (SOC_DW.If_ActiveSubsystem == 0) {
  478. if (rtPrevAction != 0) {
  479. SOC_DW.UnitDelay_DSTATE_fs = false;
  480. SOC_DW.UnitDelay_DSTATE_e = false;
  481. SOC_TimeCounter_Reset(&SOC_DW.TimeCounter);
  482. SOC_Conditionalcounter1_Reset(&SOC_DW.Conditionalcounter_i);
  483. SOC_Conditionalcounter1_Reset(&SOC_DW.Conditionalcounter1_j);
  484. }
  485. SOC_TimeCounter(&rtb_Switch, 20.0, &SOC_DW.TimeCounter);
  486. if (rtb_Switch > 20.0) {
  487. SOC_UpLim(rtb_Abs1, &rtb_Switch2_l, socc_pct_chrgCCV, 0.0);
  488. } else {
  489. rtb_Switch2_l = rtb_Abs1;
  490. }
  491. SOC_Conditionalcounter1(&rtb_Gain3_l, socc_Nr_judge,
  492. &SOC_DW.Conditionalcounter_i);
  493. rtb_RelationalOperator_pu = ((rtb_Gain3_l >= socc_Nr_judge) ||
  494. SOC_DW.UnitDelay_DSTATE_fs);
  495. SOC_Subsystem1(rtb_RelationalOperator_pu, SOC_DW.Delay_DSTATE_l,
  496. rtb_Switch2_l, &SOC_B.in1_i, &SOC_B.in2_f,
  497. &SOC_PrevZCX.Subsystem2);
  498. SOC_Conditionalcounter1(&Switch_cz, socc_Nr_judge,
  499. &SOC_DW.Conditionalcounter1_j);
  500. SOC_DW.UnitDelay_DSTATE_fs = SOC_DW.UnitDelay_DSTATE_e;
  501. SOC_DW.UnitDelay_DSTATE_e = ((Switch_cz >= socc_Nr_judge) ||
  502. SOC_DW.UnitDelay_DSTATE_fs);
  503. if (SOC_DW.UnitDelay_DSTATE_e) {
  504. socd_pct_battSocEo = socc_pct_battSocUp;
  505. } else {
  506. if (rtb_RelationalOperator_pu) {
  507. rtb_Switch2_l = (SOC_DW.Delay_DSTATE_l - SOC_B.in1_i) + fmaxf
  508. (socc_pct_chrgCCV, SOC_B.in2_f);
  509. }
  510. SOC_UpLim(rtb_Switch2_l, &socd_pct_battSocEo, socc_pct_battSocUp, -0.1);
  511. }
  512. SOC_Conditionalcounter1_Update(ihd_V_cellUMax >= look1_iflf_binlcapw
  513. (rtb_OCVSOC1, &socm_I_chrgCor[0], &socm_V_chrgCor[0], 1U), &rtb_Gain3_l,
  514. &SOC_DW.Conditionalcounter_i);
  515. SOC_DW.UnitDelay_DSTATE_fs = rtb_RelationalOperator_pu;
  516. SOC_Conditionalcounter1_Update(ihd_V_cellUMax >= cmnc_V_chrgLim, &Switch_cz,
  517. &SOC_DW.Conditionalcounter1_j);
  518. } else {
  519. if (rtPrevAction != 1) {
  520. SOC_DW.UnitDelay_DSTATE_c = false;
  521. SOC_DW.UnitDelay_DSTATE_f = false;
  522. SOC_TimeCounter_Reset(&SOC_DW.TimeCounter_c);
  523. SOC_Conditionalcounter_Reset(&SOC_DW.Conditionalcounter1_f);
  524. SOC_Conditionalcounter_Reset(&SOC_DW.Conditionalcounter_n);
  525. }
  526. SOC_TimeCounter(&rtb_Switch, 20.0, &SOC_DW.TimeCounter_c);
  527. if (rtb_Switch > 20.0) {
  528. SOC_LowLim(rtb_Abs1, &rtb_Switch2_l, socc_pct_disChrgCCV, 0.0);
  529. } else {
  530. rtb_Switch2_l = rtb_Abs1;
  531. }
  532. SOC_Conditionalcounter(&rtb_Gain3_l, socc_Nr_judge,
  533. &SOC_DW.Conditionalcounter1_f);
  534. rtb_RelationalOperator_pu = ((rtb_Gain3_l >= socc_Nr_judge) ||
  535. SOC_DW.UnitDelay_DSTATE_c);
  536. SOC_Subsystem1(rtb_RelationalOperator_pu, SOC_DW.Delay_DSTATE_l,
  537. rtb_Switch2_l, &SOC_B.in1, &SOC_B.in2,
  538. &SOC_PrevZCX.Subsystem2_e);
  539. SOC_Conditionalcounter(&Switch_cz, socc_Nr_judge,
  540. &SOC_DW.Conditionalcounter_n);
  541. SOC_DW.UnitDelay_DSTATE_c = SOC_DW.UnitDelay_DSTATE_f;
  542. SOC_DW.UnitDelay_DSTATE_f = ((Switch_cz >= socc_Nr_judge) ||
  543. SOC_DW.UnitDelay_DSTATE_c);
  544. if (SOC_DW.UnitDelay_DSTATE_f) {
  545. socd_pct_battSocEo = socc_pct_battSocLow;
  546. } else {
  547. if (rtb_RelationalOperator_pu) {
  548. rtb_Switch2_l = (SOC_DW.Delay_DSTATE_l - SOC_B.in1) + fminf
  549. (socc_pct_disChrgCCV, SOC_B.in2);
  550. }
  551. SOC_LowLim(rtb_Switch2_l, &socd_pct_battSocEo, socc_pct_battSocLow, 0.1);
  552. }
  553. SOC_Conditionalcounter_Update(ihd_V_cellUMin <= look1_iflf_binlcapw
  554. (rtb_OCVSOC1, &socm_I_disChrgCor[0], &socm_V_disChrgCor[0], 1U),
  555. &rtb_Gain3_l, &SOC_DW.Conditionalcounter1_f);
  556. SOC_DW.UnitDelay_DSTATE_c = rtb_RelationalOperator_pu;
  557. SOC_Conditionalcounter_Update(ihd_V_cellUMin <= look1_iflf_binlcapw
  558. (rtb_OCVSOC1, &socm_I_disChrgCor[0], &socm_V_emptyV[0], 1U), &Switch_cz,
  559. &SOC_DW.Conditionalcounter_n);
  560. }
  561. rtb_Abs1 = 1.0F - rtb_Add_f_tmp_tmp * rtb_MathFunction1_l[0];
  562. rtb_Switch2_l = 0.0F - rtb_MathFunction1_g * rtb_MathFunction1_l[0];
  563. tmp_0 = 1.0F - rtb_Delay_j * rtb_MathFunction1_b[0];
  564. tmp_1 = 0.0F - rtb_Switch7 * rtb_MathFunction1_b[0];
  565. for (Switch = 0; Switch < 2; Switch++) {
  566. int32_T P_Delay_DSTATE_k_tmp;
  567. real32_T P_Delay_DSTATE_k_tmp_0;
  568. real32_T P_Delay_DSTATE_k_tmp_1;
  569. P_Delay_DSTATE_k_tmp = Switch << 1;
  570. SOC_DW.P_Delay_DSTATE_k[P_Delay_DSTATE_k_tmp] = 0.0F;
  571. P_Delay_DSTATE_k_tmp_0 = rtb_Add_ij[P_Delay_DSTATE_k_tmp];
  572. SOC_DW.P_Delay_DSTATE_k[P_Delay_DSTATE_k_tmp] += P_Delay_DSTATE_k_tmp_0 *
  573. rtb_Abs1;
  574. P_Delay_DSTATE_k_tmp_1 = rtb_Add_ij[P_Delay_DSTATE_k_tmp + 1];
  575. SOC_DW.P_Delay_DSTATE_k[P_Delay_DSTATE_k_tmp] += (0.0F - rtb_Add_f_tmp_tmp) *
  576. P_Delay_DSTATE_k_tmp_1;
  577. SOC_DW.P_Delay_DSTATE_k[P_Delay_DSTATE_k_tmp + 1] = 0.0F;
  578. SOC_DW.P_Delay_DSTATE_k[P_Delay_DSTATE_k_tmp + 1] += P_Delay_DSTATE_k_tmp_0 *
  579. rtb_Switch2_l;
  580. SOC_DW.P_Delay_DSTATE_k[P_Delay_DSTATE_k_tmp + 1] += (1.0F -
  581. rtb_MathFunction1_g) * P_Delay_DSTATE_k_tmp_1;
  582. SOC_DW.P_Delay_DSTATE[P_Delay_DSTATE_k_tmp] = 0.0F;
  583. P_Delay_DSTATE_k_tmp_0 = rtb_Add_ob[P_Delay_DSTATE_k_tmp];
  584. SOC_DW.P_Delay_DSTATE[P_Delay_DSTATE_k_tmp] += P_Delay_DSTATE_k_tmp_0 *
  585. tmp_0;
  586. P_Delay_DSTATE_k_tmp_1 = rtb_Add_ob[P_Delay_DSTATE_k_tmp + 1];
  587. SOC_DW.P_Delay_DSTATE[P_Delay_DSTATE_k_tmp] += (0.0F - rtb_Delay_j) *
  588. P_Delay_DSTATE_k_tmp_1;
  589. SOC_DW.P_Delay_DSTATE[P_Delay_DSTATE_k_tmp + 1] = 0.0F;
  590. SOC_DW.P_Delay_DSTATE[P_Delay_DSTATE_k_tmp + 1] += P_Delay_DSTATE_k_tmp_0 *
  591. tmp_1;
  592. SOC_DW.P_Delay_DSTATE[P_Delay_DSTATE_k_tmp + 1] += (1.0F - rtb_Switch7) *
  593. P_Delay_DSTATE_k_tmp_1;
  594. }
  595. if (SOC_DW.Delay_DSTATE_l > socc_pct_battSocUp) {
  596. socd_pct_ahSoc = socc_pct_battSocUp;
  597. } else if (SOC_DW.Delay_DSTATE_l < socc_pct_battSocLow) {
  598. socd_pct_ahSoc = socc_pct_battSocLow;
  599. } else {
  600. socd_pct_ahSoc = SOC_DW.Delay_DSTATE_l;
  601. }
  602. if (SOC_DW.icLoad_l) {
  603. SOC_DW.Delay1_DSTATE_n = socd_pct_battSocEo;
  604. }
  605. if ((uint16_T)(SOC_DW.UnitDelay_DSTATE_m + 1U) <= 100) {
  606. Switch = (uint16_T)(SOC_DW.UnitDelay_DSTATE_m + 1U);
  607. } else {
  608. Switch = 100;
  609. }
  610. if (SOC_DW.icLoad_m) {
  611. SOC_DW.Delay2_DSTATE_b = dcmd_st_chrgSt_T2;
  612. }
  613. SOC_FristEn(&rtb_RelationalOperator_pu, &SOC_DW.FristEn_n);
  614. if (rtb_RelationalOperator_pu || ((SOC_DW.Delay2_DSTATE_b == chrging) &&
  615. (dcmd_st_chrgSt_T2 != chrging)) || ((SOC_DW.Delay2_DSTATE_b != chrging) &&
  616. (dcmd_st_chrgSt_T2 == chrging)) || (fabsf(socd_pct_battSocEo -
  617. SOC_DW.Delay1_DSTATE_n) > 2.0F) || (Switch > (uint16_T)(5U *
  618. socc_Nr_judge))) {
  619. SOC_DW.socd_pct_battSoc0_Delay_DSTATE = socd_pct_battSocEo;
  620. SOC_DW.socd_pct_bcuSoc0_Delay_DSTATE = socd_pct_bcuSocEo;
  621. }
  622. rtPrevAction = SOC_DW.If_ActiveSubsystem_j;
  623. SOC_DW.If_ActiveSubsystem_j = (int8_T)(dcmd_st_chrgSt_T2 != chrging);
  624. if (SOC_DW.If_ActiveSubsystem_j == 0) {
  625. if (rtPrevAction != 0) {
  626. SOC_fit_Reset(&SOC_DW.fit);
  627. SOC_DW.UnitDelay_DSTATE_b = 0.0F;
  628. }
  629. rtb_Delay_j = fminf(5.0F, fabsf(SOC_DW.socd_pct_battSoc0_Delay_DSTATE -
  630. SOC_DW.socd_pct_bcuSoc0_Delay_DSTATE)) + fmaxf
  631. (SOC_DW.socd_pct_battSoc0_Delay_DSTATE,
  632. SOC_DW.socd_pct_bcuSoc0_Delay_DSTATE);
  633. SOC_Subsystem(socd_pct_battSocEo, socc_pct_battSocUp, fminf
  634. (socc_pct_battSocUp, rtb_Delay_j),
  635. SOC_DW.socd_pct_battSoc0_Delay_DSTATE, socc_pct_battSocUp,
  636. SOC_DW.socd_pct_bcuSoc0_Delay_DSTATE, &rtb_Delay_j);
  637. SOC_fit(rtb_Delay_j, &rtb_Switch7, socc_pct_fitRate, &SOC_DW.fit);
  638. if (rtb_Switch7 >= SOC_DW.UnitDelay_DSTATE_b) {
  639. SOC_DW.UnitDelay_DSTATE_b = rtb_Switch7;
  640. }
  641. if (SOC_DW.UnitDelay_DSTATE_e) {
  642. SOC_DW.Delay_DSTATE = socc_pct_battSocUp;
  643. } else {
  644. SOC_UpLim(SOC_DW.UnitDelay_DSTATE_b, &SOC_DW.Delay_DSTATE,
  645. socc_pct_battSocUp, -0.1);
  646. }
  647. } else {
  648. if (rtPrevAction != 1) {
  649. SOC_fit_Reset(&SOC_DW.fit_j);
  650. }
  651. rtb_Delay_j = fminf(SOC_DW.socd_pct_battSoc0_Delay_DSTATE,
  652. SOC_DW.socd_pct_bcuSoc0_Delay_DSTATE) - fminf(5.0F,
  653. fabsf(SOC_DW.socd_pct_battSoc0_Delay_DSTATE -
  654. SOC_DW.socd_pct_bcuSoc0_Delay_DSTATE));
  655. SOC_Subsystem(socd_pct_battSocEo, SOC_DW.socd_pct_battSoc0_Delay_DSTATE,
  656. fmaxf(rtb_Delay_j, socc_pct_battSocLow), socc_pct_battSocLow,
  657. SOC_DW.socd_pct_bcuSoc0_Delay_DSTATE, socc_pct_battSocLow,
  658. &rtb_Switch7);
  659. SOC_fit(rtb_Switch7, &rtb_Delay_j, socc_pct_fitRate, &SOC_DW.fit_j);
  660. if (SOC_DW.UnitDelay_DSTATE_f) {
  661. SOC_DW.Delay_DSTATE = socc_pct_battSocLow;
  662. } else {
  663. SOC_LowLim(rtb_Delay_j, &SOC_DW.Delay_DSTATE, socc_pct_battSocLow, 0.1);
  664. }
  665. }
  666. socd_pct_battSoc = socd_pct_battSocEo;
  667. socd_pct_bcuSoc = socd_pct_bcuSocEo;
  668. socd_flg_EEsave = ((fabsf(socd_pct_battSocEo -
  669. SOC_DW.socd_flg_EEsave_Delay_DSTATE) > 1.0F) || (fabsf(socd_pct_bcuSocEo -
  670. SOC_DW.socd_flg_EEsave_Delay1_DSTATE) > 1.0F));
  671. if (socd_flg_EEsave) {
  672. SOC_DW.socd_flg_EEsave_Delay1_DSTATE = socd_pct_bcuSocEo;
  673. SOC_DW.socd_flg_EEsave_Delay_DSTATE = socd_pct_battSocEo;
  674. }
  675. SOC_DW.icLoad = false;
  676. SOC_DW.icLoad_j = false;
  677. SOC_DW.icLoad_o = false;
  678. SOC_DW.icLoad_i = false;
  679. SOC_DW.icLoad_p = false;
  680. SOC_DW.icLoad_a = false;
  681. SOC_DW.Delay2_DSTATE_k = rtb_MathFunction1_g * rtb_Abs + rtb_Merge3;
  682. SOC_Conditionalcounter1_Update((!(fabsf(rtb_Abs) > 0.05F)) && (!(fabsf
  683. (rtb_Divide_l) > 0.05F)), &rtb_Gain3, &SOC_DW.Conditionalcounter1);
  684. SOC_DW.icLoad_l = false;
  685. SOC_DW.Delay1_DSTATE_n = socd_pct_battSocEo;
  686. SOC_DW.UnitDelay_DSTATE_m = (uint16_T)((fabsf(rtb_OCVSOC1) < 1.0F) * Switch);
  687. SOC_DW.icLoad_m = false;
  688. SOC_DW.Delay2_DSTATE_b = dcmd_st_chrgSt_T2;
  689. }
  690. void SOC_initialize(const char_T **rt_errorStatus)
  691. {
  692. RT_MODEL_SOC_T *const SOC_M = &(SOC_MdlrefDW.rtm);
  693. rt_InitInfAndNaN(sizeof(real_T));
  694. rtmSetErrorStatusPointer(SOC_M, rt_errorStatus);
  695. SOC_PrevZCX.Subsystem2_e.Subsystem1_Trig_ZCE = POS_ZCSIG;
  696. SOC_PrevZCX.Subsystem2.Subsystem1_Trig_ZCE = POS_ZCSIG;
  697. SOC_PrevZCX.Subsystem1.Subsystem1_Trig_ZCE = POS_ZCSIG;
  698. }