ALGO_WaveAnalyse_ATY.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /**
  2. * @file ALGO_WaveAnalyse_ATY.h
  3. *
  4. * @param Project ALGO_Algorithm_ATY_LIB
  5. *
  6. * @author ATY
  7. *
  8. * @copyright
  9. * - Copyright 2017 - 2025 MZ-ATY
  10. * - This code follows:
  11. * - MZ-ATY Various Contents Joint Statement -
  12. * <a href="https://mengze.top/MZ-ATY_VCJS">
  13. * https://mengze.top/MZ-ATY_VCJS</a>
  14. * - CC 4.0 BY-NC-SA -
  15. * <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  16. * https://creativecommons.org/licenses/by-nc-sa/4.0/</a>
  17. * - Your use will be deemed to have accepted the terms of this statement.
  18. *
  19. * @brief Familiar functions of wave analyse from ad
  20. *
  21. * @version
  22. * - 1_01_220601 > ATY
  23. * -# Preliminary version, first Release
  24. * - Undone
  25. ********************************************************************************
  26. */
  27. #ifndef __ALGO_WaveAnalyse_ATY_H
  28. #define __ALGO_WaveAnalyse_ATY_H
  29. #include "INCLUDE_ATY.h"
  30. /******************************* For user *************************************/
  31. // #define __DEBUG_ALGO_WaveAnalyse_ATY
  32. /******************************************************************************/
  33. extern uint16_t wave_lastWaveAve_Kalman;
  34. extern uint16_t wave_firstWavePeakPoint, wave_firstWaveZeroPoint;
  35. extern uint16_t wave_quarterSpace;
  36. extern uint16_t wave_maxVpp;
  37. #define WAVE_DISPLAY_NUM 100
  38. #define WAVE_DISPLAY_PEAK_HIGH (wave_lastWaveAve_Kalman + (WAVE_DISPLAY_NUM * 2))
  39. #define WAVE_DISPLAY_PEAK_LOW (wave_lastWaveAve_Kalman - (WAVE_DISPLAY_NUM * 2))
  40. #define WAVE_DISPLAY_ZERO_RAISE (wave_lastWaveAve_Kalman + WAVE_DISPLAY_NUM)
  41. #define WAVE_DISPLAY_ZERO_FALL (wave_lastWaveAve_Kalman - WAVE_DISPLAY_NUM)
  42. #define WAVE_BASE_AVE (wave_lastWaveAve_Kalman)
  43. #define WAVE_KALMAN_ATTENUATION 2
  44. void WavePeakZeroPointFind(
  45. uint16_t* inputWave,
  46. uint16_t* kalmanWave,
  47. uint16_t* deepKalmanWave,
  48. uint16_t* peakZeroPoints,
  49. uint16_t size);
  50. #define WAVE_FIRST_COUNT 10
  51. #define WAVE_FIRST_THRESHOLD_V 25
  52. #define FIRST_THRESHOLD_HIGH (wave_lastWaveAve_Kalman + WAVE_FIRST_THRESHOLD_V)
  53. #define FIRST_THRESHOLD_LOW (wave_lastWaveAve_Kalman - WAVE_FIRST_THRESHOLD_V)
  54. void WaveFirstPulseFind(uint16_t* inputWave, uint16_t* peakZeroPoints, uint16_t size);
  55. // trans time(12bit@36MHz ADCCLK) = point to point time
  56. // 15 x 1_000_000us / 36_000_000Hz = 5/12us = 0.4167us
  57. #define ADC_TIME_UNIT (15.0 / 36.0)
  58. void WaveParamCalc(uint16_t* peakZeroPoints, uint16_t firstWavePoint, uint16_t size);
  59. void WaveVppCalc(uint16_t* peakZeroPoints, uint16_t* kalmanWave, uint16_t size);
  60. void WaveWholeProcess(
  61. uint16_t* inputWave,
  62. uint16_t* kalmanWave,
  63. uint16_t* deepKalmanWave,
  64. uint16_t* peakZeroPoints,
  65. uint16_t size);
  66. #ifdef __DEBUG_WAVE_ATY
  67. #define TEST_WAVE_SIZE 5000
  68. extern uint16_t kalmanWave_Test[TEST_WAVE_SIZE];
  69. extern uint16_t deepKalmanWave_Test[TEST_WAVE_SIZE];
  70. extern uint16_t peakZeroPoints_Test[TEST_WAVE_SIZE];
  71. void WaveAnalyse_Test(uint16_t* testDataIn, uint8_t WAVE_DISPLAY_FLAG);
  72. #endif /* __DEBUG_WAVE_ATY */
  73. // float ALGO_WaterDensityFromTemp(float temperature);
  74. // float ALGO_EConductanceFromRes(float Res);
  75. // float ALGO_ResistivityFromRes(float Res, float A, float L);
  76. // float ALGO_ConductivityFromRes(float Res, float A, float L);
  77. // float ALGO_MolarityFromConductivity(float Conductivity, float MC);
  78. // float ALGO_MassConcentrationFromMolarity(float Molarity, float MM);
  79. #endif /* __ALGO_WaveAnalyse_ATY_H */
  80. /******************************** End Of File *********************************/