TMS.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #include "TMS.h"
  2. boolean_T FirstRun_TMS;
  3. void TMS_Init(void)
  4. {
  5. FirstRun_TMS = true;
  6. }
  7. void TMS(void)
  8. {
  9. static uint8_T TminLowNr;
  10. static uint8_T TminOverNr;
  11. static uint8_T TmaxOverNr;
  12. //初始值
  13. if (FirstRun_TMS)
  14. {
  15. tmsd_st_heatAct = 0;
  16. TminLowNr = 0;
  17. TminOverNr = 0;
  18. TmaxOverNr = 0;
  19. }
  20. //
  21. if (sfmd_T_modTMin < tmsc_T_openThr)
  22. {
  23. TminLowNr = (TminLowNr + 1) > 200 ? 200 : (TminLowNr + 1);
  24. }
  25. else
  26. {
  27. TminLowNr = 0;
  28. }
  29. //
  30. if (sfmd_T_modTMin >= tmsc_T_closeMinThr)
  31. {
  32. TminOverNr = (TminOverNr + 1) > 200 ? 200 : (TminOverNr + 1);
  33. }
  34. else
  35. {
  36. TminOverNr = 0;
  37. }
  38. //
  39. if (sfmd_T_modTMax >= tmsc_T_closeMaxThr)
  40. {
  41. TmaxOverNr = (TmaxOverNr + 1) > 200 ? 200 : (TmaxOverNr + 1);
  42. }
  43. else
  44. {
  45. TmaxOverNr = 0;
  46. }
  47. //================================温度判定 开关热管理状态===============================
  48. if (tmsd_st_heatAct == 0)
  49. {
  50. if (TminLowNr >= 5 && ((socd_pct_battSoc > 100 && ihd_st_disChrgMosControl == 1) || ihd_st_chrgConnect == 1))
  51. {
  52. tmsd_st_heatAct = 1;
  53. }
  54. }
  55. else
  56. {
  57. if (TmaxOverNr >= 5 || TminOverNr >= 5 || (ihd_st_chrgConnect == 0 && socd_pct_battSoc < 50))
  58. {
  59. tmsd_st_heatAct = 0;
  60. }
  61. }
  62. //因故障关闭热管理
  63. if (((sfmd_st_fltAct >> 4) & 0x01) == 1)
  64. {
  65. tmsd_st_heatAct = 0;
  66. }
  67. //强制控制加热回路
  68. if (ihd_st_heatForceControl == 1)
  69. {
  70. tmsd_st_heatAct = 1;
  71. }
  72. if (ihd_st_heatForceControl == 2)
  73. {
  74. tmsd_st_heatAct = 0;
  75. }
  76. printf("tmsd_st_heatAct:%d\n",tmsd_st_heatAct);
  77. FirstRun_TMS = false;
  78. }