 ModSim32 Help Index

Modbus Reference

Protocol

Messages

Error Detection

Exception Responses

ModSim32 Overview

Basic Operation

Document/View Architecture

Modbus Data Definition

Display Formats

Connections

Menu Commands

File menu

Connection menu

Display menu

Window menu

Help menu

Using OLE Automation

Automation Routines

Registration Information

Pricing Details

Licensing Info

Contact Information

Other Products


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 ModSim32 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


ModSim Basic Operation
ModSim32 Overview

ModSim32 is a Windows Application designed to simulate data from one or more modbus slave devices.  ModSim32 may be connected serially to a modbus master application, or connected to multiple modbus master client applications via a network.  Modbus supports the MBAP, (Modbus Applications Programming Interface), communications protocol standard for network communications.

ModSim32 operates as a Windows MDI, (Multiple Document Interface), application, with each document representing a block of modbus data.  Each data block is configured to represent a series of data, (inputs, coils, input registers, or holding registers), from a defined slave address.  Keyboard commands are available to edit the contents of a data point and OLE Automation routines are supported which allows Visual Basic or other third-party Windows applications to easily access and change simulated modbus data.


File menu commands

The File menu offers the following commands:

New	Creates a new document.
Open	Opens an existing document.
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.
Save Test Config	Saves each open document and creates a test configuration file.
Restore Test Config	Restores a previously saved test configuration, (i.e. opens each document file).
Exit	Exits ModSim32.


Connection menu commands

The Connection menu offers the following commands for configuring each of the four COM ports and starting and stopping the MBAP Network Server:

Connect
Port 1	Allows you to configure COM Port 1.
Port 2	Allows you to configure COM Port 2.
Port 3	Allows you to configure COM Port 3.
Port 4	Allows you to configure COM Port 4.
MBAP Svr	Enables ModSim32 to operate as a mobus network server
Dosconnect
Port 1	Disables communication via COM Port 1
Port 2	Disables communication via COM Port 2
Port 3	Disables communication via COM Port 3
Port 4	Disables communication via COM Port 4
MBAP Svr	Shuts down the network server

The configuration dislog box used to connect a PC COM port allows you to select the baud rate, parity, and protcol selections as follows:


Display menu commands

The Display menu allows you to define the numerical format used to display modbus register data:

Binary	Displays data as a series of 16 discrete values.
Decimal	Displays data as a decimal number in the range -32767 to 32768
Hex	Displays data in hexadecimal (0000-ffff)
Floating Point	Displays data as a floating-point value using the lowest addressed register as the most significant 16-bits of data.
Float (Swapped)	Displays data as a floating-point value using the highest addressed register as the most significant 16-bits of data.


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.
Window 1, 2, ...	Goes to specified window.


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 ModSim32.

You can open an existing document with the Open command.

Shortcuts

Toolbar:

Keys:	CTRL+N


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 ModSim32 stores the file that you want to open.

Directories

Select the directory in which ModSim32 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 all windows containing the active document.  ModSim32 suggests that you save changes to your document 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, ModSim32 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, ModSim32 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.  ModSim32 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.


Save Test Config command (File menu)

Use this command to save each open document and create a test configuration file which may be later restored.  If an open document has not been previously saved to disk, ModSim32 will prompt you for a file name under which to save the document.  The test configuration file which is created contains the name of each document and may be used to automatically reopen each one during the Restore Test Config command.


Restore Test Config command (File menu)

Use this command to restore a previously saved test configuration.  Each document which was open during the corresponding save operation will be reopened and associated with a modbus connection.


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.  <<YourApp>> 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.

<< Add other File Save As dialog box options depending on which ones your application chooses via the OFN_ flags of the OPENFILENAME structure used by the CFileDialog. >>


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 ModSim32 session.  You can also use the Close command on the application Control menu.  ModSim32 prompts you to save documents with unsaved changes.

Shortcuts

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

Keys:	ALT+F4


Undo/Can't Undo command (Edit menu)

<< Your application's user interface for Undo may differ from the one described below.  Modify this help text accordingly. >>

Use this command to reverse the last editing action, if possible.   The name of the command changes, depending on what the last action was.  The Undo command changes to Can't Undo on the menu if you cannot reverse your last action.

Shortcuts

Toolbar:

Keys:	CTRL+Z or

ALT-BACKSPACE


Redo command (Edit menu)

<< Write application-specific help here. >>


Cut command (Edit menu)

Use this command to remove the currently selected data from the document and put it on the clipboard.  This command is unavailable if there is no data currently selected.

Cutting data to the clipboard replaces the contents previously stored there.

Shortcuts

Toolbar:

Keys:	CTRL+X


