Download Print this page

Get Latest Temperature; Log Temperatures At High Speed - Land Instruments International SPOT User Manual

Modbus controls

Advertisement

Spot Modbus Controls
2
Examples
The examples below give code snippets written in pseudocode. It is assumed
that the user has a Modbus tcp stack with functions:
ModbusRead
ModbusWrite
ModbusWriteMany
ModbusRead returns an array of length n registers, containing the values of
the Modbus registers on the SPOT thermometer from start register onwards.
ModbusWrite writes one value to a Modbus register on the SPOT
thermometer; ModbusWriteMany writes n values from an array.
Further functions must also be written in user code:
AddToLog
(unsigned short integer)
AddToJPG
(unsigned char)
ReportError
These functions add a word length data point to the log, add a byte of data
to the jpeg file that is being compiled, or alert the user to an error.

2.1 Get Latest Temperature

The most recent temperature measurement can simply be obtained by
reading register 247, and the internal instrument temperature from register
248. These can be read with one Modbus read command (read 2 registers
starting at 247).
Array =
ModbusRead
Temperature = Array[0]

2.2 Log Temperatures at High Speed

SPOT thermometers can provide temperature measurement at up to 1 kHz if
instrument output time is set to 1 ms.
The output data buffer permits every 1 ms measurement to be recorded and
transmitted in a single large batch of data.
Every output time, when register 247 is updated with the latest temperature
measurement, that measurement is also copied to a circular output data
buffer in registers 255-354.
Register 254 is incremented at the same time so that it always contains the
position of the latest measurement within that buffer.
A Modbus 'read multiple registers' command can then be used to read 101
registers starting at register 254. The new data will be indicated by the
difference in the pointer position since the previous read.
The 'read multiple registers' command should be repeated at regular
intervals of 50 to 70 times the instrument's output time.
More frequent communication is unnecessary, and it reduces the time
available for the instrument to measure temperature, which in turn reduces
the averaging statistics and increases noise.
Page 8
(start register, n registers)
(register, value)
(start register, n registers, array)
(string)
(247, 1)
User Guide

Advertisement

loading