0% found this document useful (0 votes)
136 views17 pages

DO Modbus Instruction

This document provides information about using MODBUS RTU communication protocols with an optical dissolved oxygen sensor. It describes the MODBUS command structure, including the frame format, function codes, and data formats. Specifically, it outlines the procedures to read and write registers to get dissolved oxygen values from the sensor using MODBUS RTU commands.

Uploaded by

David Bernal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
136 views17 pages

DO Modbus Instruction

This document provides information about using MODBUS RTU communication protocols with an optical dissolved oxygen sensor. It describes the MODBUS command structure, including the frame format, function codes, and data formats. Specifically, it outlines the procedures to read and write registers to get dissolved oxygen values from the sensor using MODBUS RTU commands.

Uploaded by

David Bernal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Optical Dissolved Oxygen

Sensor

MODBUS RTU
Programmer Manuel

1 / 17
Table of Contents
1 MODBUS RTU Overview ...................................................................................................... 3

1.1 Scope ................................................................................................................. 3


1.2 MODBUS Command Structure .......................................................................... 3
1.3 MODBUS RTU for Optical Dissolved Oxygen Sensor ......................................... 5
1.4 MODBUS RTU Function Code for Optical Dissolved Oxygen Sensor ................ 5
1.5 Data formats in optical dissolved oxygen sensor .............................................. 7
2 MODBUS RTU Commands for Optical Dissolved Oxygen Sensor ...................................... 10

2.1 Overview ......................................................................................................... 10


2.2 Command Description..................................................................................... 10
3 Procedure to get DO value ................................................................................................ 16

2 / 17
1 MODBUS RTU Overview

1.1 Scope

This document is about MODBUS of optical dissolved oxygen probes with hardware Rev2.0 and
software Rev6.2 or later. This document is intended for software programmers with detailed
information about MODBUS RTU protocols.

1.2 MODBUS Command Structure

Data format in this document:


----Binary number – shown with suffix B. For example: 10001B
----Decimal number – without nay suffix. For example: 256
----Hexadecimal number—shown with prefix 0x. For example: 0x2A
----ASCII character or string – shown with quotation marks. For example: ” YL0114010022”

1.2.1 Command Structure


MODBUS defines a simple protocol data unit (PDU), which is transparent to communication layer.

Figure 1: MODBUS Protocol Data Unit


The mapping of MODBUS protocol on a specific bus or network introduces some additional fields
on the Protocol Data Unit. The client that initiates a MODBUS transaction builds the MODBUS
PDU, and then adds fields in order to build the appropriate communication PDU.

Figure 2: MODBUS Structure for Serial Communication


On a MODBUS serial bus, address field only includes addresses for slave devices.
Note:
 Slave address range for optical dissolved oxygen sensor is: 1…247
 Master device sends a “request frame” with a targeted slave address. When slave device
responses, it has to put its own address in the “response frame”, so that master device
knows where the response comes from.
 Function code indicates type of operations
 CRC is the result of redundancy check.

3 / 17
1.2.2 MODBUS RTU Transmission Mode
When devices communicate on a MODBUS using RTU (remote terminal unit) mode, each 8-bit
byte contains two 4-bit hexadecimal characters. The main advantage of the RTU mode is that it
has higher character density, which enables better throughput compare to ASCII mode at same
baud rate. Each RTU message must be transmitted in a continuous string of characters.
RTU mode format for each byte (11 bits):
Encoding system 8 bit binary
Each 8-bit packet contains 4-bit hexadecimal characters (0-9, A-F)
Bit per byte: 1 start bit
8 data bits, least significant bit first
No parity check
1stop bits
Baud rate: 9600bps
Serial transmission of characters:
Every character or byte is sent under this sequence (left to right):
Least Significant Bit (LSB)……Most Significant Bit(MSB)
Start 1 2 3 4 5 6 7 8 Stop
Figure 3: RTU Mode Bit Sequence
CRC Field Structure:
Redundancy check (CRC16)
Frame Structure:
Slave address Function Data CRC
Code
2 bytes
1 byte 1 byte 0…252 bytes
CRC Low CRC High
Figure 4: RTU Message Frame Structure
Maximum size of MODBUS frame is 256 bytes.
1.2.3 MODBUS RTU Message Frame
In RTU mode, message frames need to be separated by an idle interval of at least 3.5 character
lengths. In rest of this document, this idle interval is called t3.5.

