logo elektroda
logo elektroda
X
logo elektroda

[STM32] Implementing MODBUS Protocol for PC-Mockup Connection: Initialization & Libraries

toom16 4986 5
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 16514177
    toom16
    Level 10  
    Hello, I need to implement the connection between the mockup and the PC via the modbus protocol. Unfortunately, I have no idea how to write it in the program code. I read a lot of pages on the internet and there was nothing left. Additional libraries, eg FreeMODBUS, I have no idea how to properly implement stm32, I know that you should initialize the port and timer in two files. It's about establishing a connection and being able to read any data from the computer.
    I will just add that I do not have a board at hand because it is a university problem, and the help from the lecturer was limited only to the theoretical explanation of what modbus is.

    Anyone can help?
  • ADVERTISEMENT
  • #2 16514504
    Freddie Chopin
    MCUs specialist
    toom16 wrote:
    Anyone can help?

    Yes. But only when you ask a specific question, because nobody will throw you a ready-made project here or make it for you. You do not have to count on a description of how to do it step-by-step, because this is a topic with such a volume that it would be easy for quite a long "doing".

    toom16 wrote:
    I will just add that I do not have a plate at hand because it is a university problem

    Buy it yourself - you can spend a few dozen zlotys on some Nucleo, especially when you get to work right before the completion of the test.
  • ADVERTISEMENT
  • #3 16514554
    toom16
    Level 10  
    I would ask a specific question if I knew what to ask ;)
    I will not invest in one forced course in the network direction :P not my brooch, but unfortunately someone was smarter when they came up with it :)

    Theory, a piece of code / tips on how to establish a connection between the board and the computer, how to send / receive a frame (how to write it). But if you say that this is a river topic, I am surprised by the lecturer because it is not a task from the beginning of the semester, and as he mentioned it is "very easy" :D

    Thanks for the response!
  • ADVERTISEMENT
  • #4 16514582
    tomek_602
    Level 22  
    Since you've never dealt with this, there is no way to help you yet, because until you have formulated the right questions, no one will give you the right answer.
    Without reading the description and at least superficial understanding of Modbus, it will not be possible. For this you need to read the description of the mock-up registers - unless you are to design it yourself. And it's "trivial" only for someone who has already done the first two or three hands. The first one is always uphill.
    Once you get the hang of it, use ready-made free libraries to support the right kind of Modbus (ASCII, RTU or TCP). But first, to test the connection with the mockup, use one of the free simulators / testers, eg Radzio.
  • ADVERTISEMENT
  • #5 16514624
    Freddie Chopin
    MCUs specialist
    There are examples in the package with FreeMODBUS, so all you need to do is adjust one to your needs. These examples differ in small details, but are roughly identical - they provide a number of "holding registers" (read / write) and a number of "input registers" (read-only) after Modbus.
  • #6 16551820
    uboot571
    Level 12  
    Hello
    toom16 - did you handle the initial configuration and what stage are you at? I am also implementing the modbus on the STM32, so you can move on together.
    The FreeModbus topic on STM was already there agitated so maybe it will be useful to you.
ADVERTISEMENT