beautypg.com

Basic programming guide – Remote Processing BASIC for the CX-10 Modbus User Manual

Page 57

background image

BASIC PROGRAMMING GUIDE

2-48

REGREAD

Syntax:

REGREAD(register)

Function:

Return value from a modbus register

Mode:

Command, run

Use:

PRINT REGREAD(1)
100 A = REGEAD(n)

DESCRIPTION

REGREAD function returns an integer or float from a modbus register. Variable type conversion is
automatically converted to a format compatible with Basic 52 (BCD floating point).

register range can be between 1 and 65535. However, this is board dependent. Consult your board manual
for valid registers. Most boards have valid ranges and gaps between ranges and are not contiguous.

Floating point numbers stored in modbus registers are in IEE-754 format. This format is known as single
precision. Effectively 7 digits plus exponent can be stored in this format. There are some numbers that, when
stored using REGWRITE, will return a slightly different number.

For example, if you stored one of the original numbers below using REGWRITE, REGREAD will return a
slightly different number.

Original

REGREAD

80.3

80.30001

80.6

80.59999

For all intents and purposes the differences are not significant, less than 0.0001245%.

ERROR

BAD ARGUMENT - when register is not valid or out of range.

EXAMPLE

100

REGWRITE 7033,A

120

PRINT REGEAD(7033)

>run

12