van_com_algorithm.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /******************************************************************
  2. * Copyright (C) 2023 - 2023 OneChip, Inc. All rights reserved.
  3. * File name: van_com_algorithm.h
  4. * Author: fanyidong Date:2024.1.21
  5. * Description: 常用算法定义
  6. * Others:
  7. * History:
  8. 1. Date:
  9. Author:
  10. Modification:
  11. *****************************************************************/
  12. #ifndef VAN_COM_ALGORITHM_H
  13. #define VAN_COM_ALGORITHM_H
  14. #include "communication.h"
  15. #define VAN_COM_HEADER_FALG 0x55AA
  16. #define VAN_COM_TAIL_FALG 0x5AA5
  17. #define VAN_CFG_NONE 0
  18. #define SIZEOF_MSG_ST 8
  19. #define SIZEOF_MSG_MODBUS 8
  20. #define combine_cmdMessage(msg,header,typeer,cmder,tailer) {\
  21. msg.head = header; \
  22. msg.type = typeer; \
  23. msg.cmd = cmder; \
  24. }
  25. typedef struct
  26. {
  27. float realtemp;
  28. float goal;
  29. float err;
  30. float err_last;
  31. float Kp,Ki,Kd;
  32. float variate;
  33. float integral;
  34. }pid_def;
  35. float PIDRealize(pid_def *pid);
  36. unsigned int checkSum(const unsigned char *pInBuffer, unsigned int uLen);
  37. int DecodeNew(CmdMessage* pMessage, unsigned char *pdata, const unsigned char *pInBuffer, unsigned int *pheader,unsigned int ulast,unsigned int maxlen);
  38. int DecodeModbud_RTU(unsigned char *pdata,const unsigned char *pInBuffer, unsigned int *pheader, unsigned int ulast, unsigned int maxlen);
  39. int hex_to_ascii(const void *hex, void *string, int len);
  40. int Decode(CmdMessage *pMessage, const unsigned char *pInBuffer, int uLen);
  41. #endif