Figure 5: RTU Message Frame


Entire message frame must be sent as continuous stream of characters.
If idle time between two characters is longer than 1.5 characters, the message frame will be
considered incomplete, and will be discarded by receiving side.
4 / 17
Figure 6: Frame transmission
1.2.4 MODBUS RTU CRC Check
In RTU mode, the error checking field is based on a cyclical redundant checking (CRC) method.
The CRC field checks entire content of MODBUS message, regardless of the existence of parity
check bit. CRC16 checking method is utilized. CRC result is a 16-bit value with two 8-bit bytes, low
order 8-bit byte first followed by high order 8-bit byte.

1.3 MODBUS RTU for Optical Dissolved Oxygen Sensor

Based on standard MODBUS definition, message frame starts with t3.5 idle interval, and similarly,
ends with t3.5 idle interval. Device address and Function code are both 8-bit byte. Data character
string has n*8 bits, it contains information about register start/end address and number of
registers for read/write operation. CRC field is 16 bit in length.
Start Device Function Data CRC End
address code
Value Idle for 3.5 1-247 Comply Comply CRC CRC Idle for 3.5
character with with Low High character
length MODBUS MODBUS length
function data
code format format
Length 3.5 1 1 n 1 1 3.5
(byte)
Figure 7: Message frame structure for MODBUS

1.4 MODBUS RTU Function Code for Optical Dissolved


Oxygen Sensor

Optical dissolved oxygen sensor has two MODBUS function codes:


0x03: Read registers 0x10: Write registers
1.4.1 MODBUS Function Code 0x03: Read Registers
This function code is to read a block of continuous registers from a remote device. Request PDU
defines start address and number of registers for the read operation. Register addressing starts
from 0. Therefore, addresses for register 1-16 are 0-15. Data for each register in Response
message have two bytes. For each register data, first byte is for high bits, and second byte for low
bits.
Request Frame:
Function code 1 Byte 0x03
5 / 17
Start address 2 Bytes 0x0000….0xfffff
Number of registers 2 Bytes 1…125
Figure 8: Request frame for read registers
Response Frame:
Function code 1 byte 0x03
Number of byte 1 byte N×2
Register data N×2 bytes
N = number of registers
Figure 9: Response frame for read registers
Below is an example of Request and Response frames (Read register 108-110. Register 108 is read
only with 2-byte value of 0X022B. Registers 109-110 have values of 0X0000 and 0X0064).
Request Frame Response Frame
Data format Hexadecimal Data Format Hexadecimal
Function code 0x03 Function code 0x03
Start address(high bits) 0x00 Number of bytes 0x06
Start address (low bits) 0x6B Register value (high bits, 108) 0x02
Number of registers (high bits) 0x00 Register value (low bits, 108) 0x2B
Number of registers (low bits) 0x03 Register value (high bits, 109) 0x00
Register value (low bits, 109) 0x00
Register value (high bits, 110) 0x00
Register value (low bits, 110) 0x64
Figure 10: Example of request and response frame for read operation
1.4.2 MODBUS Function Code 0x10: Write Registers
This function code is to write a block of continuous registers at a remote device. Request frame
contains register data. Each register data have two character bytes. Response frame contains
function code, start address, and number of registers that completed write operation.
Request Frame:
Function code 1 byte 0x10
Start address 2 bytes 0x0000….0xffff
Number of registers 2 bytes 0x0001….0x0078
Number of bytes 1 byte N×2
Register data N×2 bytes value
N = number of registers
Figure 11: Request frame for write operation
Response Frame
Function Code 1 byte 0x10
Start address 2 bytes 0x0000….0xffff
Number of registers 2 bytes 1…123(0x7B)
Figure 12: Response frame for write operation
Below is an example of Request frame and Response frame (write 0x000A and 0x0102 to two
registers starting from address 2):
Request Frame Response Frame
Data Format Hexadecimal Data Format Hexadecimal
6 / 17
Function code 0x10 Function code 0x10
Start address (high bits) 0x00 Start address (high bits) 0x00
Start address (low bits) 0x01 Start address (low bits) 0x01
Number of registers (high bits) 0x00 Number of registers (high bits) 0x00
Number of registers (low bits) 0x02 Number of registers (low bits) 0x02
Number of bytes 0x04
Register value (high bits) 0x00
Register value (low bits) 0x0A
Register value (high bits) 0x01
Register value (low bits) 0x02
Figure 13: Example of Request frame and response frame for write operation

