Modbus rtu/tcp, network reply

Source: Internet
Author: User
Tags readable



==========================================================================================================

For advice, Modbus device address starting from 40000 and not starting from 0, is there any particular argument, or is it just that everyone is used to it?

I'm here to help you answer.
(1),
MODBUS is divided into 0X, 1x,3x,4x four kinds of registers.
0X---> Discrete output (Readable and writable) the corresponding PLC is: do
1X---> Discrete input (read only) plc for: DI
3X---> Input register 16-bit (read-only) the corresponding PLC is: AI
4X---> Hold register 16-bit (readable writable) corresponding PLC: AO
At the same time according to the above specification, can also expand 0X and 4X, where ox can not only correspond to do, but also corresponding to the host computer sent "button"
4X not only can correspond to AO, but also can correspond to "setting parameters" of the host computer.
(2), why the Modbus device address starting from 40000 and not starting from 0, what is the special argument, or just people are accustomed to this use
(A), device address starting from 40001
Because it belongs to the 4X register, while the 0X register is starting from 00001, the 1X register starts from 10001 and the rest is identical.
(B), in fact, 40001 corresponds to the No. 0 address cell of the buffer in your program,
If: Your program defines a buffer (20) to exchange data with the host computer 40001-40020, then
40001----> BUFFER (0)
40002----> BUFFER (1)
40003----> BUFFER (2)
40004----> BUFFER (3)
........................
40020----> BUFFER (19)





========================================================================================================== who did the Modbus? /tcp the transplant on the stm32? Give me a clue?

The TCP data is processed by the network protocol stack and sent to the Modbus protocol stack, and the network protocol stack is used to send the data after parsing.


MODBUS-TCP Communication Server (slave) Everyone is transplant freemodbus-tcp.

A lot of examples on the Internet are modbus-tcp to do the host (client) example comparison, do lower machine slave (server) example is very few, seems to be about the freemodbus-tcp transplant data
Want to directly transplant freemodbus but not completely, there is no self-written from the return code, Modbus in the slave example a lot of AH
Consult the following people have relevant link instance, or code link is better,

Generally write their own, in fact, Modbus-tcp and Modbus-rtu is the same, the difference is that TCP does not address bytes, the first byte of the RTU is the address.
==========================================================================================================

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.