beautypg.com

Appendices, Modbus, Modbus® commands – Kipp&Zonen SMP3 Pyranometers User Manual

Page 45: Input registers

background image

.

Register 4

IO_SCALE_FACTOR

The scale factor defines the number of fractional digits, the range and the position of the decimal point for the following
registers:

IO_SENSOR1_DATA, IO_SENSOR2_DATA, IO_RAW_SENSOR1_DATA and IO_RAW_SENSOR2_DATA. The scale factor is read

only. The default value of the scale factor is set during calibration mode or it can be changed during operation (see register
IO_DEF_SCALE_FACTOR and coil IO_AUTO_RANGE).

If the register

IO_SCALE_FACTOR is not set to 0 then you must multiply or divide the data of register (X), whereas X is one of the

above mentioned registers.

Scale factor = 2

(floating point) result = (integer) register (X) / 100.0

Scale factor = 1

(floating point) result = (integer) register(X) / 10.0

Scale factor = 0

(floating point) result = (integer) register(X)

Scale factor = -1

(floating point) result = (integer) register(X) * 10.0

The default value of register

IO_SCALE_FACTOR is 0. However, this value can be set to a different value if the coil IO_AU-

TO_RANGE is set or a different value is written to the register IO_DEF_SCALE_FACTOR (set default scale factor).

Register 5

IO_SENSOR1_DATA

This register holds the actual data (solar radiation) measured by the sensor. The solar radiation is measured in W/m².

If the register

IO_SCALE_FACTOR is not set to 0 then you must multiply or divide the data as described under register 4.

The raw data from the sensor is calibrated, linearized; temperature compensated and filtered using 2 different kinds of filters
(See

IO_FAST_RESPONSE and IO_TRACKING_FILTER).

Register 6

IO_RAW_SENSOR1_DATA

The raw sensor data is calibrated but not linearized and temperature compensated. If the register

IO_SCALE_FACTOR is not set

to 0 then you must multiply or divide the data as described under register 4,

IO_SCALE_FACTOR.

Register 7

IO_STDEV_SENSOR1

This register is used to calculate the standard deviation over the signal. When the register is read the data is sent to the comput-
er and at the same time a new calculation is started. The next time register 7 is read the standard deviation over the last period
is sent to the computer and a new calculation is started. If the poll frequency is quite high (for example 1 poll per second) then
the standard deviation will be zero or almost zero, but if the poll frequency is very low then the standard deviation can be quite
high, indicating that the data in register 5 or 6 changed dramatically since the last poll. The standard deviation is measured in
0.1 W/m². To convert the data to a floating point, make the following calculation:

(floating point) result = (integer) register (IO_STDEV_SENSOR1) / 10.0

Register 8

IO_BODY_TEMPERATURE

The body temperature sensor measures the temperature of the body in 0.1°C.

The convert the data to a floating point number, make the following calculation:

(floating point) result = (integer) register (IO_BODY_TEMPERATURE) / 10.0

A. Modbus®
A.1 Modbus® commands

The commands are all according to the Modbus RTU protocols described in the document: ‘Modbus® over serial line V1.02’ and
‘MODBUS application protocol V1.1b’ available from the Modbus® organization (www.modbus.org). The commands can be tested
using software tools, such as the program ‘Modbus Poll’ from www.modbustools.com.

The following commands are implemented:

Function

Sub function

Description

0x01

N/A

Read Coils

0x02

N/A

Read Discrete Inputs

0x03

N/A

Read Holding Registers

0x04

N/A

Read Input Register

0x05

N/A

Write Single Coil

0x06

N/A

Write Holding Register

0x10

N/A

Write multiple Registers

The SMP does not make a difference between a ‘coil’ and a discrete input. The only difference is that a discrete input is read only.

The SMP does not make a difference between a holding register and an input register. The only difference is that an input
register is read only.

A.2 Input registers

Input registers are read only

Appendices

Real-time Processed Data

Register Parameter

R/W Type Mode Description

0

IO_DEVICE_TYPE

R

U16

All

Device type of the sensor

1

IO_DATAMODEL_VERSION

R

U16

All

Version of the object data model 100=this version

2

IO_OPERATIONAL_MODE

R

U16

All

Operational mode: Normal, Service, Calibration and so on

3

IO_STATUS_FLAGS

R

U16

All

Device status flags

4