1.5 Data formats in optical dissolved oxygen sensor

1.5.1 Floating-point number


Definition: floating point number, comply with IEEE754 (single precision)
Note Sign Exponent Fraction Total
bit 31 30…23 22…0 32
Exponent deviation 127
Figure 14: Single floating point number definition (4 bytes, 2 MODBIS registers)

Example: Convert decimal number 17.625 to binary number


Step 1: Convert decimal number 17.625 to a floating point number with binary format
First, convert integer to binary
17decimal = 16 + 1 = 1×24 + 0×23 + 0×22 + 0×21 + 1×20
Thus, integer 17 in binary format is 10001B
Then convert decimal part to binary
0.625decimal = 0.5 + 0.125 = 1×2-1 + 0×2-2 + 1×2-3
Thus, 0.625 in binary format is 0.101B
Combine above together, 17.625 in binary format is 10001.010B
Step 2: Calculate exponent
Left shift the binary number 10001.010B until only bit left before the decimal point ---
10001.101B = 1.0001101 B× 24, so exponent value is 4. By adding 127, we have 131, which
is 10000011B in binary format
Step 3: Get fraction
Fraction is simply the number after decimal point. Thus from 1.0001101B, fraction
number is 0001101B. IMPORTANT NOTE about the 23 bit fraction number: the first bit
which on the left side of decimal point is hidden bit and does not need to be compiled.
Step 4: Sign definition
Sign bit is 0 if the number is positive. Sign is 1 if the number is negative. For 17.625, sign
bit is 0.
Step 5: Convert to floating point number
1 Sign bit + 8-bit exponent + 23-bit fraction
7 / 17
0 10000011 00011010000000000000000B
(Corresponding hexadecimal number is 0x418D0000)

Sample code:
1. If your compiler has similar library functions, it can be called directly. For example if C
language is used, we can directly call memcpy() function in C library to convert floating point
number. Sample code:
float floatdata;//floating point data to be converted
void* outdata;
memcpy(outdata,&floatdata,4);

If floatdata=17.625,
In little-endian storage mode after the function is called:
Value at address of outdata is 0x00
Value at address of (outdata+1) is 0x00
Value at address of (outdata+2) is 0x8D
Value at address of (outdata+3) is 0x41
In big-endian storage mode after the function is called:
Value at address of outdata is 0x41
Value at address of (outdata+1) is 0x8D
Value at address of (outdata+2) is 0x00
Value at address of (outdata+3) is 0x00

2. If your complier doesn’t have the conversion function, then the following function can be
used:
void memcpy(void *dest,void *src,int n)
{
char *pd = (char *)dest;
char *ps = (char *)src;
for(int i=0;i<n;i++) *pd++ = *ps++;
}
Then you can get same result by calling this function memcpy(outdata,&floatdata,4);

Example: Convert binary floating point number 0100 0010 0111 1011 0110 0110 0110 0110B to a
decimal number
Step 1: Separate this binary number 0100 0010 0111 1011 0110 0110 0110 0110B and get values
of Sign , exponent and fraction.
0 10000100 11110110110011001100110B
1 Sign bit 8-bit exponent 23-bit fraction

