
The reason why Modbus protocol has become the "standard language" in the industrial field is that it uses a very intuitive way to manage data——Classify data of different properties into four categories“drawer”Inside. No matter which brand the device comes from, As long as you follow this rule, They can communicate smoothly.
core idea: Divide into four regions based on two dimensions
UnderstandingModbusClassification of storage areas, Just like tidying up a wardrobe, You just need to think from two perspectives:
- data type: The data is simple“switch”, It's still a specific one“Number”?
- discrete signal (coil) : There are only two states, black and white. for example, Is the light on or off, Is the valve open or closed. This type of data isModbusIt is called“coil” (Coil) .
- analog quantity (register) : It is a continuously changing numerical value. for example, temperature25.6℃, Stress0.8MPa, Rotation speed1500Turn. This type of data isModbusIt is called“register” (Register) .
- Operation Permissions: This data can only be“Look”, It's still possible“Change”?
- read-only: You can only read its status, But it cannot be modified. likeThe reading on the electricity meter, You can only see how much electricity was used.
- read and write: You can both check its status, It can also be modified. likeVolume keys on mobile phones, You can check the current volume, You can also adjust the major and minor keys.
Combine these two dimensions together, I got itModbusThe four core storage areas, You can quickly grasp it using the table below:
| Storage Area Name (commonly known as) | data type | read-write permissions | You can imagine it as… | Typical application scenarios |
|---|---|---|---|---|
| Coil register(Zone 0) | discrete signal | read and write | light switch | control relay, Motor start stop, Indicator light |
| Discrete input register(Zone 1) | discrete signal | read-only | Door magnetic sensor | Read button status, limit switch, fault signal |
| input register(Zone 3) | analog quantity | read-only | thermometer | Collect temperature, Stress, Flow and other sensor data |
| holding register(Zone 4) | analog quantity | read and write | Adjustable thermostat | Set target speed, temperature, Modify device parameters |
four“Data drawer”Detailed usage of
1. Coil register(Zone 0):Commanding actions“switch”
This is what you useissue ordersThe drawer. main site(e.g. Zone 1):PLCOr computer) By writing data to this area, Directly control the switch of on-site equipment.
- How to use: Do you want to start a motor, Write it to the address of the coil that controls it“1” (ON) ; I want to stop, Just write it in“0” (OFF) .
- like: You use your phone at homeAPPRemote control of smart socket switch.
2. Discrete input register(Zone 3):Perceived state“eyes”
This drawer belongs to the equipmentsense organ, Specially used to reflect external switch state changes.
- How to use: You can only read it. For example, Do you want to know if an emergency stop button has been pressed, Go read the corresponding discrete input address, If the value is“1”, It means the button has been pressed.
- characteristics: Because it is read-only, Can ensure that these critical status signals are not accidentally modified, Very safe.
3. input register(Zone 4):Reporting data“instrument”
This drawer contains items collected from the sitereal-time data, Usually a read-only analog quantity.
- How to use: Main station regularly (For example, once per second) Read this area, To monitor the production process. for example, Continuously reading the address of the temperature sensor in the input register, To obtain real-time temperature values.
- like: The vehicle speed and fuel level displayed on the dashboard, You can only watch, Cannot directly change the vehicle speed through the dashboard.
4. holding register(such asStorage settings“Brain”
This is the device'sConfiguration Center and Brain, Used to store important equipment parameters and setpoints. It allows reading and writing, It is the most feature rich area.
- How to use: You can set a target operating frequency for the frequency converter in the hold register(such as40Hz) , Or the target temperature of a thermostatposition80℃) . Can read the current set value, They can also be modified.
- Advanced Usage: A hold register only16andCannot directly represent complex data such as floating-point numbers. At this moment, Multiple consecutive registers need to be combined together. for example, one32Single precision floating-point numbers typically require two consecutive hold registers to be occupied.
Key Concepts: About the address
Many beginners may confuse“absolute address”and“relative address”, It's actually quite simple:
- absolute address (For people to see) : In order to make it visually appealing for us engineers, Easy to configure. The commonly used ones areShort address model, For example
40001. It represents the fourth storage area (holding register) The first data point.40001(such as400001It's the same address, It's just that the representation method is different.40001It's a simplified version,400001It's the complete version (Long address model) , Can cover the most65536An address, But the vast majority of devices don't use that much, So simplified40001more common.
- relative address (Used for machines) : In realityModbusIn communication messages, In order to save space and improve efficiency, It starts from 0offset address. for example, absolute address
40001The corresponding relative address in the message is0,40002correspond to1.
Simple memory: What you see in the device manual or software configurationthinking40001) It's an absolute address; When transmitting at the bottom layer of the protocol, It will automatically convert it to a relative address. When programming, pay attention to which address the software requires.
Summary
ModbusThrough these four“Data drawer”, Established a clear and easy to understand set of data management rules for industrial equipment:
- districtcontrol switch (If starting the device) → read and write 0thinking (coil)
- districtCheck status (Like a fault signal) → read 1district (Discrete Input)
- districtCollect data (Like monitoring temperature) → read 3district (input register)
- districtSet parameters (If modifying the set value) → read and write 4district (holding register)
Leave a Reply