diff --git a/applications/PLC_link.c b/applications/PLC_link.c index 582ee33..e7b997b 100644 --- a/applications/PLC_link.c +++ b/applications/PLC_link.c @@ -65,23 +65,22 @@ static void mb_plc_read_regs(mb_inst_t *hinst) // 写入 Modbus mb_write_bits(hinst, 2256, DO_TABLE_SIZE, w_buffer); - - /* u16 regs[64]; - int addr = 7000; - int nb = 10; - int total = mb_write_regs(hinst, addr, nb, regs); - if (total <= 0) + //输入寄存器d0->6000 u16 r_regsD[AI_TABLE_SIZE]; + // 读 Modbus + mb_read_regs(hinst, 6000, AI_TABLE_SIZE, r_regsD); + for (int i = 0; i < AI_TABLE_SIZE; i++) { - return; + ai_table[i].current_Value = r_regsD[i]; } - u8 regsM[64]; - int addrM = 3000; - int nbM = 10; - int totalM = mb_read_bits(hinst, addrM, nbM, regsM); - if (totalM <= 0) + + //输出寄存器d100->6100 + u16 w_regsD [AO_TABLE_SIZE]; + for (int i = 0; i < AO_TABLE_SIZE; i++) { - return; - }*/ + w_regsD [i] = ao_table[i].current_Value; + } + // 写入 Modbus + mb_write_regs(hinst, 6100, AO_TABLE_SIZE, w_regsD); } static void mb_plc_thread(void *args)//线程服务函数 diff --git a/applications/data/SC828_DATA_table.c b/applications/data/SC828_DATA_table.c index 4510cdf..fefcd61 100644 --- a/applications/data/SC828_DATA_table.c +++ b/applications/data/SC828_DATA_table.c @@ -1,6 +1,10 @@ #include "SC828_DATA_table.h" #include "Variable.h" +#define DBG_TAG "data.table" +#define DBG_LVL DBG_LOG +#include + // 系统数据状态表(表格) IO_State_DATA data_table[] = { {1001, 0, STR_COMM_COUNTER}, @@ -19,7 +23,7 @@ IO_State_DATA data_table[] = { // DIO状态表(表格) IO_State_DIO di_table[] = { - {2001, 0, STR_EMERGENCY_STOP}, + {2001, 0, STR_EMERGENCY_STOP}, {2002, 0, STR_TEMP_LOCK}, {2003, 0, STR_PRESSURE_LOCK}, {2004, 0, STR_CALL_CONFIRM}, @@ -104,7 +108,7 @@ IO_State_DIO di_table[] = { }; // --- DIO 输出(3001~3066)--- IO_State_DIO do_table[] = { -{3001, 1, STR_RED}, // 红 + {3001, 1, STR_RED}, // 红 {3002, 0, STR_GREEN}, // 绿 {3003, 0, STR_YELLOW}, // 黄 {3004, 0, STR_ALARM}, // 警报 @@ -173,7 +177,7 @@ IO_State_DIO do_table[] = { }; //AIO状态表 -IO_State_AIO aio_table[] = { +IO_State_AIO ai_table[] = { // --- AIO 输入(4001~4022)--- {4001, 0, STR_AIO_TEMP1}, {4002, 0, STR_AIO_TEMP2}, @@ -197,7 +201,9 @@ IO_State_AIO aio_table[] = { {4020, 0, STR_AIO_FABRIC_CYCLE5}, {4021, 0, STR_AIO_FABRIC_CYCLE6}, {4022, 0, STR_AIO_PH}, +}; // --- AO 输出(5001~5014)--- +IO_State_AIO ao_table[] = { {5001, 0, STR_AIO_HEAT_RATIO}, {5002, 0, STR_AIO_COOL_RATIO}, {5003, 0, STR_AIO_MAIN_PUMP_SPEED}, @@ -218,7 +224,8 @@ IO_STEP_DATA step_table[99]; const unsigned char DI_TABLE_SIZE = sizeof(di_table) / sizeof(di_table[0]); const unsigned char DO_TABLE_SIZE = sizeof(do_table) / sizeof(do_table[0]); -const unsigned char AIO_TABLE_SIZE = sizeof(aio_table) / sizeof(aio_table[0]); +const unsigned char AI_TABLE_SIZE = sizeof(ai_table) / sizeof(ai_table[0]); +const unsigned char AO_TABLE_SIZE = sizeof(ao_table) / sizeof(ao_table[0]); const unsigned char DATA_TABLE_SIZE = sizeof(data_table) / sizeof(data_table[0]); void DATA_Table_Init(){ @@ -231,10 +238,15 @@ void DATA_Table_Init(){ do_table[i].current_state = 0; } - for(int i=0;i #include "lvgl.h" - #define DBG_TAG "gui" #define DBG_LVL DBG_LOG #include