Sign bit(s): 0
Exponent(E):10000100B=1×27+0×26+0×25+0×24+0×23+1×22+0×21+0×20
=128+0+0+0+0+4+0+0=132
Fraction(M):11110110110011001100110B =8087142
Step 2: Calculate decimal value
8 / 17
D = (-1)S×(1.0+M/223)×2E-127
= (-1)0×(1.0+8087142/223)×2132-127
= 1×1.964062452316284×32
= 62.85

Reference code:
float floatTOdecimal(long int byte0, long int byte1, long int byte2, long int byte3)
{
long int realbyte0,realbyte1,realbyte2,realbyte3;
char S;
long int E,M;
float D;
realbyte0 = byte3;
realbyte1 = byte2;
realbyte2 = byte1;
realbyte3 = byte0;

if((realbyte0&0x80)==0)
{
S = 0; //Positive
}
else
{
S = 1; //Negative
}
E = ((realbyte0<<1)|(realbyte1&0x80)>>7)-127;
M = ((realbyte1&0x7f) << 16) | (realbyte2<< 8)| realbyte3;
D = pow(-1,S)*(1.0 + M/pow(2,23))* pow(2,E);
return D;
}
Note:
 Function parameters byte0, byte1, byte2 and byte3 represent the 4 sections of a binary
floating number.
 Return value is value of decimal number after conversion

For example when a command is sent to a sensor to get temperature value, response frame from
the sensor will have measured temperature. If the values are 4 byte floating point number
0x00,0x00,0x8d,0x41, then the following function can be used to get temperature in decimal
value:
float temperature = floatTOdecimal( 0x00, 0x00, 0x8d, 0x41);
and temperature = 17.625.
1.5.2 Characters
Definition: Character is shown by ASCII code.
Example: String “YL” could be shown by corresponding ASCII codes (refer to ASCII character chart)

9 / 17
“Y” is 0x59
“L” is 0x4C

2 MODBUS RTU Commands for Optical


Dissolved Oxygen Sensor

2.1 Overview

In order to communicate with optical dissolved oxygen via MODBUS RTU, master terminal
software will be needed. MODBUS RTU is an open standard. There are free commercial software
tools available. For applications described in this document, MODBUS register address starts from
1. However, slave address in MODBUS protocol starts from 0, and usually master software
compiles addresses. For example, register address 2090 will be compiled by master software as
address 2089.

2.2 Command Description

2.2.1 Set Slave Device ID


Purpose: Set MODBUS slave address to a sensor probe. Range of address is 1~247.
Sensor probe slave address can be set via MODBUS register 0x3000:
Start address Number of registers Register 1 MODBUS Function code
0x3000 0x01 New Slave address 0x10
Figure 15: Set slave ID command
Below is an example of request and response frames for setting slave device ID command. Old
slave address is 0x01, new address is 0x14.
Definition Address Function Start address Number of Number Register CRC
code registers of byte value
Byte 0 1 2 3 4 5 6 7 8 9 10
Value 0x01 0x10 0x30 0x00 0x00 0x01 0x02 0x14 0x00 0x99 0x53
Figure 16: Example of Request frame to set slave ID *Note: byte 8 is reserved
Definition Address Function Start address Number of CRC
code registers
Byte 0 1 2 3 4 5 6 7
Value 0x01 0x10 0x30 0x00 0x00 0x01 0x0E 0xC9
Figure 17: Example of response frame for Set slave ID command

2.2.2 Get SN
Purpose: Get sensor probe’s serial number (SN). Each sensor probe has a unique SN.
Serial Number can be read from 7 continuous MODBUS registers starting from address 0x0900
10 / 17
Start Address Number of registers Register 1-7 MODBUS Function code
0x0900 0x07 SN 0x03
Figure 18: Register definition for Get SN command
Below is an example of request and response frames to get SN “YL0114010022” from a slave
device (address 0x01)
Definition Address Function Starting address Number of CRC
code registers
Byte 0 1 2 3 4 5 6 7
Value 0x01 0x03 0x09 0x00 0x00 0x07 0x07 0x94
Figure 19: Request frame to get SN
Definition Address Function Number of Register value CRC
code byte
Byte 0 1 2 4-15 3 16 17 18
Value 0x01 0x03 0x0E 0x00 “YL0114010022” 0x00 0x19 0x66
Figure 20: Response frame sample for Get SN command
Note: SN value is in ASCII code as below:
Byte 4 5 6 7 8 9 10 11 12 13 14 15
Value 0x59 0x4C 0x30 0x31 0x31 0x34 0x30 0x31 0x30 0x30 0x32 0x32
Figure 21: Sensor probe’s SN

