TMS.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * @Author : ChenJie
  3. * @Date : 2021-11-08 10:44:13
  4. * @Version : V3.0
  5. * @LastEditors : ChenJie
  6. * @LastEditTime : 2021-11-08 14:34:38
  7. * @Description : file content
  8. * @FilePath : \PLAT\project\ec616_0h00\apps\qx_app\src\EmbeddedCoder_src\TMS.c
  9. */
  10. #include "TMS.h"
  11. boolean_T FirstRun_TMS;
  12. void TMS_Init(void)
  13. {
  14. FirstRun_TMS = true;
  15. }
  16. void TMS(void)
  17. {
  18. static uint8_T TminLowNr;
  19. static uint8_T TminOverNr;
  20. static uint8_T TmaxOverNr;
  21. //初始值
  22. if (FirstRun_TMS)
  23. {
  24. tmsd_st_heatAct = 0;
  25. TminLowNr = 0;
  26. TminOverNr = 0;
  27. TmaxOverNr = 0;
  28. }
  29. //
  30. if (sfmd_T_modTMin < tmsc_T_openThr)
  31. {
  32. TminLowNr = (TminLowNr + 1) > 200 ? 200 : (TminLowNr + 1);
  33. }
  34. else
  35. {
  36. TminLowNr = 0;
  37. }
  38. //
  39. if (sfmd_T_modTMin >= tmsc_T_closeMinThr)
  40. {
  41. TminOverNr = (TminOverNr + 1) > 200 ? 200 : (TminOverNr + 1);
  42. }
  43. else
  44. {
  45. TminOverNr = 0;
  46. }
  47. //
  48. if (sfmd_T_modTMax >= tmsc_T_closeMaxThr)
  49. {
  50. TmaxOverNr = (TmaxOverNr + 1) > 200 ? 200 : (TmaxOverNr + 1);
  51. }
  52. else
  53. {
  54. TmaxOverNr = 0;
  55. }
  56. //================================温度判定 开关热管理状态===============================
  57. if (tmsd_st_heatAct == 0)
  58. {
  59. if (TminLowNr >= 5 && ((socd_pct_battSoc > 100 && ihd_st_disChrgMosControl == 1) || ihd_st_chrgConnect == 1))
  60. {
  61. tmsd_st_heatAct = 1;
  62. }
  63. }
  64. else
  65. {
  66. if (TmaxOverNr >= 5 || TminOverNr >= 5 || (ihd_st_chrgConnect == 0 && socd_pct_battSoc < 50))
  67. {
  68. tmsd_st_heatAct = 0;
  69. }
  70. }
  71. //因故障关闭热管理
  72. if (((sfmd_st_fltAct >> 4) & 0x01) == 1)
  73. {
  74. tmsd_st_heatAct = 0;
  75. }
  76. //强制控制加热回路
  77. if (ihd_st_heatForceControl == 1)
  78. {
  79. tmsd_st_heatAct = 1;
  80. }
  81. if (ihd_st_heatForceControl == 2)
  82. {
  83. tmsd_st_heatAct = 0;
  84. }
  85. FirstRun_TMS = false;
  86. }