IO_SCALE_FACTOR

R

S16

All

Range and scale factor sensor data

(1)

5

IO_SENSOR1_DATA

R

S16

N,S

Temperature compensated data sensor 1 in W/m²

6

IO_RAW_SENSOR1_DATA

R

S16

N,S

Sensor data sensor 1 in W/m²

7

IO_STDEV_SENSOR1

R

S16

N,S

Standard deviation sensor 1 in 0.1 W/m²

8

IO_BODY_TEMPERATURE

R

S16

N,S

Body temperature in 0.1 °C

9

IO_EXT_POWER_SENSOR

R

S16

N,S

External power voltage in 0.1 V

10 to 15 FACTORY USE ONLY

16

IO_DAC_OUTPUT_VOLTAGE

R

U16

N,S

DAC output voltage (actual voltage)

17

IO_SELECTED_DAC_INPUT

R

U16

N,S

DAC selected input data

(1)

The scale factor defines the format and number of decimal places

.

Register 9

IO_EXT_POWER_SENSOR

The Ext power sensor measured the external voltage applied to the sensor in 0.1 Volt.

The convert the data to a floating point number, make the following calculation:

(floating point) result = (integer) register (IO_EXT_POWER_SENSOR) / 10.0

Example
Read registers: ‘operational mode to external power’ from Modbus® device with address 1.

Tx

transmitted data to the smart sensor

Rx

received data from the smart sensor

SendModbusRequest (0x04, 1, IO_OPERATIONAL_MODE, 8);
Tx 01 04 00 02 00 08 50 0C
Rx 01 04 10 00 01 00 00 00 00 03 E5 03 E5 00 00 00 F8 00 EA 66 12

Explanation of the received bytes:
01

= MODBUS address

04

= read input registers

10

= number of received data bytes

00 01

= operational mode (mode 1)

00 00

= status flags (none)

00 00 = scale factor = 0 = 1x
03 E5

= 997 decimal = sensor 1 data in W/m²

03 E5

= 997 decimal = raw sensor 1 data in W/m²

00 00

= 0 = standard deviation sensor 1

00 F8

= 248 = 24.8°C.

00 EA

= 234 = 23.4 Volt

66 12

= MODBUS checksum (CRC16)

.

A.5 Discrete inputs

A discrete input can be true or false. A discrete input is read only; a coil can be read or written.

Status indicators

Input Parameter

R/W Def. Mode Description

0

IO_FALSE

R

0

All

Always false (for testing only)

1

IO_TRUE

R

1

All

Always true (for testing only)

2

IO_VOID_DATA_FLAG

R

*

All

Void signal, 1=unstable signal, temperature too low or too high

3

IO_OVERFLOW_ERROR

R

*

All

Overflow, signal out of range

4

IO_UNDEFLOW_ERROR

R

*

All

Underflow signal out of range

5

IO_ERROR_FLAG

R

*

All

General hardware error (set if one of the H/W error flags is set)

6

IO_ADC_ERROR

R

*

All

Hardware error A/D converter

7

IO_DAC_ERROR

R

*

All

Hardware error D/A converter

8

IO_CALIBRATION_ERROR

R

*

All

Calibration checksum error

9

IO_UPDATE_FAILED

R

*

All

Update calibration parameters failed

Legend

Input

Discrete input

Modbus® discrete input 0 is the first discrete input

Coil

Modbus Coil

A coil can be read or written.

Parameter Name

Name of the register

R/W

Read write

R

Read only

R/W Read/write

Def

Default value

default value at power on (0, 1or *) * = undefined

Mode

operation mode

N

available in normal mode

S

available in service mode

C

available in calibration mode (not for users)

F

available in factory mode (not for users)

All

available in all modes

Inputs can be read in all modes but some coils can’t be written in normal mode or service mode.

A.6 Coils

Device control

Coil

Parameter

R/W Def. Mode Description

10

IO_CLEAR_ERROR

R/W 0

All

Select normal operation and clear error (1=clear error)

11 to 17 FACTORY USE ONLY

18

IO_RESTART_MODBUS

R/W 0

All

Restart the device with modbus® protocol

19

FACTORY USE ONLY

20

IO_ROUNDOFF

R/W 1

S,N

Enable rounding of sensor data

21

IO_AUTO_RANGE

R/W 0

S,N

Enable auto range mode (0=no auto range)

22