2.2.3 Start Measurement


Purpose:Set probe in continuous light emitting mode and start measuring dissolved oxygen.
MODBUS register 0x2500 is used. The Probe starts in auto-measure mode by default.
Starting address Number of registers MODBUS Function code
0x2500 0x01 0x03
Figure 22: Start measurement command definition
Below is an example of request and response frames for sending a Start Measurement command
to a device with slave address 0x01.
Definition Device Function Start address Number of CRC
address code registers
Byte 0 1 2 3 4 5 6 7
Value 0x01 0x03 0x25 0x00 0x00 0x01 0x8F 0x06
Figure 23: Request frame of a start measurement comment
Definition Device Function Number of Register value CRC
address code bytes
Byte 0 1 2 3~4 5 6
Value 0x01 0x03 0x00 meaningless
Figure 24: Response frame of a start measurement command

2.2.4 Get Temperature and DO values


Purpose:Get temperature and DO measurement results. Temperature unit is Celsius degree (C),
DO unit is percentage (%). User calibration process is automatically applied to DO value.
11 / 17
Temperature and DO data can be read from 4 continuous MODBUS registers starting from
address 0x2600.
Start address Number of Register 1-2 Register 3-4 MODBUS
registers function code
0x2600 0x04 Temperature DO value 0x03
Figure 25: Register definition for Get temperature and DO command
Below is an example of request and response frames for getting temperature and DO command,
assuming slave device address is 0x01, returned temperature is 17.625C and DO value is 17.625.
Definition Device Function Start address Number of CRC
address code registers
Byte 0 1 2 3 4 5 6 7
Value 0x01 0x03 0x26 0x00 0x00 0x04 0x4F 0x41
Figure 26: Request frame for Get Temperature and DO command
Definition Device Function Number of Register value CRC
address code bytes
Byte 0 1 2 3-6 7-10 11 12
Value 0x01 0x03 0x08 17.625 17.625 0x12 0x65
Figure 27: Response frame for Get Temperature and DO command
Note: Temperature and DO values are floating point number in little-endian storage mode. See sample below:
Temperature(3-6) DO value(7-10)
0x00 0x00 0x8D 0x41 0x00 0x00 0x8D 0x41
Figure 28: Registers for temperature and DO values.

2.2.5 Get Software and Hardware Rev


Purpose: Get current hardware and software Release Version.
Hardware and software release version numbers of a sensor probe can be read from 2 continuous
registers starting from address 0x0700.
Start address Number Register 1 Register 2 MODBUS function
registers code
0x0700 0x02 HW Rev SW Rev 0x03
Figure 29: Register definitions for Get software and hardware Rev command
Below is an example of request and response frames for getting hardware and software release
version, assuming device slave address is 0x01, returned value for hardware Rev is 2.0 and
software Rev is 5.7.
Definition Device Function Start address Number of CRC
address code registers
Byte 0 1 2 3 4 5 6 7
Value 0x01 0x03 0x07 0x00 0x00 0x02 0xc5 0x7f
Figure 30: Request frame of Get Hardware and Software Rev command

Definition Device Function Number Register value CRC


address code of bytes

12 / 17
Byte 0 1 2 3-4 5-6 7 8
Value 0x01 0x03 0x04 0x02 0x00 0x05 0x07 0xb9 0x19
Figure 31: Response frame of Get Hardware and Software Rev Command

2.2.6 Stop Measurement