Copy command (Edit menu)

Use this command to copy selected data onto the clipboard.  This command is unavailable if there is no data currently selected.

Copying data to the clipboard replaces the contents previously stored there.

Shortcuts

Toolbar:

Keys:	CTRL+C


Paste command (Edit menu)

Use this command to insert a copy of the clipboard contents at the insertion point.  This command is unavailable if the clipboard is empty.

Shortcuts

Toolbar:

Keys:	CTRL+V


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 <<YourApp>>, 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.


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 <<YourApp>>,

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

<< Add or remove toolbar buttons from the list below according to which ones your application offers. >>

Click	To

Open a new document.

Open an existing document.  <<YourApp>> 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, <<YourApp>> displays the Save As dialog box.

Print the active document.

Remove selected data from the document and stores it on the clipboard.

Copy the selection to the clipboard.

Insert the contents of the clipboard at the insertion point.

Reverse the last editing.  Note:  You cannot undo some actions.

Go to the first record in the current selection.

Go to the previous record in the current selection.

Go to the next record in the current selection.

Go to the last record in the current selection.


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, and keyboard latch state. 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 <<YourApp>> 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 which of the following keys are latched down:

Indicator	Description

CAP	The Caps Lock key is latched down.

NUM	The Num Lock key is latched down.

SCRL	The Scroll Lock key is latched down.


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)

<<YourApp>> 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 <<YourApp>> 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 ModSim32.


Help Using Help Command
Context Help command

Use the Context Help command to obtain help on some portion of ModSim32.  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 ModSim32 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


Scroll bars

Displayed at the right and bottom edges of the document window.  The scroll boxes inside the scroll bars indicate your vertical and horizontal location in the document.  You can use the mouse to scroll to other parts of the document.

<< Describe the actions of the various parts of the scrollbar, according to how they behave in your application. >>


Size command (System menu)

Use this command to display a four-headed arrow so you can size the active window with the arrow keys.

After the pointer changes to the four-headed arrow:

1.	Press one of the DIRECTION keys (left, right, up, or down arrow key) to move the pointer to the border you want to move.

2.	Press a DIRECTION key to move the border.

3.	Press ENTER when the window is the size you want.

Note:  This command is unavailable if you maximize the window.

Shortcut

Mouse:	Drag the size bars at the corners or edges of the window.


Move command (Control menu)

Use this command to display a four-headed arrow so you can move the active window or dialog box with the arrow keys.

Note:  This command is unavailable if you maximize the window.

Shortcut

Keys:	CTRL+F7


System Minimize Command
Minimize command (application Control menu)

Use this command to reduce the <<YourApp>> 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.


Next Window command (document Control menu)

Use this command to switch to the next open document window.  <<YourApp>> determines which window is next according to the order in which you opened the windows.

Shortcut

Keys:	CTRL+F6


Previous Window command (document Control menu)

Use this command to switch to the previous open document window.  <<YourApp>> 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. >>


Choose Font Dialog
Choose Font dialog box

<< Write application-specific help here. >>


Choose Color Dialog
Choose Color dialog box

<< Write application-specific help here. >>


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. >>


Replace Dialog
Replace dialog box

<< Write application-specific help here. >>


Edit Repeat Command
Repeat command (Edit menu)

Use this command to repeat the last editing command carried out.  The Repeat menu item changes to Can't Repeat if you cannot repeat your last action.

Shortcut

Key:	F4


Edit Clear Command
Clear command (Edit menu)

<< Write application-specific help here. >>


Edit Clear All
Clear All command (Edit menu)

<< Write application-specific help here. >>


Next Pane Command
Next Pane

<< Write application-specific help here. >>


Prev Pane Command
Prev Pane

<< Write application-specific help here. >>


Document/View Architecture

Each ModSim32 document represents a block of data points made accessible to a modbus master application via the serial port or network.  Each data block is defined  as an array of coils or registers beginning at a specified modbus address and representing data contained within a single modbus slave device.  Multiple documents may be opened, defining additional data from the same or different device.  ModSim32 supports multiple simultaneous communication with modbus masters, and each document is assessible via any connected COM port or network connection.

Standard Windows menu selections are used to manipulate ModSim32 documents.  These include commands to create new  documents, write document data to disk, and read data from a disk file.  Modbus data is displayed in a variety of numerical formats, and edit commands are supported which allow access to and modification of data contained within a ModSim32 document.


Modbus Data Definition

Each ModSim32 document represents a block of contiguous modbus data as defined by the following parameters:

Device Id	Defines the physical modbus slave device represented by the document.
Point Type	Defines one of: INPUT STATUS COIL STATUS INPUT REGISTER HOLDING REGISTER
Address	Defines the modbus address of the first document data point.
Length	Defines the length of the data array contained within the document