IO_FASTRESPONSE

R/W 0

S,N

Enable fast response filter (0=no filter)

23

IO_TRACKING_FILTER

R/W 1

S,N

Enable tracking filter (0=no filter)

Note

The default values of the device options are stored in non-volatile memory. The default values can be overruled during

operation. However, at power-on the default values are restored and the smart sensor will start up with the default

values stored in the non-volatile memory.

.

ADC CONTROL

Coil

Parameter

R/W Def. Mode Description

24 to 34 Factory use only

A.7 Read write holding registers

Register 34

IO_DEF_SCALE_FACTOR

The default scale factor is set in the factory mode or service mode and is stored in non-volatile memory. The default scale factor
stored in non-volatile memory is always set after a power-on. However it is possible to change the default setting during opera-
tion by writing a value to the register 34.

Note

This value is not stored in non-volatile memory and is overwritten with the default value at power on.

The following values are valid:
Scale factor = 2
Scale factor = 1
Scale factor = 0

Scale factor = -1
Scale factor 0 is the default value. See also input register 4

IO_SCALE_FACTOR.

A.8 Read discrete inputs

Discrete input 0 IO_FALSE

This discrete input is always false

Discrete input 1 IO_TRUE

This discrete input is always true

Discrete input 2 IO_VOID_DATA_FLAG
The void data flag is raised when the data in register

IO_SENSOR1_DATA or IO_RAW_SENSOR1_DATA is not valid, because the

body temperature of the sensor is too low or too high, when there is an internal overflow condition, because a calculation is out
of range or a division by zero occurred, the reference voltage of the ADC is not stable or the digital filter is not stable. When the
IO_VOID_DATA_FLAG is set, bit 0 in the IO_STATUS_FLAGS is also set.

The

IO_VOID_DATA_FLAG and bit 0 of the IO_STATUS_FLAGS are cleared when the IO_VOID_DATA_FLAG is read by the computer.

Discrete input 3 IO_OVERFLOW_ERROR
This discrete input is raised when an out of range condition occurs and the sensor data (see

IO_SENSOR1_DATA) is above the

maximum value specified by the calibration program or above 29,999. The typical maximum value is 4000 W/m².

When the

IO_OVERFLOW_ERROR is set, bit 1 in the IO_STATUS_FLAGS is also set.

The

IO_OVERFLOW_ERROR and bit 1 of the IO_STATUS_FLAGS are cleared when the IO_OVERFLOW_ERROR is read by the computer.

Discrete input 4 IO_UNDERFLOW_ERROR
This discrete input is raised when an underflow condition occurs and the sensor data (see

IO_SENSOR1_DATA) is below the

minimum value specified by the calibration program or below -29,999. The typical minimum value is -400 W/m².

When the

IO_UNDERFLOW_ERROR is set, bit 2 in the IO_STATUS_FLAGS is also set.

The

IO_UNDERFLOW_ERROR and bit 2 of the IO_STATUS_FLAGS are cleared when the IO_UNDERFLOW_ERROR is read by the

computer.

.

Discrete input 5 IO_ERROR_FLAG
The error flag is raised when there is a (fatal or correctable) hardware error or software error such as: ADC error, DAC error,
calibration error or when the update of the calibration data failed. When the

IO_ERROR_FLAG is raised the error code is copied

to the register

IO_ERROR_CODE (see register 26).

The error flag is cleared when a true condition is written to the coil:

‘IO_CLEAR_ERROR’. This has no effect when the error is fatal

or not resolvable such as a calibration error.

The error flag is always set after a power up, this is to indicate the power went off, or a restart occurred. The computer should
raise the

IO_CLEAR_ERROR in order to reset the error flag.

Discrete input 6 IO_ADC_ERROR
This flag is raised when the A/D converter responsible for the conversion of the analogue signals to digital signals detected a
failure (hard or software).

The ADC error flag is cleared when a true condition is written to the coil:

‘IO_CLEAR_ERROR’ and the error produced by the ADC,

is not fatal.

Discrete input 7 IO_DAC_ERROR
This flag is raised when the D/A converter responsible for the conversion of the digital signal to the analogue output signal
detected a failure (hard or software).

The DAC error flag is cleared when a true condition is written to the coil:

‘IO_CLEAR_ERROR’ and the error produced by the DAC,

is not fatal.