Purpose:After stable test result is obtained, stop measurement activities. If measurement need
to start again , use command Start Measurement.
MODBUS register 0x2E00 is used for this command.
Start address Number of registers MODBUS function code
0x2E00 0x01 0x03
Figure 32: Register definition for Stop measurement command
Below is an example of request and response frames for a device with slave address 0x01 to stop
measurement activities.
Definition Device Function Start address Number of CRC
address code registers
Byte 0 1 2 3 4 5 6 7
Value 0x01 0x03 0x2E 0x00 0x00 0x01 0x8D 0x22
Figure 33: Request frame of stop measurement command
Definition Device Function Number of Register value CRC
address code bytes
Byte 0 1 2 3~4 5 6
Value 0x01 0x03 0x00 meaningless
Figure 34: Response frame of stop measurement command

2.2.7 Get User Calibration Coefficients


Purpose: Get two calibration coefficients K and B. (This is to eliminate measurement errors
caused by aging or other reasons. User calibration equation is: DOfinal=K*DO +B; default values
are: K=1; B=0)
User calibration coefficients (K and B) can be read from 4 continuous MODBUS registers starting
from address 0x1100.
Start address Number of Register 1-2 Register 3-4 MODBUS function
registers code
0x1100 0x04 K value B value 0x03
Figure 35: Register definition for Get User calibration coefficients command
Below is an example of request and response frames for getting customer calibration coefficients
from a device with slave address 0x01, assuming returned values are: K=1.0; B=0.0.
Definition Device Function Start address Number of registers CRC
address code
Byte 0 1 2 3 4 5 6 7
Value 0x01 0x03 0x11 0x00 0x00 0x04 0x41 0x35
Figure 36: Request frame of Get customer calibration coefficient command

Definition Device Function Number Register CRC


address code of bytes value
13 / 17
Byte 0 1 2 3-6 7-10 11 12
Value 0x01 0x03 0x08 1.0 0.0 0x9E 0x12
Figure 37: Response frame of get customer calibration coefficient command
Note: K and B are floating point numbers in little-endian storage mode
K(3-6) B(7-10)
0x00 0x00 0x80 0x3F 0x00 0x00 0x00 0x00
Figure 38: Registers for two coefficients K and B.

2.2.8 Set Customer Calibration Coefficients


Purpose: Set two calibration coefficients K and B.
Customer coefficients (K and B) can be set at 4 continuous MODBUS registers starting from
address 0x1100.
Start address Number of Register 1-2 Register 3-4 MODBUS function
registers code
0x1100 0x04 K B 0x10
Figure 39: Register definition for set customer calibration command
Below is an example of request and response frames for setting customer calibration coefficients,
Assuming slave address is 0x01, coefficients are K=1.0; and B=0.0.
Definition Device Function Start address Number of Number Register value CRC
address code registers of bytes
Byte 0 1 2 3 4 5 6 7-10 11-14 15 16
Value 0x01 0x10 0x11 0x00 0x00 0x04 0x08 1.0 0.0 0x81 0xAE
Figure 40: Request frame of set customer calibration coefficient command
Note: Coefficients K and B, floating point numbers in little-endian storage mode
K(7-10) B(11-14)
0x00 0x00 0x80 0x3F 0x00 0x00 0x00 0x00
Figure 41: Registers for two coefficients K and B

Definition Device Function Start Number of CRC


address code address registers
Byte 0 1 2 3 4 5 6 7
Value 0x01 0x10 0x11 0x00 0x00 0x04 0Xc4 0xf6
Figure 42: Response frame of set customer calibration coefficient command

2.2.9 Set Optical Sensor Cap Coefficients


Purpose:Set sensor cap coefficients (K0~K7), this is necessary step to replace sensor caps.
Sensor cap coefficients can be set at 16 continuous MODBUS registers starting from address
0x2700.
Start address Number of registers Register 1-16 MODBUS function code
0x2700 0x10 K0- K7 0x10
Figure 43: Request frame of set sensor cap coefficient command

