Let's prepare a PLC and communication first.
We need a PLC that supports Modbus RTU communication and a USB to serial cable.
Then prepare a tool software on the computer.
1 Let's confirm the serial port parameters of the PLC.
The current serial port of PLC supports Modbus protocol.
The serial port parameters are 115200 baud rate, 8 data bits, 1 stop bit, and no parity.
2 Open the Modbus Poll tool.
The setting parameters are also 115200, 8, 1, or none.
3 Select Register Variable.
Click the button in the figure to select the register to be read or written.
Slave ID is the ID of the slave device. Set it to 1 to correspond to the PLC.
Function: It is the function code. The function corresponding to the 0X register is 01 for read.
Address: The register address to be read. Set it to 0, that is, start reading from 0, which just corresponds to the output point on the PLC.
Quantity: The number of registers. Set it to 10, we read 10 first.
Sacn Rate: Scanning cycle. The default is 1000ms. That is, read once every 1000ms.
Don’t worry about other parameters, leave them as default, and click OK.
Then it shows that all communications are connected.
Let's try setting all even addresses to 1.
Double-click the value inside, and the setting value interface will appear. Because it is written separately, the default function code 05 can be used.
It can be seen that the corresponding output point in the PLC is also set to 1.
This is a very basic Modbus RTU communication demo.
If you thought that was the end of it, you were probably right.
We start learning the Modbus protocol. There is no need to make it so complicated. Learn a little bit every day and digest the Modbus protocol slowly.
First learn how to use it, and then learn more about the protocol.
Well, if you have digested the previous content, we can continue. If you have not digested it, I suggest you save the following content and continue reading it another day.
In the experiment just now, we saw the reading and writing operations of PLC through the computer's Modbus Poll.
Don't we want to know how they use it?
Modbus Poll has a function that can display the sent and received messages, which is very helpful for us to learn the Modbus protocol.
We find the Display->Communication option and we can see the sent and received messages.
Tx:072-01 01 00 00 00 0A BC 0D
Rx:073-01 01 02 55 01 47 6C
We copy a message.
For beginners, whether users or developers, it is recommended to find a device and tool that supports Modbus, such as Modbus Poll, to perform communication tests to see what the Modbus message looks like and the reading and writing status.
Because I have encountered some beginners who use a serial port tool to send data to the microcontroller or PLC, but find that the other party does not respond. In addition to setting the serial port parameters correctly, you must ensure that your message is the correct Modbus protocol.
For example, if we read 0X register and read 10, the message is 01 01 00 00 00 0A BC 0D
I guess many people know the previous message 01 01 00 00 00 0A.
Then use a tool or online to calculate CRC. Either the result is wrong, or the result is correct but the message is 01 01 00 00 00 0A 0D BC. The bytes of CRC are reversed.
No matter what I send, PLC just doesn't reply.
This is a common mistake made by many novices and beginners.
So don't underestimate a simple Modbus. It is not an easy task to use it well.
Sometimes, there is a problem when your device communicates with the other device, and you cannot clearly tell whether it is a problem with your device or the other device, which can easily lead to unnecessary misunderstandings and work.
Modbus Poll also provides read and write tests for different function codes.
Previous article:What are the applications of frequency converters in mine hoists?
Next article:What does the Modbus protocol look like? What are the parameters of the Modbus RTU protocol?
- Popular Resources
- Popular amplifiers
- Red Hat announces definitive agreement to acquire Neural Magic
- 5G network speed is faster than 4G, but the perception is poor! Wu Hequan: 6G standard formulation should focus on user needs
- SEMI report: Global silicon wafer shipments increased by 6% in the third quarter of 2024
- OpenAI calls for a "North American Artificial Intelligence Alliance" to compete with China
- OpenAI is rumored to be launching a new intelligent body that can automatically perform tasks for users
- Arm: Focusing on efficient computing platforms, we work together to build a sustainable future
- AMD to cut 4% of its workforce to gain a stronger position in artificial intelligence chips
- NEC receives new supercomputer orders: Intel CPU + AMD accelerator + Nvidia switch
- RW61X: Wi-Fi 6 tri-band device in a secure i.MX RT MCU
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- [Review of SGP40] + Testing the sensor I2C communication with Arduino
- Analysis of the causes of high temperature failure of DCDC power modules
- Near Field Communication (NFC) Transceiver Reference Design
- In electromagnetic field simulation, what are the advantages and disadvantages of FDTD and FEM algorithms?
- Combining 51 code to analyze the programming ideas of RFID card reader
- X-NUCLEO-IKS01A3 sensor driver transplantation based on STM8S-DISCOVERY
- TMDSEVM572X development board link emulator
- [AB32VG1 development board review] OLED screen display driver
- TI TMS320F2812 SVPWM Program
- Android 5.0 BLE low-power Bluetooth slave device application