This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Zephyr MODBUS samples

Hi

We wan't use in our project some MODBUS sensors and I found, that Nordic Connect SDK (I use version 1.9.1) with Zephyr has support for MODBUS. I tried the samples (rtu- server and rtu-client), but I don't get  them work. They  compile OK and if I look with logic analyzer, client is asking and the server is answering with right data and frames, but client shows always:

Everything is connected as it should (server is answering). Has anyone tried the MODBUS samples and get them to work?

I add also logic analyzer images:

That is the client asking

And server answers:

Tiit

  • Hi Tiit,

    I haven't been able to reproduce the problem you reported. I used the same MODBUS example and nRF Connect SDK v1.9.1. I have also tried with nRF Connect SDK v1.8.0 and that also worked well. I haven't observed warnings neither for frame size nor for timeout. The communication was working well as observed in the output of the COM ports.
    In my setup the error which you reported shows up only when I disconnect one of the Tx/Rx lines which connect two boards. In this case OFF/ON sequence was needed on the client side. After that everything started to work as expected.

    I would suggest you to try the same example without sensors and see if you get any errors. Ensure that everything is properly connected. Later, if you change for example pins in prj.conf file, make sure that you also change pins when physically connecting the boards together.

    Best regards,
    Dejan

  • Hi Dejan

    Do you use also RS232 for communication? I have tested the example first -- I didn't touch the settings (only commented DE pin out, because I don't use RS485 tranceiver) and connected Arduino serial (UART1, RX - 1.01, TX - 1.02) pins crossed between two boards -- I see only RX timed out.

    It's strange, because the server board is recieving coil change messages (log shows, but LED-s stay off).

    The client board is sending MODBUS messages and server board is answering (as I see from logic analyzer), but client board  shows only the RX timeout error.

    Tiit

  • Hi Tiit,

    Tiit said:
    Do you use also RS232 for communication? I have tested the example first -- I didn't touch the settings (only commented DE pin out, because I don't use RS485 tranceiver) and connected Arduino serial (UART1, RX - 1.01, TX - 1.02) pins crossed between two boards -- I see only RX timed out.


    I connected two boards the same way, with pins P1.01 and P1.02 on one board connected to the pins P1.02 and P1.01 on the second board, respectively. I did not use RS485 and I was observing communication on the boards' COM ports.

    Tiit said:

    It's strange, because the server board is recieving coil change messages (log shows, but LED-s stay off).

    The client board is sending MODBUS messages and server board is answering (as I see from logic analyzer), but client board  shows only the RX timeout error.

    I could see "Coils state change" on the client side, and "Coil write" and "Coil read" on the server side.

    Best regards,
    Dejan

  • Hi Dejan

    I got it working, but I don't know what was the problem actually. I removed everything releated to SDK, cleaned the folders and reinstalled from scratch and the example worked straight out of the box. That is strange, because it was not working with 1.8.0, 1.9.0 and also with 1.9.1 -- i tried different SDK versions more than one time. 

    I got my sensor also working -- Senseair Sunrise uses non-standard approach for MODBUS checksum stopbits and I modified SDK-s Zephyr MODBUS subsystem files with a patch, that is included in newer Zephyr version (modbus: stop bits can now be set individually by Constikri · Pull Request #40558 · zephyrproject-rtos/zephyr · GitHub).

    Tiit

  • Hi Tiit,

    It is great to hear that you got everything working.

    Best regards,
    Dejan

Related