Edit controls accessible from within each ModSim32 document  provide access to the above data definition parameters as well as the physical connection associated with the data.


Modbus Data Display

Input Status and Coil Status values are represented within a ModSim32 document as either 1 or 0.   Register values may be displayed in binary, decimal, hexadecimal, or floating-point notation.  Floating-point representation uses the contents of two consequtive 16-bit registers to assemble one 32-bit IEEE floating-point value.  ModSim32 can store a floating point value withe the most-significant 16-bits of data in the low-order register address or the high-order register address.

Using the mouse to double-click on a displayed value will present a dialog box which allows you to edit the contents of the data point.


Connecting to a Modbus Master

Menu commands are available which allow you to define the characteristics of a serial connection to your modbus network.  ModSim32 supports physical baud rates up to 19.2K and may be used to simulate data using either the RTU or ASCII transmission modes.  ModSim32 supports multiple simultaneous connections, and each document is accessible to multiple connections.  ModSim32 may also be used to simulate an MBAP modbus network server by selecting the appropriate command under the Connect menu.


OLE Automation Routines

ModSim32 supports OLE Automation functions which may be used to customize it’s operation for automated testing applications.  Using Visual Basic or similar Windows OLE Automation Client, the user can access and modify modbus data points defined within a ModSim32 document.

short ReadPoint (short NodeAddress, long PointAddress, short  *pValue)

Arguments:

Node Address -  refers to slave address associated with a ModSim32 document.

PointAddress - Specifies the address of the data point to be read,

(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

*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 that the value could not be located.

Short WritePoint (short NodeAddress, long PointAddress, short  Value)

Arguments:

Node Address -  refers to slave address associated with a ModSim32 document.

PointAddress - Specifies the address of the data point to be read,

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 written, otherwise non-zero.

short ReadPointEx (short NodeAddress, short PointType, short PointAddress, short  *pValue)

Arguments:

Node Address -  refers to slave address associated with a ModSim32 document.

PointType - Specifies the modbus data type

coil status:	1

input status: 	2

holding register: 	3

input register: 	4

PointAddress - Specifies the address of the data point in the range 0-65535.

*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 that the value could not be located.

Short WritePointEx (short NodeAddress, short PointType, short PointAddress, short  Value)

Arguments:

Node Address -  refers to slave address associated with a ModSim32 document.

PointType - Specifies the modbus data type

PointAddress - Specifies the address of the data point to be read,

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 written, otherwise non-zero.

short ReadFloat (short NodeAddress, long PointAddress, float  *pValue, BOOL Swap)

short ReadFloatEx (short NodeAddress, short PointType, short PointAddress, float  *pValue,

BOOL Swap)

Arguments:

Node Address -  refers to slave address associated with a ModSim32 document.

PointType - Specifies the modbus data type

PointAddress - Specifies the address of the data point to be read,

*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 that the value could not be located.

Short WriteFloat (short NodeAddress, long PointAddress, float  Value, BOOL Swap)

Short WriteFloatEx (short NodeAddress, short PointType, short PointAddress, float  Value,

BOOL Swap)

Arguments:

Node Address -  refers to slave address associated with a ModSim32 document.

PointType - Specifies the modbus data type

PointAddress - Specifies the address of the data point to be read,

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 written, otherwise non-zero.

An example Visual Basic project is included with the ModSim32 distribution files which demonstrates how to access/modify data points contained within a ModSim32 document.  The example project simply updates a holding register based on a one second timer and updates a text control on the form.

Use the Project Framework to Browse for ModSim32.tlb

In the General Definitions:

Public m_sim As IModSim

In Form Load

Set m_sim = CreateObject("ModSim32.Document")

On 1 sec Timer

status = m_sim.WritePoint (1, 40100, tick)

tick = tick + 1

status = m_sim.ReadPoint (1, 40100, temp)

text1.text = temp


No Help Available

No help is available for this area of the window.


ModSim32 Registration Details

ModSim32 is a time-limited demo application which allows you to connect up to a modbus network and evaluate its operation without cost or obligation.  ModSim32 is designed to allow unrestricted use for a period of 3 1/2 minutes after successful communication is established with a MBAP client device.  During this time, all features, including OLE Automation are active.  At the end of the demo period, ModSim32 will terminate the TCP connection.

The introductory registration price for the ModSim32 application is $64.95.  Current users of the 16-bit ModSim32 application may upgrade for only $15.00. You may print an order form by selecting a button control within the ModSim32 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

ModSim32 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 ModSim32 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.

ModScan32 Windows Application

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.

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. >>