Skip to content

Timeout when receiving modbus data #92

@octarudin

Description

@octarudin

Hello, I don't know where my mistake is. Plase help me. Below is my specification.

  • STM32F411CE 100Mhz PLL HSE Clock.
  • Wiring diagram, logic analyzer screenshot, and source code attached.
  • USART1 (PA9 as USART1_TX and PA10 as USART1_RX) just for printf / transmit serial data to PC.
  • USART2 (PA2 as USART2_TX and PA3 as USART2_RX) for communicating with modbus devices (in this case PZEM-016 and XY-MD02).
  • Not using USART Interrupt.
  • Slave ID=1, Start address to read=0, Quantity=10 for PZEM-016.
  • Slave ID=2, Start address to read=1, Quantity=2 for XY-MD02.
  • Reading Input Register (FC 04) for those modbus devices.
  • I use TTL-RS485 module.

The problem:
this code always get timeout when receive modbus data, but it can write modbus frame successfully.

nmbs_error err = nmbs_read_input_registers(&nmbs, 1, 10, &r_reg)
the err value always NMBS_ERROR_TIMEOUT.

Source Code in txt, generated by STM32CubeMX
source code.txt

Wiring diagram
Image

Serial monitor output / USART1
Image

Logic analyzer on TTL-RS485 Module
Image

Thanks for helping me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions