 ModScan-32 Help Index

Modbus Reference

Protocol

Messages

Error Detection

Exception Responses

ModScan Overview

Document/View Architecture

Modbus Data Definition

Display Formats

MDI Operation

Connecting to a Modbus Network

Menu Commands

File menu

Connection menu

Setup menu

View menu

Window menu

Help menu

Tool & Status Bars

Toolbar

Format Selections

Status Bar

Testing Features

Writing Data to the Modbus

Message Counters

Observing Serial Traffic

Capturing Data to Text File

User Defined Commands

Scripts

Using ModScan with a Database

Using OLE Automation

Creating Custom Displays

Registration Information


MODBUS Protocol

The MODBUS protocol describes an industrial communications and distributed control system developed by Gould-Modicon to integrate PLC’s, computers, terminals, and other monitoring, sensing, and control devices.  MODBUS is a Master/Slave communications protocol, whereby one device, (the Master), controls all serial activity by selectively polling one or more slave devices.  The protocol provides for one master device and up to 247 slave devices on a common line.  Each device is assigned an address to distinguish it from all other connected devices.

Only the master initiates a transaction.  Transactions are either a query/response type, (only a single slave is address), or a broadcast/no response type, (all slaves are addressed).  A transaction comprises a single query and single response frame or a single broadcast frame.

Certain characteristics of the MODBUS protocol are fixed, such as the frame format, frame sequences, handling of communications errors and exception conditions, and the functions performed.

Other characteristics are user selectable.  These include a choice of transmission media, baud rate, character parity, number of stop bits, and the transmission modes, (ASCII or RTU).   The user selected parameters are set, (hardwired or programmed), at each station.  These parameters cannot be changed while the system is running.

Modes of Transmission

The mode of transmission is the structure of the individual units of information within a message, and the numbering system used to transmit the data.  Two modes of transmission are available for use in a MODBUS system.  Both modes provide the same capabilities for communicating with PLC slaves;  the mode is selected depending on the equipment used as a MODBUS Master.  One mode must be used per MODBUS system; mixing of modes is not allowed.  The modes are ASCII (American Standard Code for Information Interchange), and RTU, (Remote Terminal Unit.)  The characteristics of the two transmission modes are defined below:

