alejoseb / Modbus-STM32-HAL-FreeRTOS

Modbus TCP and RTU, Master and Slave for STM32 using Cube HAL and FreeRTOS
GNU Lesser General Public License v2.1
539 stars 183 forks source link

RS485 dose not work for the second time #18

Closed houchaoo closed 3 years ago

houchaoo commented 3 years ago

the first time is ok ,the data is correct ,but another message does not resoponse

alejoseb commented 3 years ago

Hi, I need more details about your issue, setup, hardware and software configuration. Otherwise, I cannot help you. Thanks

houchaoo commented 3 years ago

Hi thanks for reply,my mcu is stm32f407vgt6, the 485 chip is ADM2587EBRWZ,the setting is like this below.

ModbusH.uModbusType = MB_SLAVE;
ModbusH.port = &huart3; // This is the UART port connected to STLINK in the NUCLEO F429
ModbusH.u8id = 1; //slave ID
ModbusH.u16timeOut = 1000;
ModbusH.EN_Port = RS485_Ctrl_GPIO_Port;
ModbusH.EN_Pin=RS485_Ctrl_Pin;
//ModbusH2.EN_Port = LD2_GPIO_Port; // RS485 Enable
//ModbusH2.EN_Pin = LD2_Pin; // RS485 Enable
 ModbusH.xTypeHW = USART_HW;

ModbusH.u16regs = ModbusDATA;
ModbusH.u16regsize = sizeof(ModbusDATA) / sizeof(ModbusDATA[0]);
//Initialize Modbus library
ModbusInit(&ModbusH);
//Start capturing traffic on serial Port
ModbusStart(&ModbusH);

image

the first time when i send the read message ,i can get a reply form my mcu,however when i try to read again ,the mcu reply nothing,and another time i try to read ,the mcu works ok, and so on ....

houchaoo commented 3 years ago

image image image image image image

houchaoo commented 3 years ago

RS232 works fine..

houchaoo commented 3 years ago

I find that when i switch the RS485 ctrl pin ,I got a message "0x00" may be the 485 chip is not good . thanks a lot

alejoseb commented 3 years ago

Yes probably that is the problem. I have tested with transceivers MAX485 without any issue, I verified the control signal with an oscilloscope. I have also used the MAX1438, which does not require the control signal.

houchaoo commented 3 years ago

when I change the T35 from 5 to 6,the 485 works fine...thanks a lot ,Your project is wonderful

alejoseb commented 3 years ago

Glad to know this library is useful for your project, I will close this issue then.