|
|
|
@ -4,10 +4,10 @@
|
|
|
|
#include "Relays.h"
|
|
|
|
#include "Relays.h"
|
|
|
|
#include "myfreertos.h"
|
|
|
|
#include "myfreertos.h"
|
|
|
|
|
|
|
|
|
|
|
|
u8 prev_sendbuf[37] = {0xEE, 0xB5, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
u8 prev_sendbuf[41] = {0xEE, 0xB5, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFC, 0xFF, 0xFF};
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFC, 0xFF, 0xFF};
|
|
|
|
u8 sendbuf[37] = {0xEE, 0xB5, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
u8 sendbuf[41] = {0xEE, 0xB5, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFC, 0xFF, 0xFF};
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFC, 0xFF, 0xFF};
|
|
|
|
u8 sendbuf_crc[20] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
u8 sendbuf_crc[20] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
extern u8 global_buffer[64];
|
|
|
|
extern u8 global_buffer[64];
|
|
|
|
@ -382,11 +382,11 @@ void RS485_1_Send_Data_2(void)
|
|
|
|
sendbuf[0] = 0xEE;
|
|
|
|
sendbuf[0] = 0xEE;
|
|
|
|
sendbuf[1] = 0xB5;
|
|
|
|
sendbuf[1] = 0xB5;
|
|
|
|
sendbuf[2] = 0x05;
|
|
|
|
sendbuf[2] = 0x05;
|
|
|
|
sendbuf[33] = 0xFF;
|
|
|
|
sendbuf[37] = 0xFF;
|
|
|
|
sendbuf[34] = 0xFC;
|
|
|
|
sendbuf[38] = 0xFC;
|
|
|
|
sendbuf[35] = 0xFF;
|
|
|
|
sendbuf[39] = 0xFF;
|
|
|
|
sendbuf[36] = 0xFF;
|
|
|
|
sendbuf[40] = 0xFF;
|
|
|
|
u8 a;
|
|
|
|
// u8 a;
|
|
|
|
if (T <= 1000 && T >= -1000)
|
|
|
|
if (T <= 1000 && T >= -1000)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (T < 0) {
|
|
|
|
if (T < 0) {
|
|
|
|
@ -459,6 +459,7 @@ void RS485_1_Send_Data_2(void)
|
|
|
|
sendbuf[26] = ((int)(pid.Ki * 100000)) % 256; // Ti 0.001
|
|
|
|
sendbuf[26] = ((int)(pid.Ki * 100000)) % 256; // Ti 0.001
|
|
|
|
sendbuf[27] = (int)pid.Kd / 256; // Td 340
|
|
|
|
sendbuf[27] = (int)pid.Kd / 256; // Td 340
|
|
|
|
sendbuf[28] = (int)pid.Kd % 256; // Td 340
|
|
|
|
sendbuf[28] = (int)pid.Kd % 256; // Td 340
|
|
|
|
|
|
|
|
|
|
|
|
// num = (((pid.OUT * 350) / pid.pwmcycle) - 1);
|
|
|
|
// num = (((pid.OUT * 350) / pid.pwmcycle) - 1);
|
|
|
|
|
|
|
|
|
|
|
|
int out1 = pid.OUT;
|
|
|
|
int out1 = pid.OUT;
|
|
|
|
@ -475,16 +476,29 @@ void RS485_1_Send_Data_2(void)
|
|
|
|
|
|
|
|
|
|
|
|
// bufcut_Init(sendbuf_crc, sendbuf, 3, 31);
|
|
|
|
// bufcut_Init(sendbuf_crc, sendbuf, 3, 31);
|
|
|
|
// GetCRC16(sendbuf_crc, 28, &crc_num1, &crc_num2);
|
|
|
|
// GetCRC16(sendbuf_crc, 28, &crc_num1, &crc_num2);
|
|
|
|
GetCRC16(sendbuf, 31, &crc_num1, &crc_num2);
|
|
|
|
|
|
|
|
sendbuf[31] = crc_num1;
|
|
|
|
|
|
|
|
sendbuf[32] = crc_num2;
|
|
|
|
int tem_offset_10times = (int)(pid.tem_offset * 10);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (tem_offset_10times < 0) {
|
|
|
|
|
|
|
|
tem_offset_10times = (~(tem_offset_10times - 1)) & 0xFFFF;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sendbuf[31] = tem_offset_10times / 256; // tem offset
|
|
|
|
|
|
|
|
sendbuf[32] = tem_offset_10times % 256;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sendbuf[33] = ((int)(pid.tem_threshold * 10)) / 256; // tem threshold
|
|
|
|
|
|
|
|
sendbuf[34] = ((int)(pid.tem_threshold * 10)) % 256;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GetCRC16(sendbuf, 35, &crc_num1, &crc_num2);
|
|
|
|
|
|
|
|
sendbuf[35] = crc_num1;
|
|
|
|
|
|
|
|
sendbuf[36] = crc_num2;
|
|
|
|
|
|
|
|
|
|
|
|
// only when modify happen, then send
|
|
|
|
// only when modify happen, then send
|
|
|
|
if (cmp_str(prev_sendbuf, sendbuf, 37) != 0) {
|
|
|
|
if (cmp_str(prev_sendbuf, sendbuf, 41) != 0) {
|
|
|
|
|
|
|
|
|
|
|
|
RS485_1_Send_Data(sendbuf, 37);
|
|
|
|
RS485_1_Send_Data(sendbuf, 41);
|
|
|
|
|
|
|
|
|
|
|
|
cp_str_to_prev(prev_sendbuf, sendbuf, 37);
|
|
|
|
cp_str_to_prev(prev_sendbuf, sendbuf, 41);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|