cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus slave RTU/ASCII

Hghas
Associate II

Hi

I want to implement Modbus slave RTU/ASCII protocol on STM32F103VET6. I have read many forums about Modbus and examined several libraries, but unfortunately I couldn’t do it and I’m disappointed. 

In this blog: https://blog.naver.com/eziya76/220970378890 (this is Korean, I translated it with google) there is a full explanation of running Modbus, but when I test with ‘Modbus poll’, the error ‘Time out’ occurs. The library is here: https://github.com/cwalter-at/freemodbus 

Maybe I’m missing something or doing something wrong. I uploaded my project and schematic of my discovery board. I’m using Usart1 (PA9 , PA10 pins) for Modbus and connect it with Usb cable to PC. 

After all, if you have a good manual or know a better library, please let me know.

I really appreciate if someone helps me. This is very important for me.

Thank you very much…

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel A.
Evangelist III

IMHO, the Modbus serial protocol cannot be expected to work well over USB CDC emulated serial connection on either side. All timing will be distorted.

-- pa

View solution in original post

4 REPLIES 4
Pavel A.
Evangelist III

IMHO, the Modbus serial protocol cannot be expected to work well over USB CDC emulated serial connection on either side. All timing will be distorted.

-- pa

Thank you.

Yes, at first I guessed so, but in the blog, he used usb serial for modbus protocol. I don't know how that works.

So, if I run the library and use a RS485 IC like SP3485 (in the pdf above) will this work? 

Pavel A.
Evangelist III

It could be other problem as well. Have you tested that the serial TX/RX work, with some terminal program?

-- pa

Ok, I'll check it. 

My discovery board has a RS485 module (SP3485 IC). I want to use this instead of serial port. This IC has two states, driver enable and reciever enable. When should I enable driver mode and when I should enable reciever mode?

Thanks for your help...​