/****************************************************************** * Copyright (C) 2023 - 2023 OneChip, Inc. All rights reserved. * File name: van_com_algorithm.h * Author: fanyidong Date:2024.1.21 * Description: 常用算法定义 * Others: * History: 1. Date: Author: Modification: *****************************************************************/ #ifndef VAN_COM_ALGORITHM_H #define VAN_COM_ALGORITHM_H #include "communication.h" #define VAN_COM_HEADER_FALG 0x55AA #define VAN_COM_TAIL_FALG 0x5AA5 #define VAN_CFG_NONE 0 #define SIZEOF_MSG_ST 8 #define SIZEOF_MSG_MODBUS 8 #define combine_cmdMessage(msg,header,typeer,cmder,tailer) {\ msg.head = header; \ msg.type = typeer; \ msg.cmd = cmder; \ } typedef struct { float realtemp; float goal; float err; float err_last; float Kp,Ki,Kd; float variate; float integral; }pid_def; float PIDRealize(pid_def *pid); unsigned int checkSum(const unsigned char *pInBuffer, unsigned int uLen); int DecodeNew(CmdMessage* pMessage, unsigned char *pdata, const unsigned char *pInBuffer, unsigned int *pheader,unsigned int ulast,unsigned int maxlen); int DecodeModbud_RTU(unsigned char *pdata,const unsigned char *pInBuffer, unsigned int *pheader, unsigned int ulast, unsigned int maxlen); int hex_to_ascii(const void *hex, void *string, int len); int Decode(CmdMessage *pMessage, const unsigned char *pInBuffer, int uLen); #endif