Below is an example of request and response frames for setting sensor cap coefficients to a
device with slave address 0x01.
14 / 17
Definition Device Function Start Number of Number Register CRC
address code address registers of bytes value
Byte 0 1 2 3 4 5 6 7-38 39 40
Value 0x01 0x10 0x27 0x00 0x00 0x10 0x20 K0-K7 XX XX
Figure 44: Request frame of set sensor cap coefficient command
Note: Ki(i=0-7) sensor cap coefficients, floating point number in little-endian storage mode
Definition Device Function Start address Number of CRC
address code registers
Byte 0 1 2 3 4 5 6 7
Value 0x01 0x10 0x27 0x00 0x00 0x10 0xcb 0x71
Figure 45: Response frame of set sensor cap coefficient command

2.2.10 Get Slave Device ID


Purpose: Get current MODBUS slave address to a sensor probe. Use 0xFF as fixed Device address.
Sensor probe slave address can be read from MODBUS registers 0x3000.
Start address Number of registers Register 1 MODBUS Function code
0x3000 0x01 Current Slave address 0x10
Figure 46: Get slave ID command
Below is an example of request and response frames for getting slave device id, assuming
returned address is 0x03.
Definition Device Function Start address Number of CRC
address code registers
Byte 0 1 2 3 4 5 6 7
Value 0xFF 0x03 0x30 0x00 0x00 0x01 0x9E 0xD4
Figure 47: Request frame of get slave device ID comment
Definition Device Function Number of Register value CRC
address code bytes
Byte 0 1 2 3 4 5 6
Value 0xFF 0x03 0x02 0x03 0x00(reserve) 0x91 0x60
Figure 48: Response frame of get slave device ID comment

15 / 17
3 Procedure to get DO value

Procedures Command

Power On

Delay>=4s

Y
Get Temperature and DO Get temperature
and DO values

More than 10 times? N


Delay 1s

Y
Calculate DO(mg/L)

Figure 46:Flow chart to get DO measurement

 Get temperature and DO values – Get measurement results including temperature (C)
and DO (%) after 1 second of measurements.
Note: Please pay attention to highlighted portion (red) in the flow chart above. It’s highly
recommended that customers get an average DO results (%) after 10 consecutive
measurements, then convert the average DO percentage to a DO value in mg/L unit.
 Calculate DO(mg/L), converting the average DO percentage to a DO value in mg/L unit.
According to the formula: DO(mg/L)=DO(%)*X1*X2*1.4276;
1 ml/L = 1.4276 mg/L;
lnX1= Al + A2 100/T + A3 ln T/100 + A4 T/100 + S* [B1 + B2 T/100 + B3 (T/100)^2];
Al = -173.4292, B1 = - 0.033096,
A2 = 249.6339, B2 = 0.014259,
A3 = 143.3483, B3 = - 0.001700;
A4 = -21.8492;
T =273.15 + t ,T represent for Kelvin temperature and t represent for Celsius
temperature;
S is salinity, S=0 in pure water;
X2= (Phmg - u) / (760 - u);

16 / 17
Phmg= pressure * 760 / 101.325, pressure is the barometer in kPa unit;
Logu= 8.10765 - (1750.286/ (235+t)), t represent for Celsius temperature.

Reference code:
#include <math.h>

float pressure = 0.0;


float Phmg= 0.0;
float t = 0.0;
float T = 0.0;
float S = 0.0;

T = 273.15 + t; //t is current temperature which get from probe


X1’ = -173.4292 // X1’ = ln X1
+ 249.6339*(100/ T)
+ 143.3483*log(T /100) //Function log() is equal to ln(x)
+ -21.8492*( T /100)
+S*(-0.033096 + (0.014259* T)/100
-0.001700*( T /100)*( T /100));
X1 = exp(X1’);

// log u = 8.10765 - (1750.286/ (235+t))


u’ = 8.10765 - (1750.286/ (235 + t));// u’ = log u
u = pow(10, u’); //u=10^u ’

Phmg = pressure*760/101.325;
X2 = ((Phmg - u)/(760 - u));
DO(mg/L)= DO(%)*X1*X2*1.4276;

17 / 17

You might also like