Characteristic	ASCII (7-bit)	RTU (8-bit)
Coding System	hexadecimal (uses ASCII printable characters (0-9, A-F)	8-bit binary
Number of bits per character:
start bits	1	1
data bits (least significant first)	7	8
parity (optional)	1	1
	(1-bit sent for even or odd parity, no bits for no parity)	(1-bit sent for even or odd parity, no bits for no parity)
stop bits	1 or 2	1 or 2
Error Checking	LRC (Longitudinal Redundancy Check)	CRC (Cyclical Redundancy Check)

ASCII printable characters are easy to view when troubleshooting and this mode is suited to computer masters programmed in a high level language, such as FORTRAN, as well as PLC masters.  RTU is suited to computer masters programmed in a machine language, as well as PLC masters.

In the RTU mode, data is sent in 8-bit binary characters.  In the ASCII mode, each RTU character is first divided into two 4-bit parts, (high order and low order), and then represented by the hexadecimal equivalent.  The ASCII characters representing the hexadecimal characters are used to construct the message.  The ASCII mode uses twice as many characters as the RTU mode, but decoding handling the ASCII data is easier.  Additionally, in the RTU mode, message characters must be transmitted in a continuous stream.  In the ASCII mode, breaks of up to one second can occur between characters to allow for a relatively slower master.


Error Detection

There are two types of errors which may occur in a communications system: transmission errors and programming errors.  The MODBUS system has specific methods for dealing with either type of error.

Communications errors usually consist of a changed bit or bits within a message.  The most frequent cause of communications errors is noise: unwanted electrical signals in a communications channel.  These signals occur because of electrical interference from machinery, damage to the communications channel, impulse noise, (spikes), etc.  Communications errors are detected by character framing, a parity check, and a redundancy check.

When the character framing, parity, or redundancy checks detect a communications error, processing of the message stops.  A PLC slave will not act on or respond to the message.  (The same occurs if a non-existent slave address is used.)

When a communications error occurs, the message is unreliable.  The PLC slave cannot know for sure if this message was intended for it.  So the CPU might be answering a message which was not its message to begin with.  It is essential to program the MODBUS Master to assume a communications error has occurred if there is no response in a reasonable time.  The length of this time depends upon the baud rate, type of message, and scan time of the PLC slave.  Once this time is determined, the master may be programmed to automatically retransmit the message.

The MODBUS system provides several levels of error checking to assure the quality of the data transmission.  To detect multibit errors where the parity has not changed, the system uses redundancy checks: Cyclical Redundancy Check, (CRC), for the RTU mode and Longitudinal Redundancy Check, (LRC), for the ASCII mode.

CRC-16 Cyclic Redundancy Check

The CRC-16 error check sequence is implemented as described in the following paragraphs.

The message, (data bits only, disregarding start/stop and parity bits), is considered as one continuous binary number whose most significant bit, (MSB), is transmitted first.  The message is pre-multiplied by X**16, (shifted left 16 bits), then divided by X**16 + X**15 + X**2 + 1 expressed as a binary number (11000000000000101).  The integer quotient digits are ignored and the 16-bit remainder (initialized to all ones at the start to avoid the case where all zeroes being an accepted message), is appended to the message, (MSB first), as the two CRC check bytes.  The resulting message including the CRC, when divided by the same polynomial (X**16 + X**15 + X**2 + 1), at the receiver will give a zero remainder if no errors have occurred.  (The receiving unit recalculates the CRC and compares it to the transmitted CRC).  All arithmetic is performed modulo two, (no carries).  An example of the CRC-16 error check for message HEX 0207, (address 2, function 7 or a status request to slave number 2) follows:

The device used to serialize the data for transmission will send the conventional LSB or right-most bit of each character first.  In generating the CRC, the first bit transmitted is defined as the MSB of the dividend.  For convenience then, and since there are no carries used in arithmetic, let’s assume while computing the CRC that the MSB is on the right.  To be consistent, the bit order of the generating polynomial must be reversed.  The MSB of the polynomial is dropped since it affects only the quotient and not the remainder.  This yields 1010 0000 0000 0001, (HEX A001)..  Note that this reversal of the bit order will have no effect whatever on the interpretation or the bit order of characters external to the CRC calculations.

The step by step procedure to form the CRC-16 is as follows:

1.	Load a 16-bit register with all 1’s.

2.	Exclusive OR the first 8-bit byte with the high order byte of the 16-bit register, putting the result in the 16-bit register.

3.	Shift the 16-bit register one bit to the right.

4a.	If the bit shifted out to the right is one, exclusive OR the generating polynomial 1010 0000 0000 0001 with the 16-bit register.

4b.	If the bit shifted out to the right is zero; return to step 3.

5.	Repeat steps 3 and 4 until 8 shifts have been performed.

6.	Exclusive OR the next 8-bit byte with the 16-bit register.

7.	Repeat step 3 through 6 until all bytes of the message have been exclusive OR’rd with the 16-bit register and shifted 8 times.

8.	The contents of the 16-bit register are the 2 byte CRC error check and is added to the message most significant bits first.

	16-BIT REGISTER	MSB			Flag
(Exclusive OR)	1111	1111	1111	1111
02			0000	0010
	1111	1111	1111	1101
Shift 1	0111	1111	1111	1110	1
Polynomial	1010	0000	0000	0001
	1101	1111	1111	1111
Shift 2	0110	1111	1111	1111	1
Polynomial	1010	0000	0000	0001
	1100	1111	1111	1110
Shift 3	0110	0111	1111	1111	0
Shift 4	0011	0011	1111	1111	1
Polynomial	1010	0000	0000	0001
	1001	0011	1111	1110
Shift 5	0100	1001	1111	1111	0
Shift 6	0010	0100	1111	1111	1
Polynomial	1010	0000	0000	0001
	1000	0100	1111	1110
Shift 7	0100	0010	0111	1111	0
Shift 8	0010	0001	0011	1111	1
Polynomial	1010	0000	0000	0001
	1000	0001	0011	1110
07			0000	0111
	1000	0001	0011	1001
Shift 1	0100	0000	1001	1100	1
Polynomial	1010	0000	0000	0001
	1110	0000	1001	1101
Shift 2	0111	0000	0100	1110	1
Polynomial	1010	0000	0000	0001
	1101	0000	0010	1111
Shift 3	0110	1000	0010	0111	1
Polynommial	1010	0000	0000	0001
	1100	1000	0010	0110
Shift 4	0110	0100	0001	0011	0
Shift 5	0011	0010	0000	1001	1
Polynomial	1010	0000	0000	0001
	1001	0010	0000	1000
Shift 6	0100	1001	0000	0100	0
Shift 7	0010	0100	1000	0010	0
Shift 8	0001	0010	0100	0001	0
	HEX 12			HEX 41
TRANSMITTED MESSAGE WITH CRC-16

(MESSAGE SHIFTED TO RIGHT TO TRANSMIT)

       12                   41                    07                   02

0001    0010    0100    0001    0000    0111    0000    0010

LRC (Longitudinal Redundancy Check)

The error check sequence for the ASCII mode is LRC.  The error check is an 8-bit binary number represented and transmitted as two ASCII hexadecimal (hex) characters.  The error check is produced by converting the hex characters to binary, adding the binary characters without wraparound carry, and two’s complementing the result.  At the received end the LRC is recalculated and compared to the sent LRC.  The colon, CR, LF, and any imbedded non-ASCII hex characters are ignored in calculating the LRC.

Address	02		0000 0010
Function	01		0000 0001
Start Add H.O.	00		0000 0000
Start Add L.O.	00		0000 0000
Quantity of Pts	00		0000 0000
	08		0000 1000
		Sum	0000 1011
		1’s complement	1111 0100
		+1	0000 0001
Error Check	F5	2’s complement	1111 0101


MODBUS Message Types

ASCII Framing

Framing in ASCII Transmission mode is accomplished by the use of the unique colon, (:), character to indicate the beginning of frame and carriage return/line feed, (CRLF), to delineate end of frame.  The line feed character also serves as a synchronizing character which indicates that the transmitting station is ready to receive an immediate reply.

BEGIN FRAME	ADDRESS	FUNCTION	DATA	ERROR CHECK	EOF	READY TO RECEIVE
:	2-CHAR 16-BIT	2-CHAR 16-BITS	N X 4-CHAR N X 16-BITS	2-CHAR 16-BITS	CR	LF

RTU Framing

Frame synchronization can be maintained in RTU transmission mode only by simulating a synchronous message.  The receiving device monitors the elapsed time between receipt of characters.  If three and one-half character times elapse without a new character or completion of the frame, then the device flushes the frame and assumes that the next byte received will be an address.

T1,T2,T3	ADDRESS	FUNCTION	DATA	CHECK	T1,T2,T3
	8-BITS	8-BITS	N X 8-BITS	16-BITS

Address Field

The address field immediately follows the beginning of frame and consists of 8-bits, (RTU), or 2 characters, (ASCII).   These bits indicate the user assigned address of the slave device that is to receive the message sent by the attached master.

Each slave must be assigned a unique address and only the addressed slave will respond to a query that contains its address.  When the slave sends a response, the slave address informs the master which slave is communicating.  In a broadcast message, an address of 0 is used.  All slaves interpret this as an instruction to read and take action on the message, but not to issue a response message.

Function Field

The Function Code field tells the addressed slave what function to perform.  MODBUS function codes are specifically designed for interacting with a PLC on the MODBUS industrial communications system.  The high order bit in this field is set by the slave device to indicate an exception condition in the response message.  If no exceptions exist, the high-order bit is maintained as zero in the response message.

The following table lists those functions supported by the ModScan application:

CODE	MEANING	ACTION
01	READ COIL STATUS	Obtains current status, (ON/OFF), of a group of logic coils.
02	READ INPUT STATUS	Obtains current status, (ON/OFF), of a group of discrete inputs.
03	READ HOLDING REGISTER	Obtains current binary value in one or more holding registers.
04	READ INPUT REGISTER	Obtains current binary value in one or more input registers.
05	FORCE SINGLE COIL	Force logic coil to a state of ON or OFF.
06	PRESET SINGLE REGISTER	Place a specific binary value into a holding register.

Data Field

The data field contains information needed by the slave to perform the specific function or it contains data collected by the slave in response to a query.  This information may be values, address references, or limits.  For example, the function code tells the slave to read a holding register, and the data field is needed to indicate which register to start at and how many to read.  The imbedded address and data information varies with the type and capacity of the PLC associated with the slave.

Error Check Field

This field allows the master and slave devices to check a message for errors in transmission.  Sometimes, because of electrical noise or other interference, a message may be changed slightly while its on its way from one device to another.  The error checking assures hat the slave or master does not react to messages that have changed during transmission.  This increases the safety and the efficiency of the MODBUS system.

The error check field uses a Longitudinal Redundancy Check, (LRC), in the ASCII mode of transmission, and a CRC-16 check in the RTU mode.


Exception Responses

Programming or operation errors are those involving illegal data in a message, no response from the PLC to its interface unit, or difficulty in communicating with a slave.  These errors result in an exception response from either the master computer software or the PLC slave, depending on the type of error.  The exception response codes are listed below.  When a PLC slave detects one of these errors, it sends a response message to the master consisting of the slave address, function code, error code, and error check fields.  To indicate that the response is a notification of an error, the high-order bit of the function code is set to one.

CODE	NAME	MEANING
01	ILLEGAL FUNCTION	The message function received is not an allowable action for the addressed slave.
02	ILLEGAL DATA ADDRESS	The address referenced in the data field is not an allowable address for the addressed slave device.
03	ILLEGAL DATA VALUE	The value referenced in the data field is not allowable in the addressed slave location.
04	FAILURE IN ASSOCIATED DEVICE	The slave’s PC has failed to respond to a message or an abortive error occurred.
05	ACKNOWLEDGE	The slave PLC has accepted and is processing the long duration program command.
06	BUSY, REJECTED MESSAGE	The message was received without error, but the PLC is engaged in processing a long duration program command.
07	NAK-NEGATIVE ACKNOWLEDGMENT	The PROGRAM function just requested could not be performed.


Read Output Status
READ OUTPUT STATUS (FUNCTION CODE 01)

This function allows the user to obtain the ON/OFF status of logic coils used to control discrete outputs from the addressed slave only.  Broadcast mode is not supported with this function code.  In addition to the slave address and function fields, the message requires that the information field contain the initial coil address to be read, (Starting Address), and the number of locations that will be interrogated to obtain status data.

The addressing allows up to 2000 coils to be obtained at each request; however, the specific slave device may have restrictions that lower the maximum quantity.  The coils are numbered from zero; (coil number 1 is address 0000, coil number 2 is address 0001, etc.)

The following is an example of a message to Read Output Status Coils 20-56 from slave device number 17.

ADDR	FUNC	DATA START PT HO	DATA START PT LO	DATA # OF PTS HO	DATA # OF PTS LO	ERROR CHECK FIELD
11	01	00	13	00	25	B6

An example response to Read Output Status is shown below.  The data is packed one bit for each coil.  The response includes the slave address, function code, quantity of data characters, and error checking.  Data will be packed with one bit with one bit for each coil, (1 = ON, 0 = OFF).  The low order bit of the first character contains the addressed coil, and the remainder follow.  For coil quantities that are not even multiples of eight, the last characters will be filled in with zeroes at the high end.  The quantity of data characters is always specified as the quantity of RTU characters, i.e., the number is the same whether RTU or ASCII is used.

ADDR	FUNC	BYTE COUNT	DATA COIL STATUS 20-27	DATA COIL STATUS 28-35	DATA COIL STATUS 36-43	DATA COIL STATUS 44-51	DATA COIL STATUS 52-56	ERROR CHECK FIELD
11	01	05	CD	6B	B2	0E	1B	D6

The status of coils 20-27 is shown as CD(HEX) = 1100 1101(Binary).  Reading left to right, this shows that coils 27,26,23,22, and 20 are all on.  The other coil data bytes are decoded similarly.


Read Input Status
READ INPUT STATUS (FUNCTION CODE 02)

This function allows the user to obtain the ON/OFF status of discrete inputs in the addressed slave.  Broadcast mode is not supported.  In addition to the slave address and function code fields, this message requires that the information field contain the initial input address to be read, (Starting Address) and the number of locations that will be interrogated to obtain the status data.

The following is an example of a message to Read Input Status Coils 10197-10218 from slave device number 17.

ADDR	FUNC	DATA START PT HO	DATA START PT LO	DATA # OF PTS HO	DATA # OF PTS LO	ERROR CHECK FIELD
11	02	00	C4	00	16	13

An example response to Read Input Status is shown below.  The data is packed one bit for each coil.  The response includes the slave address, function code, quantity of data characters, and error checking.  Data will be packed with one bit with one bit for each coil, (1 = ON, 0 = OFF).  The low order bit of the first character contains the addressed coil, and the remainder follow.  For coil quantities that are not even multiples of eight, the last characters will be filled in with zeroes at the high end.  The quantity of data characters is always specified as the quantity of RTU characters, i.e., the number is the same whether RTU or ASCII is used.

ADDR	FUNC	BYTE COUNT	DATA DISCRETE INPUT 10197-10204	DATA DISCRETE INPUT 10205-10212	DATA DISCRETE INPUT 10213-10218	ERROR CHECK FIELD
11	02	03	AC	DB	35	2E	LRC

The status of inputs 10197-10204 is shown as AC (HEX) = 1010 1100 (Binary).  Reading left to right, this shows that inputs 10204, 10202, 10200 and 10099 are all on.  The other input data bytes are decoded similarly.


Read Output Registers
READ OUTPUT REGISTERS (FUNCTION CODE 03)

Read Output Registers allows the user to obtain the binary contents of holding registers in the addressed slave.

These registers can store the numerical values of associated timers and counters which can be driven to external devices.

The addressing allows up to 125 registers to be obtained at each request; however, the specified slave device may have restrictions that lower this maximum quantity.  The registers are numbered from zero, broadcast mode is not allowed.

The following example reads registers 40108 through 40110 from slave number 17.

ADDR	FUNC	DATA START PT HO	DATA START PT LO	DATA # OF REGS HO	DATA # OF REGS LO	ERROR CHECK FIELD
11	03	00	6B	00	03	7E
The addresses slave responds with its address and the function code, followed by the information field.  The information field contains 2 bytes describing the quantity of data bytes to be returned.  The contents of the registers requested (DATA), are two bytes each, with the binary content right justified within each pair of characters.  The first byte includes the high order bits and the second, low order bits.

In the example below, the registers 40108-40110 have the decimal contents 555, 0, and 100 respectively.

ADDR	FUNC	BYTE COUNT	DATA OUTPUT REG H.O. 40108	DATA OUTPUT REG L.O. 40108	DATA OUTPUT REG H.O. 40109	DATA OUTPUT REG L.O. 40109	DATA OUTPUT REG H.O. 40110	DATA OUTPUT REG L.O. 40110	ERROR CHECK FIELD
11	03	06	02	2B	00	00	00	64	55


Read Input Registers
READ INPUT REGISTERS (FUNCTION CODE 04)

Function Code 04 obtains the contents of the controllers input registers.  These locations receive their vales from devices connected to the I/O structure and can only be referenced, not altered from within the controller nor via MODBUS.

The example below requests the contents of register 30009 in slave number 17.

ADDR	FUNC	DATA START PT HO	DATA START PT LO	DATA # OF REGS HO	DATA # OF REGS LO	ERROR CHECK FIELD
11	04	00	08	00	01	E2

In the response message, the contents of register 30009 is decimal value 0.

ADDR	FUNC	BYTE COUNT	DATA INPUT REG HO 30009	DATA INPUT REG LO 30009	ERROR CHECK FIELD
11	04	02	00	00	E9


Force Single Coil
FORCE SINGLE COIL (FUNCTION CODE 05)

This message forces a single coil either On of OFF.  Any coil that exists within the controller can be forced to either state, (ON or OFF).  Coils are numbered from zero (i.e. coil 1 is address 0000, coil 2 is address 0001, etc.).  The data value 65,280, (FF00 HEX) will set the coil ON and the value zero will turn it off.  All other values are illegal and will not effect the coil.  The use of slave address 00, (Broadcast mode), will force all attached slaves to modify the desired coil.

The example below requests slave number 17 to turn coil number 0173 ON.

ADDR	FUNC	DATA COIL HO	DATA COIL LO	DATA # ON/OFF	DATA	ERROR CHECK FIELD
11	05	00	AC	FF	00	3F

The normal response to the command request is to retransmit the message as received, after the coil state has been altered.

ADDR	FUNC	DATA COIL HO	DATA COIL LO	DATA # ON/OFF	DATA	ERROR CHECK FIELD
11	05	00	AC	FF	00	3F


Preset Single Register
PRESET SINGLE REGISTER (FUNCTION CODE 06)

Function 06 allows the user to modify the contents of a holding register.  Any holding register that exists within the controller can have its contents changed by this message.  The values are provided in binary up to the maximum capacity of the controller.  Unused high-order bits must be set to zero.  When used with slave address 00, all slave controllers will load the specified register with the contents specified.

ADDR	FUNC	DATA REG HO	DATA REG LO	DATA  VALUE HO	DATA VALUE  LO	ERROR CHECK FIELD
11	06	00	87	03	9E	C1

The normal response to a preset single register request is to retransmit the query message after the register has been altered.

ADDR	FUNC	DATA REG HO	DATA REG LO	DATA  VALUE HO	DATA VALUE  LO	ERROR CHECK FIELD
11	06	00	87	03	9E	C1


ModScan Overview

The ModScan application operates as a MODBUS master device in either RTU or ASCII transmission modes.  ModScan may be used to access and modify data points contained in one or more MODBUS slave devices connected to the PC via a serial port, modem, or network.  ModScan supports the standard MODBUS message types 01-06, 15 & 16, as well as providing the ability for you to exercise special features of a slave device by transmitting custom command strings and observing the response.  ModScan is a useful test and diagnostic tool for verifying the proper slave response to MODBUS queries as well as being a low cost data collection tool for interfacing data into PC database and spreadsheet applications.

See Also:

modbus_protocol	Splitter Windows	Connecting to a modbus network


File menu commands

The File menu offers the following commands:

New	Creates a new document.
Open	Opens an existing document.
Custom Forms	Creates or opens a document which may be customized to include various graphical display objects representing modbus data.
Close	Closes an opened document.
Save	Saves an opened document using the same file name.
Save As	Saves an opened document to a specified file name.
Print	Prints a document.
Print Setup	Selects a printer and printer connection.
Exit	Exits ModScan32.


Connect menu commands

The Connect menu offers the following commands:

Connect	Attaches the ModScan application to a modbus network, enabling data collection.
Disconnect	Detaches the ModScan application from the network, freeing up resources for other Windows applications.
AutoStart	Allows ModScan to be configured to automatically load documents and establish a modbus connection upon application startup.


Setup menu commands

The Setup menu offers the following commands:

Data Definition	Defines the document properties of the modbus data to be scanned.
Display Options	Allows the document data to be viewed in a variety of formats.
Extended Options	Provides the ability to write data to a connected slave device.
Text Capture	Begins collecting modbus data to a specified text file.
Dbase Capture	Begins collecting data into a defined database table.
Capture Off	Stops data collection.
Reset Counters	Clears all modbus message status counters in all documents.


Setup Display Options menu commands

The Display Options menu offers the following commands:

Show Data	This default view configuration displays data values as obtained from the modbus slave device.
Show Traffic	This option allows the serial data stream to be displayed in place of the data points.
Binary	Register values are displayed as 16 discrete bits.
Decimal	Register values are displayed in decimal format, (-32767-32768).
Hex	Register Values are displayed in Hexadecimal, (0000-ffff).
Floating Pt.	Register Values are displayed in floating point notation, (two registers are required).
Swapped FP	Register Values are displayed in floating point notation, (least significant register first).
Dbl Float	Register Values are displayed in floating point notation, (four registers, (64 bits), are required).
Swapped Dbl	Register Values are displayed in floating point notation, (least significant register first).
Hex Addresses	Displays the addresses of data points in hexadecimal notation..


Setup Extended Options menu commands

The Setup Extended Options menu offers the following commands:

Force Coils	Provides the ability to write coil values to a designated slave device.
PreSet Registers	Provides the ability to write register values to a designated slave device.
User Commands	Allows you to define and transmit a custom command.
Script Files	Begins execution of a test script.


AutoStart menu commands

The AutoStart menu offers the following commands:

Enable	Enables the ModScan application to automatically load documents and establish a modbus connection on start-up.
Disable	Disables the AutoStart functionality.
Save Config	Saves the current ModScan document configuration in a format which may be automatically restored during AutoStart.
Restore Now	Restores a configuration as previously saved above.


View menu commands

The View menu offers the following commands:

Toolbar	Shows or hides the toolbar.
Status Bar	Shows or hides the status bar.
Display Bar	Shows or hides the format toolbar used to select the  display format for modbus registers.
Config	Allows you to customize the appearance of ModScan by selecting the colors and font used.


Window menu commands

The Window menu offers the following commands, which enable you to arrange multiple views of multiple documents in the application window:

New Window	Creates a new window that views the same document.
Cascade	Arranges windows in an overlapped fashion.
Tile	Arranges windows in non-overlapped tiles.
Arrange Icons	Arranges icons of closed windows.
Split	Split the active window into panes.
Window 1, 2, ...	Goes to specified window.


Config menu commands (View menu)

The config options supported under the View menu offers you the ability to select the colors used to display modbus data as well as the character font.

Background Color	Selects the color for the ModScan data display splitter view.
Foreground Color	Selects the text color used to display data values.
Status Color	Selects the color used to show the modbus status line.
Font	Selects the font.

See Also:

Data Display Splitter View


Help menu commands

The Help menu offers the following commands, which provide you assistance with this application:

Help Topics	Offers you an index to topics on which you can get help.
About	Displays the version number of this application.


File New command
New command (File menu)

Use this command to create a new document in ModScan.  Each document represents a different block of data from a modbus device.

You can open an existing document with the Open command.

Shortcuts

Toolbar:

Keys:	CTRL+N


File New dialog box

<< Delete this help topic if your application supports only one document type. >>

Specify the type of document you wish to create:

<< List your application's document types here >>


File Open command
Open command (File menu)

Use this command to open an existing document in a new window.  You can open multiple documents at once.  Use the Window menu to switch among the multiple open documents.  See Window 1, 2, ... command.

You can create new documents with the New command.

Shortcuts

Toolbar:

Keys:	CTRL+O


File Open dialog box

The following options allow you to specify which file to open:

File Name

Type or select the filename you want to open.  This box lists files with the extension you select in the List Files of Type box.

List Files of Type

Select the type of file you want to open:

Drives

Select the drive in which ModScan stores the file that you want to open.

Directories

Select the directory in which ModScan stores the file that you want to open.

Network...

Choose this button to connect to a network location, assigning it a new drive letter.


File Close command
Close command (File menu)

Use this command to close the active document.  If the data definition, (address, point type, etc), has changed since the document was opened, ModScan suggests that you save changes before you close it.  If you close a document without saving, you lose all changes made since the last time you saved it.  Before closing an untitled document, ModScan displays the Save As dialog box and suggests that you name and save the document.

You can also close a document by using the Close icon on the document's window, as shown below:


File Save command
Save command (File menu)

Use this command to save the active document to its current name and directory.  When you save a document for the first time, ModScan displays the Save As dialog box so you can name your document.  If you want to change the name and directory of an existing document before you save it, choose the Save As command.

Shortcuts

Toolbar:

Keys:	CTRL+S


File Save As command
Save As command (File menu)

Use this command to save and name the active document.  ModScan displays the Save As dialog box so you can name your document.

To save a document with its existing name and directory, use the Save command.


Connect command (Connection menu)

Use this command to connect the ModScan application to a modbus network.  A dialog box will prompt you for information relative to the connection.  You may use ModScan to connect directly to a modbus device via one of four Windows COM ports, or via a modem or TCP/IP network.  The possible ways to connect are presented in the drop-down list contained within the connect dialog box.

If a modem connection is selected, you must supply the dialing number and if a network selection is made, you must supply the necessary IP address for the connection.

If you select a direct connection, you must specify the associated baud rate, parity and control line selections which match your modbus devices.  ModScan will always control the hardware handshake signals as follows:

The DTR will be asserted whenever the port is opened and deasserted when the port is closed.  RTS will be asserted prior to transmitting the first character in a message and deasserted after transmitting the last character in the output buffer.  Checkbox selections in the config dialog allow the ModScan application to block transmission of character data based on the state of the CTS and/or DTR signals.  Also, time delays may be placed around the RTS toggle operation to accommodate slow modem devices.  The order of operation would be as follows:

Enable RTS

Wait for User Specified Delay

Transmit the Data

Wait for User Specified Delay

Disable RTS

The protocol selections button allows to specify either the modbus RTU or ASCII transmission mode and the time-out associated with the expected slave response to a query.

See Also:

Connecting to a modbus network	Disconnect Menu Cmd


Disconnect command (Connection menu)

Use this command to disconnect the ModScan application from your modbus network.

See Also:

Connecting to a modbus network	Connect Menu Cmd


AutoStart Enable (Connection menu)

Use this command to specify a configuration file whic is to be automatically loaded on application startup.  The configuration file consists of a series of ModScan Document files and their associated display positions as saved using the AutoStart,Save Config menu option.  The current connection state, (hardware configuration and port assignment), is also saved in the config file and used to automatically establish the modbus connection during the AutoStart sequence.


AutoStart Disable (Connection menu)

Use this command to disable the AutoStart functionality.


AutoStart Save Config (Connection menu)

Use this command to create a configuration file which may be automatically loaded on application start-up.  Each open document file is saved with its associated screen coordinates in a format which may be restored during an AutoStart operation.  Connection parameters, such as baud rate, protocol, and port selection, are also saved.  You will be prompted to supply a file name for each document which has been created without a previous File Save having been perfromed..


AutoStart Restore Now (Connection menu)

Use this command to automatically load a previously saved AutoStart Config file.  All currently open documents will be closed and those specified in the config file will be restored as well as the connection parameters which were in effect whenever the file was created.


File Save As dialog box

The following options allow you to specify the name and location of the file you're about to save:

File Name

Type a new filename to save a document with a different name.  A filename can contain up to eight characters and an extension of up to three characters.  ModScan adds the extension you specify in the Save File As Type box.

Drives

Select the drive in which you want to store the document.

Directories

Select the directory in which you want to store the document.

Network...

Choose this button to connect to a network location, assigning it a new drive letter.


File 1, 2, 3, 4 command
1, 2, 3, 4 command (File menu)

Use the numbers and filenames listed at the bottom of the File menu to open the last four documents you closed.  Choose the number that corresponds with the document you want to open.


File Exit command
Exit command (File menu)

Use this command to end your ModScan32 session.  You can also use the Close command on the application Control menu.  ModScan prompts you to save documents with unsaved changes.

Shortcuts

Mouse:	Double-click the application's Control menu button.

Keys:	ALT+F4


Data Definition command (Setup menu)

Use this command to define the characteristics of the data to be monitored for the active document.  You may select up to 128 data points for display, (if the connected slave device can support the scan requirements).

See Also:

modbus protocol	Splitter1


ShowData command (Setup menu)

ModScan is normally configured to display modbus data points in the lower splitter view of the associated document.  Data points are displayed in order from top to bottom, left to right.  Data is displayed using the current colors and font selection.

Coil values are displayed as either <0> or <1>.  Register values may be displayed in a variety of formats according to your preferences.

See Also:

Data Display Splitter View


Show Traffic command (Setup menu)

Use this command to troubleshoot the connection to a particular modbus device.  When selected, this option will display the serial data exchanged between the ModScan application and the slave device associated with this document.  The data display splitter view will show data transmitted to the slave device and data returned from the slave device as communications occur during the normal polling cycle.  This will help to isolate a problem with possible misinterpretation of the modbus protocol.  Data will be displayed in either decimal or hex, depending upon the preference settings in effect for viewing the modbus data points.  Normal data collection, (if enabled), will continue.

See Also:

modbus_protocol	Data Definition Menu Cmd	Splitter1	Splitter2


Binary Display Option (Setup menu)

Use this command to display the contents of modbus registers as a group of 16 discrete values as shown below:

41000: <0001000100110100>

This example shows the HOLDING REGISTER located at address 1000 to contain the value 1134H.

Shortcuts

Toolbar:


Decimal Display Option (Setup menu)

Use this command to display the contents of modbus registers as decimal values within the range -32767 to 32768.

Shortcuts

Toolbar:


Unsigned Display Option (Setup menu)

Use this command to display the contents of modbus registers as decimal values within the range 0 to 65534.

Shortcuts

Toolbar:


Hex Display Option (Setup menu)

Use this command to display the contents of modbus registers as hexadecimal values within the range 0000 to ffff.

Shortcuts

Toolbar:


Floating Pt. Display Option (Setup menu)

Use this command to display the contents of modbus registers as floating point values based on interpretation of two consecutive registers, (32-bits), according to the IEEE specification.

Shortcuts

Toolbar:

ModScan will attempt to convert the values contained within the selected registers as the IEEE value.  If the bit pattern contained within the register set matches the criteria for a floating point number, the value will be displayed on the lower document splitter view as a decimal value associated with the first register address of the pair.

If the above screen were to displayed in hexadecimal notation, it would look like the example below.  This details the actual register contents and the conversion to floating point as performed by the ModScan application.


Swapped Floating Pt. Display Option (Setup menu)

Use this command to display the contents of modbus registers as floating point values based on interpretation of two consecutive registers, (32-bits), according to the IEEE specification.

Shortcuts

Toolbar:

ModScan will attempt to convert the values contained within the selected registers as the IEEE value.  If the bit pattern contained within the register set matches the criteria for a floating point number, the value will be displayed on the lower document splitter view as a decimal value associated with the first register address of the pair.  The difference between this option and the normal Floating Pt display option is the order of the registers with respect to the IEEE standard.  This is depicted by the following two screen examples.

If the above screen were to displayed in hexadecimal notation, it would look like the example below.  This details the actual register contents and the conversion to floating point as performed by the ModScan application.


Double-Precision Floating Pt. Display Option (Setup menu)

Use this command to display the contents of modbus registers as floating point values based on interpretation of four consecutive registers, (64-bits), according to the IEEE specification for double-precision numbers.

Shortcuts

Toolbar:

ModScan will attempt to convert the values contained within the selected registers as the IEEE value.  If the bit pattern contained within the register set matches the criteria for a floating point number, the value will be displayed on the lower document splitter view as a decimal value associated with the first register address of the pair.

If the above screen were to displayed in hexadecimal notation, it would look like the example below.  This details the actual register contents and the conversion to floating point as performed by the ModScan application.


Word-Swapped Double-Precision Floating Pt. Display Option (Setup menu)

Use this command to display the contents of modbus registers as floating point values based on interpretation of four consecutive registers, (64-bits), according to the IEEE specification for double-precision numbers.

Shortcuts

Toolbar:

ModScan will attempt to convert the values contained within the selected registers as the IEEE value.  If the bit pattern contained within the register set matches the criteria for a floating point number, the value will be displayed on the lower document splitter view as a decimal value associated with the first register address of the pair. .  The difference between this option and the normal Floating Pt display option is the order of the registers with respect to the IEEE standard.  This is depicted by the following two screen examples.

If the above screen were to displayed in hexadecimal notation, it would look like the example below.  This details the actual register contents and the conversion to floating point as performed by the ModScan application.


Hex Addresses Display Option (Setup menu)

Use this command to display the addresses associated with a modbus data point in hexadecimal notation rather than decimal.


Building Test Scripts

Test scripts consist of ASCII text data field separated by commas. They may be constructed using any word processor or spreadsheet application.  A test script entry consists of at least 7 data fields as depicted in the following example script, (example.csv).

//

// Example Test Script for ModScan Application

//

// Each Script entry consists of the following

// comma delimited data fields:

//

// TEST NAME, NODE, FUNCTION, ADDRESS, LENGTH, DATA, CONTROL CODE

//

// Double slashes on the front of a line denote comments

//

// The following Control Codes may be used (i.e. last field on each line)

//	\ -- Continue DATA fields on next line

//	C -- Generate Bad CRC message to slave

//	D -- Check response data quantity only, (ignore actual data)

//	1 -- Expect Exception Response 01

//	2 -- Expect Exception Response 02

//	4 -- Expect Exception Response 04

//	R -- Expect no Response

//	T (default) -- Verify Response Data

//

//

// First Test:

//	Write 20 Coils to Node 1 starting at address 100

//	Data is alternating pattern of ones & zeros

//      (DATA field consists of 32-bits and may be specified

//	 as a decimal, hex or floating-point value)

//

Preset Multiple Coils,1,15,100,20,0xAAAAA,T

//

//

// Second Test:

//	Verify results of first test by reading the pattern back

//

Verify Coil Status,1,1,100,20,0xAAAAA,T

//

// Third Test:

//	Read 100 Input Status values

//	ignore the data and only verify proper quantity returned

//

Verify Input Status,1,2,100,100,0,D

//

//

// Forth Test:

//	Check Slave Response to request for 1000 registers

//	(Should probably generate an exception response)

//

Test Exception 2,1,3,100,1000,0,2

//

// Fifth Test:

//	Check Slave Response to bad CRC

//

Invalid Request,1,1,100,1,0,C

//

// Sixth Test:

//	Query an unknown device & expect no response

//

Query Device 73,73,1,1,1,0,R

//

// Seventh Test:

//	Write 6 Holding Registers with data

//      (Each floating point number represents

//	 two registers  -- The NAME field on the

//	 continuation line is ignored)

//

Write Floats,1,16,100,6,1.00,\

,2.00,3.00,,,,T

//

// Eighth Test:

//	Verify Test Seven by reading back the Registers

//

Read Floats,1,3,100,6,1.00,\

,2.00,3.00,,,,T

//

// END OF SCRIPT

end


Executing Test Scripts (Setup Extended menu)

Test scripts are one of the most unique features of ModScan.  They provide for production testing of modbus slave devices by allowing you to construct and execute a series of modbus messages to be sent to an attached slave device to verify and log the responses.  Script files are constructed using any word-processor or spreadsheet application to define the test message and expected slave response.  Response codes are available which determine how ModScan verifies the response against the user supplied data.  For example, one script entry may request the contents of a group of known registers and expect the exact response to be returned.  Another script entry may complete successfully if the correct number of register values is returned, regardless of the contents.

Test scripts may be executed one entry at a time, (single-step), or placed in a loop to execute continuously, logging the results to a text file for later observation by a test technician.

If continuous execution of the script is desired, an auxiliary dialog box defines the looping characteristics.

Test results are displayed as each script entry is executed.

See Also:

modbus protocol	User Commands	Constructing a Test Script


User Cmds Option (Setup Extended menu)

Use this command to customize a command string for transmission to a designated modbus slave device.  This command is useful for observing the slave response to non-standard modbus queries or to test its reaction to requests for data which may not be available.  The slave device should respond with the proper exception message if a master device asks for data which is beyond its address range or otherwise unavailable via the modbus.

After transmitting the user string, ModScan will receive characters for the entire time-out period specified for the connection.  The results will then be updated to the appropriate edit control on the dialog box.  User defined messages transmitted to a slave device will not show up in the ModScan message counters.

See Also:

Using Test Scripts


Preset Registers Cmd (Setup Extended menu)

Use this command to force a group of holding registers to selected values.  ModScan uses modbus message 16, (Preset Registers), to write data to the designated slave device. Selecting this menu option will initiate a dialog box which prompts for the address of the data to write:

Entering appropriate values for the slave address, point address, and number of registers to write initiates a second dialog which allows you to manually select the value for each register.  Use the edit controls associated with each register address to enter its value.  Values may be entered in either decimal or hexadecimal notation, depending upon the preference selected for modbus data display.  The scrollbar control allows you to advance to the next series of register addresses up to the maximum specified in the previous dialog:

Buttons at the right of the Preset Registers dialog allow you to configure a series of register values and write them to a disk file for later retrieval and downloading to a modbus slave.  Pressing the To File button saves the currently defined register values to a selected file.  The From File button fills the edit controls of the dialog with values obtained from a previously saved disk file.

See Also:

Writing Data to Slave Device


Force Coils Cmd (Setup Extended menu)

Use this command to manually force a group of coils to a given state, (on/off).  The ability to address multiple coils in a slave depends upon the operating characteristics of the device.  ModScan uses modbus message 15, (Force Multiple Coils), to transmit the request to the designated slave.  Selecting this menu option will initiate a dialog box which prompts for the address of the data to write:

Entering appropriate values for the slave address, point address, and number of coils to write initiates a second dialog which allows you to manually select the value for each coil.  Use the radio buttons to select either ON of OFF for each coil value.  The scrollbar control allows you to advance to the next series of coil addresses:

See Also:

Writing Data to Slave Device


Text Capture Cmd (Setup menu)

Use this command to store the results of each modbus query to an ASCII text file.  Data is written to the specified file, (one scan per line), in the format selected for display in the lower splitter view, (i.e. decimal, hex, float).  If an error was encountered during the polling transaction, the error message will be logged to the file rather than the data.  There is no “wrap-around” feature for collecting data.  New data is appended to the file on each query and the file can become very large vary fast if used with a short scan frequency.


Database Capture Cmd (Setup menu)

The ability to save modbus data directly to a database is an optional feature of ModScan.  If the feature is unavailable, the Database Capture menu selection will be grayed out and not accessible.  If enabled, this command allows you to store the results of each query into an active Microsoft compatible database for interfacing modbus data with custom designs.

See Also:

Using ModScan with a Database


Capture Off Cmd (Setup menu)

Use this command to stop the document from updating the capture file.


Reset Counters Cmd (Setup menu)

Use this command to reset the modbus message counters for all active documents.


View Toolbar command
Toolbar command (View menu)

Use this command to display and hide the Toolbar, which includes buttons for some of the most common commands in ModScan such as File Open.  A check mark appears next to the menu item when the Toolbar is displayed.

See Toolbar for help on using the toolbar.


View Format toolbar command
Displaybar command (View menu)

Use this command to display and hide the Toolbar associated with the Display formatting options.  A check mark appears next to the menu item when the Toolbar is displayed.

See FormatBar for help on using the toolbar.


Toolbar

The toolbar is displayed across the top of the application window, below the menu bar.  The toolbar provides quick mouse access to many tools used in ModScan.  The toolbar is detachable and dockable by clicking the mouse on the toolbar background and dragging it to the desired location within the ModScan application window.

To hide or display the Toolbar, choose Toolbar from the View menu (ALT, V, T).

Click	To

Open a new document.

Open an existing document.  ModScan displays the Open dialog box, in which you can locate and open the desired file.

Save the active document or template with its current name.  If you have not named the document, ModScan displays the Save As dialog box.

Define the characteristics of the modbus data to be displayed.

Show modbus data points in lower splitter view.

Show serial data streams in lower splitter view.

Print the active document.

Display the About Box.

Context Help.


toolbar
Display Format Toolbar

The format toolbar is displayed across the top of the application window, below the menu bar.  The format toolbar provides quick mouse access to select the format used by ModScan to display the contents of modbus registers.  The toolbar is detachable and dockable by clicking the mouse on the toolbar background and dragging it to the desired location within the ModScan application window.

Click	To

Display registers in binary.

Display registers in decimal.

Display registers in hexadecimal.

Display registers in floating-point notation.

Display registers in floating-point notation, (interpreted as having the least significant 16-bits in the first register).

Display registers in 64-bit double precision floating point notation.

Display registers in double-precision floating point, (interpreted as having the least significant 16-bits in the first register).


View Status Bar Command
Status Bar command (View menu)

Use this command to display and hide the Status Bar, which describes the action to be executed by the selected menu item or depressed toolbar button. A check mark appears next to the menu item when the Status Bar is displayed.

See Status Bar for help on using the status bar.


Status Bar

The status bar is displayed at the bottom of the ModScan window.  To display or hide the status bar, use the Status Bar command in the View menu.

The left area of the status bar describes actions of menu items as you use the arrow keys to navigate through menus.  This area similarly shows messages that describe the actions of toolbar buttons as you depress them, before releasing them.  If after viewing the description of the toolbar button command you wish not to execute the command, then release the mouse button while the pointer is off the toolbar button.

The right areas of the status bar indicate the message counters for all modbus message activity logged by the various active documents.


New command (Window menu)

Use this command to open a new window with the same contents as the active window.  You can open multiple document windows to display different parts or views of a document at the same time.  If you change the contents in one window, all other windows containing the same document reflect those changes.  When you open a new window, it becomes the active window and is displayed on top of all other open windows.


Cascade command (Window menu)

Use this command to arrange multiple opened windows in an overlapped fashion.


Tile command (Window menu)

Use this command to arrange multiple opened windows in a non-overlapped fashion.


Tile Horizontal command (Window menu)

Use this command to vertically arrange multiple opened windows in a non-overlapped fashion.


Tile Vertical command (Window menu)

Use this command to arrange multiple opened windows side by side.


Window Arrange Icons Command

Use this command to arrange the icons for minimized windows at the bottom of the main window.  If there is an open document window at the bottom of the main window, then some or all of the icons may not be visible because they will be underneath this document window.


Split Command (Window menu)

Use this command to split the active window into panes.  You may then use the mouse or the keyboard arrows to move the splitter bars.  When you are finished, press the mouse button or enter to leave the splitter bars in their new location.  Pressing escape keeps the splitter bars in their original location.  << In a single document interface application, this command will appear on the View menu. >>


1, 2, ... command (Window menu)

ModScan displays a list of currently open document windows at the bottom of the Window menu.  A check mark appears in front of the document name of the active window.  Choose a document from this list to make its window active.


Index command (Help menu)

Use this command to display the opening screen of Help.  From the opening screen, you can jump to step-by-step instructions for using ModScan and various types of reference information.

Once you open Help, you can click the Contents button whenever you want to return to the opening screen.


Using Help command (Help menu)

Use this command for instructions about using Help.


About command (Help menu)

Use this command to display the copyright notice and version number of your copy of ModScan.


Help Using Help Command
Context Help command

Use the Context Help command to obtain help on some portion of ModScan.  When you choose the Toolbar's Context Help button, the mouse pointer will change to an arrow and question mark.  Then click somewhere in the ModScan window, such as another Toolbar button.  The Help topic will be shown for the item you clicked.

Shortcut

Keys:	SHIFT+F1


Title Bar

The title bar is located along the top of a window.  It contains the name of the application and document.

To move the window, drag the title bar.  Note: You can also move dialog boxes by dragging their title bars.

A title bar may contain the following elements:

Application Control-menu button

Document Control-menu button

Maximize button

Minimize button

Name of the application

Name of the document

Restore button


System Minimize Command
Minimize command (application Control menu)

Use this command to reduce the ModScan window to an icon.

Shortcut

Mouse:	Click the minimize icon [image] on the title bar.

Keys:	ALT+F9


Maximize command (System menu)

Use this command to enlarge the active window to fill the available space.

Shortcut

Mouse:	Click the maximize icon [image] on the title bar; or double-click the title bar.

Keys:	CTRL+F10 enlarges a document window.


Previous Window command (document Control menu)

Use this command to switch to the previous open document window.  ModScan determines which window is previous according to the order in which you opened the windows.

Shortcut

Keys:	SHIFT+CTRL+F6


Close command (Control menus)

Use this command to close the active window or dialog box.

Double-clicking a Control-menu box is the same as choosing the Close command.

Note:  If you have multiple windows open for a single document, the Close command on the document Control menu closes only one window at a time.  You can close all windows at once with the Close command on the File menu.

Shortcuts

Keys: 	CTRL+F4 closes a document window

ALT+F4 closes the <<YourType>> window or dialog box


Restore command (Control menu)

Use this command to return the active window to its size and position before you chose the Maximize or Minimize command.


Switch to command (application Control menu)

Use this command to display a list of all open applications.  Use this "Task List" to switch to or close an application on the list.

Shortcut

Keys:	CTRL+ESC

Dialog Box Options

When you choose the Switch To command, you will be presented with a dialog box with the following options:

Task List

Select the application you want to switch to or close.

Switch To

Makes the selected application active.

End Task

Closes the selected application.

Cancel

Closes the Task List box.

Cascade

Arranges open applications so they overlap and you can see each title bar.  This option does not affect applications reduced to icons.

Tile

Arranges open applications into windows that do not overlap.  This option does not affect applications reduced to icons.

Arrange Icons

Arranges the icons of all minimized applications across the bottom of the screen.


View Ruler Command
Ruler command (View menu)

<< Write application-specific help here. >>


Writing Modbus Data Values
Writing Modbus Data Points

In order to write a MODBUS data point in a slave device, the communications with the device must first be initiated by scanning a series of data points by configuring the correct addressing information and initiating a polling cycle.  Once the data is successfully  displayed, double-clicking the address/value portion of the screen will initiate a dialog box which allows the value to be changed.  If the polling cycle has been configured to represent coil addresses, double-clicking an address will initiate the Change Coil Dialog:

The Change Register Dialog Box may be initiated by configuring the display to represent register data and double clicking on an address:

Register values may be written using binary, decimal, hexadecimal, or floating-point notation, depending on the preference selection currently in effect.

Pressing the Update Button in either write data point dialog will initiate the appropriate MODBUS write command, (05 or 06), during the next scheduled poll.

See Also:

Force Multiple Coils Cmd	Preset Multiple Registers Cmd


Message Status Counters

Each document maintains a counter for each query message transmitted to a modbus slave device and a counter for each correct response returned from the addresses slave.  The counters for a given document may be reset via a button control accessible via the upper, (data definition), splitter view.  A total count of all message counters from all active documents, (including any OLE Automation client documents), is displayed via the ModScan status bar.

See Also:

Upper Splitter View	Reset All Counters Cmd


Edit Find Command
Find command (Edit menu)

<< Write application-specific help here. >>


Find Dialog
Find dialog box

<< Write application-specific help here. >>


Edit Replace Command
Replace command (Edit menu)

<< Write application-specific help here. >>


Data Capture Options
Data Capture Operation

An optional feature of ModScan is its ability to capture modbus data directly into a database.  The Microsoft Jet database engine allows you to automatically update a compatible database with new data each time it is read by a ModScan document.  Included within a database, the data is easily accessible for manipulation and display of customized applications.  Even without this option, ModScan may be used to capture data to an ASCII text file , which may then be ported in an off-line fashion to your database.

See Also:

Text Capture Cmd	DBase Capture Cmd	Database Operation


Network Connections

ModScan allows modbus communications to occur over a TCP/IP network.  This feature requires the use of a modbus to TCP/IP bridge device which can service network requests from the network and obtain the data from a connected slave device prior to responding to queries from the ModScan application.  A bridge device operates as a network server, providing support to numerous client applications distributed over the network.  WinTECH Software provides such a server for interfacing to a single serial modbus network.  Third-party vendors may provide various solutions for interfacing TCP/IP to modbus devices via other hardware, (i.e. modbus plus, etc.).  If the interfacing specification for these network bridge devices is available in the public domain, they may be included in future releases of the ModScan application.  If you have the need to use ModScan with a third-party vendor’s equipment, please contact the WinTECH Software support line for consideration.


Modem Connections

In remote testing situations, the ModScan application may be used to communicate with a modbus network over a dedicated modem connection.  ModScan supports the TAPI, (telephony application interface), standard implemented in Windows and Windows NT.  If selected, the modem connection dialog allows you to enter a phone number for dialing.  Any TAPI device configured within the Windows operating system is available for use.

It is also possible to connect via modem to a remote system utilizing the built-in networking characteristics of Windows ‘95 & NT.  To do this, you will need to configure the ModScan application to connect via a TCP/IP connection which has been setup within Windows to automatically dial and establish a PPP connection with another Windows machine which is connected directly to the slave device(s) you wish to use.  In this case, ModScan operates as if it were using a network card connected directly to a modbus to tcp/ip bridge device.

See Also:

Network Connections


Connecting to a modbus network

ModScan may be used to obtain data from modbus slave device connected to the PC in one of three basic physical arrangements.  The most common connection is via any one of the four available PC serial COM ports.  ModScan uses the standard Win32 software drivers for communication with the COM ports, thereby providing support for any hardware serial boards which may be installed in the Windows operating system, (including RS-232, RS-485, etc.).  You have complete control over the operating characteristics of the serial connection by selecting the appropriate baud rate, parity, and control line, (handshaking), properties to match the slave device(s).

See Also:

Modem Connections	Network Connections


Data Display Splitter View

As data is received from the slave device, it is displayed to the lower splitter view of the associated document.  Any errors incurred during the exchange of information will be displayed on the first line.  The font and colors used to display the data is configurable via the View, Config menu options.

Modbus register data may be displayed in any of the following formats:

Binary	Data displayed as 16 discrete values.
Decimal	Ranges from -32767 to 32768
Hexadecimal	0000-ffff
Floating Point	IEEE Standard Floating Point Notation (Requires two registers per value)
Word-Swapped Floating Point	Inverted Floating Point used by some processors
Double-Precision Floating Point	64-bit Floating Point Notation
Word Swapped Dbl Precision	Inverted 64-bit Float Values


Data Definition Splitter View

The upper half of each Document’s View represents the data selected for display, (and possible capture to a historical data file).  In most testing applications, the ModScan will only be connected to a single modbus slave device, however, in a multidrop modbus network, there may be several devices accessible from a single connection.  The “Device Id” edit control allows you to specify the slave address for the source of the data.  Likewise, edit controls are available to select the point type, data address, and number of data points to access.

Notice that the modbus protocol uses a 5-digit representation for the slave data address which infers the point-type.  For example, INPUT STATUS values are always represented in the range 10001-19999: HOLDING REGISTERS are displayed as 40000-49999.  The ModScan application uses the standard notation for displaying data in the bottom splitter window, however the address specified in the upper splitter address edit control assumes a 4-digit physical point address.  This address, coupled with the point-type specifier completely defines the data to be accessed in the slave device.

The upper splitter window also contains two counters which are used to tally the number of data requests made from this document to the modbus connection and the number of valid slave responses received in reply.  A button is available within the display which resets the counters associated with this document.

See Also:

Data Definition Menu Cmd	Splitter2	Status Counters


ModScan Document/View Architecture

ModScan utilizes the standard Windows Multiple-Document-Interface, (MDI), architecture for displaying modbus data to the user.  Each document represents a series, (array), of modbus data points identified by the following parameters:

Slave Device Address	Represents the physical device attached to the modbus network
Data Type	Internal data representation, (i.e. input, coil, register)
Data Address	Point address within the device
Length	Number of points to scan/display

Associated with each document is also a timer, which is used to periodically scan new data from the defined slave and refresh the display.  The modbus data definition is accessible from the ModScan menu or via edit controls in the top splitter window of the document display.  As new data is obtained from the slave device, it is written to the bottom splitter window in one of several formats, depending upon your preference.  The size of each document display window is adjustable via the splitter control.

See Also:

modbus_protocol	Data Definition Menu Cmd	Splitter1	Splitter2


Creating Custom Displays

An optional feature of ModScan32 allows you to create custom displays to represent modbus data unique to your specific instrumentation.  A very simple screen editor is supplied which allows you to define various control and graphical items to represent data.  Items created on the form will display data as obtained from the modbus connection based on the currently defined polling frequency.  Each form is dynamic, allowing you to insert, move, modify, or delete display items as data is being refreshed from the connection.  Some of the items you can use to create your display are defined below:

Simple Text	Creates a line of text in specified color & font.
Simple Rectangle	Creates a Line or Rectangle using specified colors and fill pattern.
Modbus Discrete	Displays an INPUT STATUS or COIL STATUS as obtained from the modbus connection.
Modbus Register	Displays the current value of a modbus register or register set.
Simple BarGraph	Graphically displays the value of a modbus register as either a vertical or horizontal bargraph.
Bitmap	Displays a graphical bitmap as defined by an external disk file.
Simple TrendChart	Displays the value of one or more modbus registers over a specified period of time.

To insert one of the above items onto a form, first create a custom document by selecting the File,Custom Form, Create menu option.  Using the left mouse button, select the screen position where you wish to insert the item and drag a rectangle onto the screen.  When the mouse button is released, a dialog box should appear listing the various display items which may be included on your form.  Select the appropriate item properties to configure the item.  Once the item is inserted on the form, clicking the right mouse button while positioned over the item will allow you to modify its properties or delete the item from the display.  (A Rectangle Item must be selected by positioning the mouse cursor over the edge of the item.)  You may also re-position a displayed item by selecting it with the left mouse button and dragging the item to a new location on the display.  The following example shows a custom display using text, Registers, Rectangles, BarGraphs, and Trend Items.


Custom Display...Simple Text Item

A Simple Text item may be inserted on a custom form to display a line of text using a specified font and color combination.  The text will be displayed horizontally, left to right.  Any available font and size may be used.  If the Transparent Background property is selected, the text will be displayed using the currently defined Window background color .  Otherwise, the user must specify both foreground and background colors, as would be necessary if positioning the text on top of another display item such as a filled rectangle or bitmap.


Custom Display...Simple Rectangle Item

Rectangles and straight lines may be positioned on a custom form to enhance readability and/or dress-up a display.

The size of the rectangle may be selected in pixels by entering values for the Height and Width.  Lines may be specified using a value of one for either parameter.  Selecting the Transparent Background display property will draw a hollow rectangle using the specified border color and pen width settings.  Non-transparent rectangles may also be created by specifying an appropriate fill color.  If other display items are to be placed over a non-transparent rectangle item, the Draw First property should be selected for the rectangle such that the other items will be visible.


Custom Display...Mobus Discrete Item

The Modbus Discrete display item may be used to represent the current state of a modbus INPUT STATUS or COIL STATUS.  The display will show either a ‘1’ or ‘0’ depending upon the state of the defined status.  (A ? will appear if the data cannot be read from the specified device.)

Properties for the Modbus Discrete item define the source of the data as well as the font and colors to be used for the display.  If a modbus COIL STATUS is selected, the item may be configured as a Write Enabled control item.  In this case, a user may double-click the item while it is displayed on the form to initiate a write operation back to the connected slave device.


Custom Display...Modbus Register Item

The Modbus Register display item may be used to represent the current state of a modbus INPUT REGISTER or HOLDING REGISTER.

As with the Modbus Discrete item, the Register Item may be used to represent data obtained from a connected modbus slave device using a specified color and font combination.  A register item may also be configured as a Write Enabled control to allow the user to double-click the display to initiate a write operation to the device.  Unlike a Discrete Item, however, the Register Item may display data in a variety of formats depending upon the characteristics of the connected modbus slave device.  Data from a register may be displayed as a simple integer or hex value, or it may represent a floating-point or double-precision floating point value contained in multiple consecutively addressed registers at the remote.  The Register Item also supports the standard modbus scaled value representations 0-4095 and 0-9999.  If a scaled representation is to be used, you must specify the upper and lower range for the reading.


Custom Display...Simple Bargraph Item

The Bargraph item is analogous to a Modbus Register Item.  A value obtained from a connected modbus slave device is displayed as a simple bar chart.  Properties for the item define the fill colors to use for data representation and the orientation of the graph in addition to specifying the source of the data.

The bargraph may be displayed vertically, (filled from the bottom), or horizontally  (filled from the left).  It may be displayed with or without a border and with or without numeric representation of the high and low limits.


Custom Display...Bitmap Item

A bitmap may be added to a custom ModScan32 display.  Properties associated with the Bitmap Item reflect the source of the data, (bmp file), and the desired dimensions to be used within the custom document.  As with Rectangle Items, the Draw First property should be selected if other display items are to be shown on top of the bitmap.


Custom Display...Simple Trend Chart Item

The Trend Chart Display Item may be used on a custom display t o represent modbus register data collected over a period of time.  Up to five data values may be displayed on a single trend chart representing a timespan of 10 minutes to 24 hours.  Values entered for the timespan and the total number of points configured for the trend determine how often data is obtained from the modbus device and updated to the display.

Each data value is configured independently as to the data source, pen width and color, and the scaling limits to be used on the display.


No Help Available

No help is available for this area of the window.


Using ModScan with a database

An optional feature of ModScan32 allows you to write data directly into a Microsoft compatible database such as Access.  ModScan uses the Jet database engine to provide an efficient exchange of information from an addressed slave device into the designated database table.  Selecting the Dbase Capture menu ietm allows you to associate a ModScan document with a given database table.  The table will then be updated with new data each time the slave device is polled.  If you change the properties of the document while collection is enabled, updates to the database will temporarily cease.  Database updates will resume if the original properties are restored.

See Also:

Database table format


Database Table Format

ModScan attempts to write the modbus data associated with a particular document as a linear table consisting of the time, status code, and value for each defined point.  The table is created with the number of columns euqal to the number of points selected in the active document plus two additional fields to contain the time & date and the status code associated with each reading.  Table headers to identify each column consist of the 5-digit modbus address for each data point.  For example, a table defined to contain 5 input registers beginning at address 44 would look like:

Time	Status	30044	30045	30046	30047	30048
11/5/97  12:53 P.M.	0	0000	0001	0002	0003	0004
11/5/97  12:54 P.M.	0	0000	0001	0002	0003	0004
11/5/97  12:55 P.M.	0	0000	0001	0002	0003	0004


Database Example

The example database file, (modbus1.mdb), distributed with the ModScan32 application may be used as a reference for creation of your own particular database requirements.


Using ModScan OLE Automation Routines

An optional feature of ModScan32 is the ability to access modbus data using OLE Automation routines.  This allows custom programs to be generated, (using Visual Basic, Excel Basic, etc.,), to interpret and format data according to your specific requirements. OLE Automation routines provide both read and write access to one or more modbus slave devices through the ModScan application.

Using the OLE Automation routines is a very simple process:

The VBA application links to the ModScan32.tlb file, (Type Library), which details the names for each automation procedure and its argument list.  From the Visual Basic development framework, this is done by selecting the menu item to include a custom type library and then browsing for ModScan32.tlb.  During the initial Form Load operation, the application must call Create Object as follows:

CreateObject("ModScan32.Document")

The application then creates one or more PollRequests which define an array of data points to be read from a modbus device.  Data defined by the Poll Request will be automatically scanned by the ModScan application on a 1 second basis.  (NOTE:  The ModScan application must be connected to the modbus network prior to the VBA application starting up.)

The application uses the handle returned from the CreatePollRequest procedure to access, (read or write), a value within the defined array.

During application termination, it must free the memory used by the ModScan application to maintain the data points by deleting any Poll Requests created.

Refer to the Visual Basic Example application included with the ModScan distribution files for additional details.


Automation Routines

The following OLE Automation routines are supported by ModScan32:

short CreatePollRequest (short Device, long Address, short Length)

Arguments:

Device - Specifies the slave device address

Address - Specifies the data point address,(in modbus master  (5 digit) format.

coil status addresses: 	00000-09999

input status addresses: 	10000-19999

input register addresses: 	30000-39999

holding register addresses: 	40000-49999

Length - Specifies the number of values included in the definition

Return Value:

Point Handle - Defines the array structure for future reads & writes

Notes:

Sets up data structures within ModScan to begin polling the specified data.  ModScan must be connected to the modbus network prior to creating the data array.  CreatePollRequest returns a non-zero value if the data structure was successfully created, otherwise it returns 0.

short CreatePollRequest2 (short Device, short cmd, short Address, short Length)

Arguments:

Device - Specifies the slave device address

Cmd – Specifies the modbus command

01 – coil status

02 – input status

03 – holding registers

04 – input registers

Address - Specifies the data point address, (0-65535)

Length - Specifies the number of values included in the definition

Return Value:

Point Handle - Defines the array structure for future reads & writes

Notes:

Sets up data structures within ModScan to begin polling the specified data.  ModScan must be connected to the modbus network prior to creating the data array.  CreatePollRequest returns a non-zero value if the data structure was successfully created, otherwise it returns 0.

short ReadValue (short PointHandle, short Index, short  *pValue)

Arguments:

Point Handle -  refers to value returned from CreatePollRequest

Index - Specifies the index into the array structure

*pValue - is a pointer to a value to be returned.

Return Value:

Status - indicates whether or not the operation was completed successfully

Notes:

Status will be MBUS_OK, (0), if the data point was successfully read, otherwise, a  non-zero value indicates one of the defined error conditions.

short WriteValue (short PointHandle, short Index, short  Value)

Arguments:

Point Handle -  refers to value returned from CreatePollRequest

Index - Specifies the index into the array structure

Value - is the data to be written.

Return Value:

Status - indicates whether or not the operation was completed successfully

Notes:

Status will be MBUS_OK, (0), if the data point was successfully queued for transmission to the addresses slave.  A zero return value does not indicate successful transmission of the request to the slave device.  The controlling application is responsible for verifying the write operation by reading back the value written.

short ReadFloat (short PointHandle, short Index, float  *pValue)

Arguments:

Point Handle -  refers to value returned from CreatePollRequest

Index - Specifies the index into the array structure.  The Index must be specified with respect to the 16-bit register array, not the 32-bit float array.  (i.e. index would be 3 to address the 2’nd floating point value in a register array, register[3] = float[1]).

*pValue - is a pointer to a value to be returned.

Return Value:

Status - indicates whether or not the operation was completed successfully

Notes:

Status will be MBUS_OK, (0), if the data point was successfully read, otherwise, a  non-zero value float

ReadWSFloat (short PointHandle, short Index, float *pValue)

Arguments:

Point Handle -  refers to value returned from CreatePollRequest

Index - Specifies the index into the array structure.  The Index must be specified with respect to the 16-bit register array, not the 32-bit float array.  (i.e. index would be 3 to address the 2’nd floating point value in a register array, register[3] = float[1]).

*pValue - is a pointer to a value to be returned.

Return Value:

Status - indicates whether or not the operation was completed successfully

Notes:

Status will be MBUS_OK, (0), if the data point was successfully read, otherwise, a  non-zero value float

ReadWSFloat swaps the order of the specified registers to create the floating point value.

WriteFloat (short PointHandle, short Index, float  Value)

Arguments:

Point Handle -  refers to value returned from CreatePollRequest

Index - Specifies the index into the array structure.  The Index must be specified with respect to the 16-bit register array, not the 32-bit float array.  (i.e. index would be 3 to address the 2’nd floating point value in a register array, register[3] = float[1]).

Value - is the data to be written.

Return Value:

Status - indicates whether or not the operation was completed successfully

Notes:

Status will be MBUS_OK, (0), if the data point was successfully queued for transmission to the addresses slave.  A zero return value does not indicate successful transmission of the request to the slave device.  The controlling application is responsible for verifying the write operation by reading back the value written.

WriteWSFloat (short PointHandle, short Index, float  Value)

Arguments:

Point Handle -  refers to value returned from CreatePollRequest

Index - Specifies the index into the array structure.  The Index must be specified with respect to the 16-bit register array, not the 32-bit float array.  (i.e. index would be 3 to address the 2’nd floating point value in a register array, register[3] = float[1]).

Value - is the data to be written.

Return Value:

Status - indicates whether or not the operation was completed successfully

Notes:

Status will be MBUS_OK, (0), if the data point was successfully queued for transmission to the addresses slave.  A zero return value does not indicate successful transmission of the request to the slave device.  The controlling application is responsible for verifying the write operation by reading back.  WriteWSFloat uses word-swapped notation to write the specified registers to the slave.

short ModifyPollRequest (short PointHandle, short Device, long Address, short Length)

Arguments:

Point Handle -  refers to value returned from CreatePollRequest

Device - Specifies the new slave device address

Address - Specifies the new data point address,(in modbus master  (5 digit) format.

Length - Specifies the number of values included in the definition

Return Value:

Status will be MBUS_OK, (0), if the data point was successfully modified, otherwise, a  non-zero value indicates one of the defined error conditions.

Notes:

Immediately after changing the parameters of a defined data point, the current status of each value in the array will be set to MBUS_UNINITIALIZED, indicating that the data does not represent that defined by the device/address definition.  The first poll after modification should reflect the true status of the addressed data array.

short DeletePollRequest (short PointHandle)

Arguments:

Point Handle -  refers to value returned from CreatePollRequest

Return Value:

Status will be MBUS_OK, (0), if the data point was successfully modified, otherwise, a  non-zero value indicates one of the defined error conditions.

Notes:

This routine frees up memory allocated by ModScan to support the defined Poll Request.


ModScan OLE Automation Error Return Values

The following status codes may be returned from the ModScan application in response to an OLE Automation request:

1-255	Modbus Exception Message as returned from slave device.
256	Invalid Data Point Handle
257	reserved
258	Invalid Data Point Address
259	reserved
260	reserved
261	reserved
262	Out-Of-Memory
263	Time-Out, (Data not received from slave)
264	reserved
265	Invalid checksum in response from slave
266	ModScan not connected to modbus network
267	reserved
268	reserved
269	Remote TCP/IP Server not connected
270	Data Uninitialized, (Values not valid)
271	ModScan Demo Time Expired


Visual Basic Example

The example Visual Basic application included with the ModScan32 distribution files is a simple take-off on the ModScan application itself.  The Form creates four array points, (one each for inputs, coils, input registers, and holding registers).  A timer is used to read and update the data once per second.  Edit controls are used to define the addresses as shown below:

Code for the example follows:

Public m_svr As IModSca

Dim PollHandle(4) As Integer	‘Handle for each of the four array points

Dim status(4) As Integer	‘Status return value for each ReadValue request

Dim SlaveDevice As Integer	‘All points use same slave address

Dim StartAddress(4) As Long	‘starting address for each array

Dim Modbus_Id(4) As Long	‘ prefix for selected address

Dim Counter As Integer

Dim temp As Integer

Dim Modbus_Addr As Long	‘qualified 5-digit modbus address

Private Sub coiladdress_Change()

‘

‘ User has changed address for coil array

‘ recalculate 5-digit modbus address

‘ and ModifyPollRequest accordingly

‘

If (IsNumeric(coiladdress.Text)) Then

    StartAddress(1) = coiladdress.Text

    Modbus_Addr = Modbus_Id(1) + StartAddress(1)

    status(1) = m_svr.ModifyPollRequest(PollHandle(1), SlaveDevice, Modbus_Addr, 10)

    StatusMsg (status(1))

End If

End Sub

Private Sub Device_Change()

‘

‘ User has changed slave device

‘ Modify all four PollRequests

‘

If (IsNumeric(Device.Text)) Then

    SlaveDevice = Device.Text

    Modbus_Addr = Modbus_Id(0) + StartAddress(0)

    temp = m_svr.ModifyPollRequest(PollHandle(0), SlaveDevice, Modbus_Addr, 10)

    Modbus_Addr = Modbus_Id(1) + StartAddress(1)

    temp = m_svr.ModifyPollRequest(PollHandle(1), SlaveDevice, Modbus_Addr, 10)

    Modbus_Addr = Modbus_Id(2) + StartAddress(2)

    temp = m_svr.ModifyPollRequest(PollHandle(2), SlaveDevice, Modbus_Addr, 10)

    Modbus_Addr = Modbus_Id(3) + StartAddress(3)

    temp = m_svr.ModifyPollRequest(PollHandle(3), SlaveDevice, Modbus_Addr, 10)

End If

End Sub

Private Sub Form_Load()

‘

‘ Create the ModScan interface object

‘

Set m_svr = CreateObject("ModScan32.Document")

Modbus_Id(0) = 10000   'input status prefix

Modbus_Id(1) = 0        'coil status prefix

Modbus_Id(2) = 30000    'input register prefix

Modbus_Id(3) = 40000    'holding register prefix

‘

‘ create the four PollRequests using

‘ default values

‘

SlaveDevice = 1

For Counter = 0 To 3

    StartAddress(Counter) = 1

    Modbus_Addr = Modbus_Id(Counter) + StartAddress(Counter)

    PollHandle(Counter) = m_svr.CreatePollRequest(SlaveDevice, Modbus_Addr, 10)

   Next Counter

statusline = "** UNINITIALIZED **"

End Sub

Private Sub Form_Terminate()

‘

‘ Free allocated resources

‘

For Counter = 0 To 4

    m_svr.DeletePollRequest (PollHandle(Counter))

    Next Counter

End Sub

Public Sub StatusMsg(Index As Integer)

‘

‘ Generate text status message

‘

If Index = 0 Then statusline = ""

If Index > 0 And Index < 256 Then statusline = "Slave Device Exception Response"

If Index = 256 Then statusline = "Invalid Handle"

If Index = 257 Then statusline = "Modbus Message Overrun"

If Index = 258 Then statusline = "Invalid Address"

If Index = 259 Then statusline = "Invalid Device Address"

If Index = 260 Then statusline = "Invalid Length Specification"

If Index = 261 Then statusline = "Invalid modbus command"

If Index = 262 Then statusline = "Driver Out-Of-Memory"

If Index = 263 Then statusline = "** Time-Out **"

If Index = 264 Then statusline = "Invalid Protocol Specification"

If Index = 265 Then statusline = "** Bad Checksum **"

If Index = 266 Then statusline = "Server NOT Connected"

If Index = 267 Then statusline = "Invalid Response from Driver"

If Index = 268 Then statusline = "Modbus Write Failure"

If Index = 269 Then statusline = "Remote Server not Connected"

If Index = 270 Then statusline = "** UNINITIALIZED **"

If Index = 271 Then statusline = "ModScan Demo Time Expired"

End Sub

Private Sub holdingregsaddress_Change()

‘

‘ User has changed address for holding registeres

‘

If (IsNumeric(holdingregsaddress.Text)) Then

    StartAddress(3) = holdingregsaddress.Text

    Modbus_Addr = Modbus_Id(3) + StartAddress(3)

    status(3) = m_svr.ModifyPollRequest(PollHandle(3), SlaveDevice, Modbus_Addr, 10)

    StatusMsg (status(3))

End If

End Sub

Private Sub inputaddress_Change()

‘

‘ User has changed starting address for

‘ input status points

‘

If (IsNumeric(inputaddress.Text)) Then

    StartAddress(0) = inputaddress.Text

    Modbus_Addr = Modbus_Id(0) + StartAddress(0)

    status(0) = m_svr.ModifyPollRequest(PollHandle(0), SlaveDevice, Modbus_Addr, 10)

    StatusMsg (status(0))

End If

End Sub

Private Sub inregsaddress_Change()

‘

‘ User has changed input register address

‘

If (IsNumeric(inregsaddress.Text)) Then

    StartAddress(2) = inregsaddress.Text

    Modbus_Addr = Modbus_Id(2) + StartAddress(2)

    status(2) = m_svr.ModifyPollRequest(PollHandle(2), SlaveDevice, Modbus_Addr, 10)

    StatusMsg (status(2))

End If

End Sub

Private Sub Timer1_Timer()

‘

‘ Each secon read and update all 10 values

‘ in each of th efour arrays

‘

For Counter = 0 To 9

    status(0) = m_svr.ReadValue(PollHandle(0), Counter, temp)

    StatusMsg (status(0))

If temp = 0 Then

    inputstatus(Counter).Value = 0

    Else

    inputstatus(Counter).Value = 1

    End If

Next Counter

For Counter = 0 To 9

    status(1) = m_svr.ReadValue(PollHandle(1), Counter, temp)

    StatusMsg (status(1))

If temp = 0 Then

    coilstatus(Counter).Value = 0

    Else

    coilstatus(Counter).Value = 1

    End If

Next Counter

For Counter = 0 To 9

    status(2) = m_svr.ReadValue(PollHandle(2), Counter, temp)

    StatusMsg (status(2))

    inputreg(Counter).Caption = temp

Next Counter

For Counter = 0 To 9

    status(3) = m_svr.ReadValue(PollHandle(3), Counter, temp)

    StatusMsg (status(3))

    holdingreg(Counter).Caption = temp

Next Counter

End Sub


 #ModScan Registration Details

ModScan is a time-limited demo application which allows you to connect up to a modbus network and evaluate its operation without cost or obligation.  ModScan is designed to allow unrestricted use for a period of 3 1/2 minutes after successful communication is established with a slave device.  During this time, all features, including OLE and database support are active.  At the end of the demo period, ModScan will cease updating the views associated with each document.  You must restart the application to resume operation.

The introductory registration price for the ModScan32 application is $64.95.  Options to allow interfacing data to a database and/or OLE are additional. You may print an order form by selecting a button control within the ModScan About box.

For the latest pricing and availability details, please refer to the WinTECH Software Web-Site at

http://www.win-tech.com

Questions about this application should be addressed to WinTECH Software.


Licensing Information

ModScan32 is distributed as a shareware/demo-ware application which may be freely distributed without charge to prospective users.  Time limits and registration reminder screens are utilized to encourage registration.  If you find this application useful, please refer it to your associates in the hope that they too may be able to use it.

If you choose to register this application, you will receive a license certificate with access codes which will remove all program restrictions when entered into the initial sign-on dialog box.  You will only need to enter the registration codes once.  A single-user license allows the purchaser to use the application on as many different machines as desired, so long as there is only one copy of the application running at any given time.  Running multiple instances of the application on different machines at the same time is a violation of the copyright owned by WinTECH Software.   Multiple-User and Site-licenses are available for installations which require multiple simultaneous use of the ModScan application.


Contact Information

For the latest product and pricing information, please refer to the WinTECH Software Web-Site at:

http://www.win-tech.com

For technical support, please e-mail:

support@win-tech.com

To place an order, fax to:

1-304-645-5966

or mail:

WinTECH Software

P.O. Box 907

Lewisburg, WV  24901

U.S.A.


Product Information

WinTECH Software offers the following products and services which may be of interest:

Modbus Driver Dll’s

Windows drivers are available to support either the modbus master or modbus slave protocol on a PC.  These drivers are written in ‘C’.  They are available in either 16 or 32-bit designs and include all modbus message formatting and interaction with the Windows serial drivers.  A simple API is made available to your application, which greatly simplifies its design and allows you to very easily implement a custom modbus design under Windows.  Each driver is very reasonably priced, and comes with a sample Windows application written in the Microsoft MFC.

ModSim Windows Application

ModSim is the counterpart to ModScan and simulates the slave end of the modbus protocol.  ModSim allows you to define a series of data points, (representing one or more slave devices), and provides this data to an attached modbus master application.

MNetSvr Windows Application

MNetSvr is a Windows application which serves as a Modbus to TCP/IP gateway device for interfacing serial modbus slave devices to plant networks.  MNetSvr utilizes the MBAP protocol standard, (Modbus Application Programming Interface), to service multiple Modbus Master Client applications requesting data from one or more slaves.

Listen Windows Application

Listen is a fully functional serial data link monitor, (datascope), which allows you to watch data traffic in real time as it travels in two directions between communicating devices. Listen is highly customizable in the way it displays data and uses standard COM drivers for compatibility with any serial hardware configurable under Windows.

 Socket Spy Windows Application

The Socket Spy allows you to monitor TCP/IP packets transferred between a Windows application and the Windows Sockets dll.  Designed as a design and trouble-shooting aide for communications developers, Socket Spy provides full debugging data relative to all sockets activity occurring within the target application.


No Help Available

No help is available for this message box.

<< If you wish to author help specific to each message box prompt, then remove the AFX_HIDP_xxx values from the [ALIAS] section of your .HPJ file, and author a topic for each AFX_HIDP_xxx value.  For example, AFX_HIDP_INVALID_FILENAME is the help topic for the Invalid Filename message box. >>


File Print command
Print command (File menu)

Use this command to print a document.   This command presents a Print dialog box, where you may specify the range of pages to be printed, the number of copies, the destination printer, and other printer setup options.

Shortcuts

Toolbar:

Keys:	CTRL+P


Print dialog box

The following options allow you to specify how the document should be printed:

Printer

This is the active printer and printer connection.  Choose the Setup option to change the printer and printer connection.

Setup

Displays a Print Setup dialog box, so  you can select a printer and printer connection.

Print Range

Specify the pages you want to print:

All	Prints the entire document.
Selection	Prints the currently selected text.
Pages	Prints the range of pages you specify in the From and To boxes.
Copies

Specify the number of copies you want to print for the above page range.

Collate Copies

Prints copies in page number order, instead of separated multiple copies of each page.

Print Quality

Select the quality of the printing.  Generally, lower quality printing takes less time to produce.


Print Progress Dialog

The Printing dialog box is shown during the time that <<YourApp>> is sending output to the printer.  The page number indicates the progress of the printing.

To abort printing, choose Cancel.


File Print Preview command
Print Preview command (File menu)

Use this command to display the active document as it would appear when printed.  When you choose this command, the main window will be replaced with a print preview window in which one or two pages will be displayed in their printed format.  The print preview toolbar offers you options to view either one or two pages at a time; move back and forth through the document; zoom in and out of pages; and initiate a print job.


Print Preview toolbar

The print preview toolbar offers you the following options:

Print

Bring up the print dialog box, to start a print job.

Next Page

Preview the next printed page.

Prev Page

Preview the previous printed page.

One Page / Two Page

Preview one or two printed pages at a time.

Zoom In

Take a closer look at the printed page.

Zoom Out

Take a larger look at the printed page.

Close

Return from print preview to the editing window.


File Print Setup command
Print Setup command (File menu)

Use this command to select a printer and a printer connection.  This command presents a Print Setup dialog box, where you specify the printer and its connection.


Print Setup dialog box

The following options allow you to select the destination printer and its connection.

Printer

Select the printer you want to use.  Choose the Default Printer; or choose the Specific Printer option and select one of the current installed printers shown in the box.  You install printers and configure ports using the Windows Control Panel.

Orientation

Choose Portrait or Landscape.

Paper Size

Select the size of paper that the document is to be printed on.

Paper Source

Some printers offer multiple trays for different paper sources.  Specify the tray here.

Options

Displays a dialog box where you can make additional choices about printing, specific to the type of printer you have selected.

Network...

Choose this button to connect to a network location, assigning it a new drive letter.


File Page Setup Command
Page Setup command (File menu)

<< Write application-specific help here. >>