This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Nrf51822 with Modbus(TTL to RS485)

I am trying to send and receive a response from a machine using  Modbus (TTL to Rs485) and nrf51822.

Connections: R0 -> RX(P0.11) ,D1->TX(p0.09), RE&DE->P0.19,VCC->5V 

Just the same as to connect with Arduino (Have implemented with Arduino mega)

I am using Keil for programming and trying to send and receive in hexadecimal format, but I am not sure if even command is transmitted and obviously I am not getting any response.

I am not sure about connections also. Attaching code.

Please let me know where I am wrong.

Parents
  • I took another look at your code, and noticed that #ifndef ENABLE_LOOPBACK_TEST is commented out in your main loop. What exactly is happening with your loopback test? Also, I noticed you say RE&DE->P0.19. What are RE and DE? 

    Any luck using a logic analyzer to see what's going on on the UART lines? Also, what are you supplying the Modbus with? If this is 5V as well, there might be a voltage mismatch that occurs and causes this to happen.

    Best regards,

    Simon

Reply
  • I took another look at your code, and noticed that #ifndef ENABLE_LOOPBACK_TEST is commented out in your main loop. What exactly is happening with your loopback test? Also, I noticed you say RE&DE->P0.19. What are RE and DE? 

    Any luck using a logic analyzer to see what's going on on the UART lines? Also, what are you supplying the Modbus with? If this is 5V as well, there might be a voltage mismatch that occurs and causes this to happen.

    Best regards,

    Simon

Children
  • There was a voltage mismatch. The code is working. I commented on ENABLE_LOOPBACK_TEST because I don't need it. Also, RE&DE pins are enable pins for  Modbus (TTL to RS485).