Przeglądaj źródła

240408 before change uart

SKY-20210407USB\Administrator 1 rok temu
rodzic
commit
7c2e7fbcdb
4 zmienionych plików z 17 dodań i 11 usunięć
  1. 7 7
      ALGO_PID_ATY.c
  2. 3 2
      HW_UART_ATY.h
  3. 6 2
      MODBUS_S_LOW_ATY.c
  4. 1 0
      MODBUS_S_LOW_ATY.h

+ 7 - 7
ALGO_PID_ATY.c

@@ -46,14 +46,14 @@
 double PidCalc(PID* pidStruct, double nextPoint)
 {
     double dError, Error;
-    Error = pidStruct->SetPoint - nextPoint;                    //Deviation
-    pidStruct->SumError += Error;                               //Integral
-    dError = pidStruct->LastError - pidStruct->PrevError;       //Current differential
-    pidStruct->PrevError = pidStruct->LastError;
+    Error = pidStruct->SetPoint - nextPoint;                    // Deviation
+    pidStruct->SumError += Error;                               // Integral
+    dError = pidStruct->LastError - pidStruct->PrevError;       // Current differential
+    pidStruct->PrevError = pidStruct->LastError; 
     pidStruct->LastError = Error;
-    return (pidStruct->Proportion * Error                       //Proportional
-        + pidStruct->Integral * pidStruct->SumError             //Integral item
-        + pidStruct->Derivative * dError);                      //Differential item
+    return (pidStruct->Proportion * Error                       // Proportional
+        + pidStruct->Integral * pidStruct->SumError             // Integral item
+        + pidStruct->Derivative * dError);                      // Differential item
 }
 
 /**

+ 3 - 2
HW_UART_ATY.h

@@ -37,8 +37,9 @@
 
 /******************************************************************************/
 
-#define UART_RX_MAX_LEN (9 + (15 * 4))
-#define PRINTF_RX_MAX_LEN 64
+// #define UART_RX_MAX_LEN (9 + (15 * 4))
+#define UART_RX_MAX_LEN (254)
+#define PRINTF_RX_MAX_LEN 254
 // #define UART_RX_MAX_LEN 16
 typedef struct _uartMsgStruct{
     uint8_t rx[UART_RX_MAX_LEN];

+ 6 - 2
MODBUS_S_LOW_ATY.c

@@ -125,6 +125,7 @@ uint8_t Modbus_Process(uint8_t* buf, uint8_t len, struct MODBUS_S_LOW_ATY_Dev* d
                         sendBuf[5] = dev->mbRegs[startAddr];
                     }
                     sendBufSize += 4;
+                    dev->setFlag = 1;
                     break;
                 }
                 case MODBUS_FUNC_WRITE_MULTY_HOLDING_REGISTERS:{
@@ -152,12 +153,15 @@ uint8_t Modbus_Process(uint8_t* buf, uint8_t len, struct MODBUS_S_LOW_ATY_Dev* d
                     sendBuf[4] = regCount >> 8;
                     sendBuf[5] = regCount;
                     sendBufSize += 4;
-                    break; }
+                    dev->setFlag = 1;
+                    break;
+                }
                 default:{
                     sendBuf[1] = buf[1] + 0x80;
                     sendBuf[2] = 0x01;
                     sendBufSize = 6;
-                    break; }
+                    break;
+                }
             }
         }
         sendBuf[sendBufSize - 2] = GenCrc16ModbusHL(sendBuf, sendBufSize - 2, 1);

+ 1 - 0
MODBUS_S_LOW_ATY.h

@@ -50,6 +50,7 @@ struct MODBUS_S_LOW_ATY_Dev
 
     uint8_t bigEndian;      // 1 for big endian(51 core)
     uint8_t(*uartSendBytes)();
+    uint8_t setFlag;
 
     uint8_t lock;
     uint8_t debugEnable;