Discrete input 8 IO_CALIBRATION_ERROR
The calibration error flag is raised when the sensor was not calibrated or a checksum error was detected in the calibration data.
This flag can’t be cleared unless the sensor is sent back to the manufacturer or dealer for a re-calibration.

Discrete input 9 IO_UPDATE_FAILED
The update failed is raised when data is written to the non-volatile memory and the update failed. This can happen in calibration
mode when calibration data in written to non-volatile memory or in the service mode when device options are written to the
non-volatile memory.

If this error is set you should retry the last update action. If the error does not disappear then there could be a hardware
problem with the non-volatile memory (EEPROM).

A.9 Read write discrete coils

Coil 10

IO_CLEAR_ERROR

Setting this coil will clear the error only when the error is a non-fatal error. Reading this coil will always return a 0. The coil
IO_CLEAR_ERROR can be used to select the normal mode (see IO_OPERATIONAL_MODE).

The smart sensors will always start-up in the normal mode.

Note

Use

IO_CLEAR_ERROR to return to the normal mode.

.

Coil 20

IO_ROUNDOFF

Setting this coil enables rounding of the data presented in

IO_SENSOR1_DATA and IO_RAW_SENSOR1_DATA.

If not set then the customer should round off the received data before processing the data.

The default value after power on is ON.

If

IO_ROUNDOFF is cleared, then the sensor is not calibrated and could produce more digits, than there are significant digits.

Coil 21

IO_AUTO_RANGE

Setting this coil enables the auto-range feature. The auto-range feature increases the number of digits for small signals

The default value after power on is OFF.

If

IO_AUTO_RANGE is set then the sensor is not calibrated and could produce more digits, than there are significant digits.

Coil 22

IO_FASTRESPONSE

Setting this coil enables the fast response filter. This filter increases the step response of the sensor. Disabling the fast response
give the SMP pyranometers the same response time as the CMP equivalents.

The default value after power on is ON.

Coil 23

IO_TRACKING_FILTER

Setting to this coil enables the tracking filter. The tracking filter reduces the noise of the signal. However, when the filter is on,
the step response on a sudden signal change is decreased. The smart sensor uses variable filter constants to minimize the effect
on the step response.

The default value after power on is OFF.

A.10 Requesting serial number

Register 41

IO_BATCH_NUMBER

The batch number defines the production year of the smart sensor, 11 = 2011, 12=2012 etc.

Register 42

IO_SERIAL_NUMBER

Register 42 defines the 4 digits serial number of the smart sensor. Only the combination of the batch number and serial number
is unique.

A.11 Simple demonstration program

The simple ‘C’ program below will show how to read the sensor data and how to deal with errors. The program will read the
registers: ‘operational mode, status flags, scale factor, and sensor data’ from Modbus® device with address 2 into registers
uOperationMode, uStatusFlags, iScaleFactor and iSensorData. Then the program will check the operation mode (must be
‘normal’) and if there are no errors flags set in iStatusFlags. If there is an error then set the

IO_ERROR_FLAG.

.

UInt16

uOperationalMode = 0;

UInt16

uStatusFlags = 0;

Int16

iScaleFactor = 0;

Int16

iSensorData = 0;

float

fSensorData = 0;

int main (void)
{

while (true)

{

// Send MODBUS request 0x04 Read input registers to slave 2

// Get modus data will wait for the answer and copies the data to registers

// uOperationalMode, uStatusFlags, iScaleFactor and iSensorData

SendModbusRequest (0x04, 2, IO_OPERATIONAL_MODE, 4);

WaitModbusReply ();

GetModbusData ();

If (uOperationalMode != 1)

{

// Send MODBUS request 0x05 write single coil to slave 2

SendModbusRequest (0x05, 2, IO_CLEAR_ERRROR, true);

WaitModbusReply

();

}

else if (uStatusFlags != 0)

{

SendModbusRequest (0x05, 2, IO_CLEAR_ERRROR, true);

WaitModbusReply

();

}

switch (iScaleFactor)

{

case 2: fSensorData = (float)(iSensorData) / 100.0;

case 1: fSensorData = (float)(iSensorData) / 10.0;

case 0: fSensorData = (float)(iSensorData);

case -1: fSensorData = (float)(iSensorData) * 10.0;

default: fSensorData = 0.0;

}

// wait 1 second

Delay (1000);

}

}

45

This manual is related to the following products: