logo elektroda
logo elektroda
X
logo elektroda

[Visual Basic] Explore Modbus Protocol Techniques and Checksum Calculation in VB

tengu 8261 6
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 658428
    tengu
    Level 21  
    Hello! Does anyone have examples of transmission with the MODBUS protocol under vb?
    I mean specifically the method of calculating the checksum and releasing the data to com. Thank you in advance!

    PS I'm just "trying" to learn vb :D

    I close. - arnoldziq
  • ADVERTISEMENT
  • #2 660731
    juntom
    Level 19  
    What MODBUS version do you want to use. If ASCI is a checksum then exor of all bytes and if RTU is the sum of CRC16. Unfortunately, I do not know VB.
  • ADVERTISEMENT
  • #3 661516
    tengu
    Level 21  
    I really care about RTU. How do you calculate the checksum anyway?
  • #4 661977
    juntom
    Level 19  
    As for the sum of crc16 see here:
    https://www.elektroda.pl/rtvforum/topic99019.html

    Modbus rtu is generally not that difficult / it was finally built well 20 years ago /. You must detect silence in the program for more than 3.5 times the time of a single character as a start condition and then take the characters one by one. After receiving the whole frame, count the crc16 frames - the last 2 characters / that is the sum of crc16 sent by the master / and then compare it with the sent.
    I have a program somewhere that I once downloaded from the net for the purpose of testing a device of my design with the Modbus RTU protocol. Shows the structure of the transferred frame and the answer obtained. As soon as I find him, I will send it.

    greetings
  • ADVERTISEMENT
  • #5 663289
    tengu
    Level 21  
    I will be oooooooo very grateful. (I am anyway ;) )
  • ADVERTISEMENT
  • #7 663792
    tengu
    Level 21  
    Thanks a lot. tomorrow I'll be up to speed

Topic summary

The discussion revolves around implementing the MODBUS protocol in Visual Basic (VB), specifically focusing on the RTU version and checksum calculation. Users inquire about the checksum method, with one participant explaining that for MODBUS RTU, the checksum is calculated using CRC16. They emphasize the importance of detecting silence for more than 3.5 character times as a start condition and detail the process of receiving and validating the data frame. A link to a resource for CRC16 calculation is provided, and users express gratitude for shared testing applications related to MODBUS RTU.
Summary generated by the language model.
ADVERTISEMENT