1. How To Use Modscan 64
  2. How To Use Modscan
  • Modpoll is a command line based Modbus master simulator and test utility. Modpoll is using the FieldTalk ™ Modbus driver. Modpoll binaries are available for the following systems: Apr 24, 2017 Data transfer through RS485 between Modscan and modsim with to ports of one PC.
  • We use Modscan as testing software (free from the Web) and always manage to connect, if our cabling is correct, and if the communication port of the slave is powered and configured properly. Just make sure that comm parameters are set to the same values on the master and the slave (baudrate, number of charaters, parity very important, number of stop characters)and that Modbus telegrams are enabled on your master.
  • ModSim32 is a very simple but powerful application for simulating data from modbus.
  • Set-up Modscan tool. If you want to simulate the data center to send out the polling with Modbus TCP 11 1st. Click “Connection” and “Connect” 2nd. To select “Remote TCP/IP Server” =IP Address: Fill in the IP of Modbus gateway 3rd. Service Port: 502 (Default setting of Modbus) 4th.

According to Modscan picture you query Word data type, but you have configured Real Data Type under PLC Connect. You need to define your type as Integer under PLC Connect. If you want to use 32bit Float data type, you also need to define your address as HRAxxxx,REAL for floats.

Did you know that you can turn your Campbell Scientific data logger into a Modbus TCP/IP slave? Do you know why that’s a good idea? Campbell Scientific data loggers are commonly used as Modbus slave devices. This means that the data logger is configured to implement the Modbus communications protocol and listen for Modbus polls from a Modbus Master, such as a SCADA (supervisory control and data acquisition) system. Turning your data logger into a Modbus TCP/IP slave is a great way to allow systems that use the Modbus protocol to have access to your live measurement data.

To better understand how this works, we’ll go through an example exercise to show the basic concepts of how to implement the Modbus protocol on a CR1000 datalogger. We’ll use a CR1000 datalogger connected to a SCADA system. You may remember our previous discussion about SCADA systems and Modbus from the “Why Modbus Matters: An Introduction” blog article.

Getting Started

In our example, the CR1000 is programmed to measure battery voltage, panel temperature, and an analog measurement in a simple program as shown below:

Modbus Programming

The CR1000 datalogger in our example is connected to a SCADA system using an NL121 Ethernet Interface. Therefore, we need to program our data logger to listen to Modbus polls on the appropriate communications port and to respond with our most current measured data. To do this, we need to use the ModbusSlave() instruction, declare a variable array to hold our Modbus data, and then update that array with our measurements.

This is accomplished using the code below:

A Closer Look

Let’s take a closer look at the ModbusSlave() instruction we added to the program code. The instruction is added between the BeginProg and Scan statements. The ModbusSlave() instruction is placed between these two statements because it only needs to execute once at compile time rather than being executed during each scan.

The ModbusSlave() instruction contains six parameters as shown below:

For reference, in our program code, our instruction with the parameters looks like this:

Let’s take a closer look at those parameters and what they mean:

  • COMPort: This parameter defines the communications port over which the data logger listens for Modbus polls. In our example, we use 502, because we are using an Ethernet connection and 502 is the default Modbus TCP port.
  • BaudRate: We use this parameter to set the baud rate of the communications port. In our example, this parameter (0) is ignored because our communications are over an Ethernet connection.
  • ModbusAddr: This parameter sets the Modbus address (or device ID) of the data logger. In our example, we set our data logger to have an address of 1.
  • ModbusVariable: We use this parameter to define the Modbus Register Map of our data logger. (A Modbus Map defines the register addresses for the available data.)
    Measurements stored in this array are used as Modbus Input and Holding registers. (A register is a 16-bit memory location.) The data logger does not distinguish between input and holding registers. Because we have declared our ModbusVariable as a floating point number (32 bits), it will be spread across two Modbus Registers (16 bits in each). In our example, our Modbus Map looks like this:
    Modbus RegistersMeasurement DescriptionUnits

    1,2

    Data Logger Panel Temperature

    Degrees Celsius

    3,4

    Data Logger Battery Voltage

    Volts

    5,6

    Analog Measurement

    Millivolts

  • ModbusBooleanVar: This parameter is used to define a Modbus Coil Map and holds the result if a Modbus master device sends a discrete on/off command to the data logger (that is, 01 Read Coil/Port Status, 02 Read Input Status, 05 Force Single Coil/Port, 15 Force Multiple Coils/Ports).
    If a 0 is entered for this parameter, the discrete commands are mapped to the data logger control ports C1 to C8, and a compile warning is generated. In our example, I have created a variable to act as a coil.
  • ModbusOption: This is an optional parameter that defines the data type of the Modbus variables and the byte order. In our example, I have chosen to format our Modbus Map floating point variables with the byte order ABCD.

Conclusion

The example exercise above outlines how you can accomplish a simple Modbus TCP/IP slave implementation by programming a CR1000 datalogger in CRBasic. Please note that the Short Cut program generator also has the capability to generate the code we have discussed above. By taking advantage of the concepts shown above, you can add more measurements to your program, as well as to the Modbus Register Map of your data logger. The result is that your SCADA system can access live measurement data for a more complete weather station implementation.

Modscan

You can look forward to blog articles in the future with more details on specific Modbus topics, common pitfalls, and best practices. In the meantime, share any Modbus comments or questions you have below.

Operation Manual

Simply Modbus Master 6.4.1

Modbus RTU Master and Modbus ASCII Master Emulator

System Requirements:

Windows NT, 95, 2000, XP. (not recommended for Windows 7 or Vista )

display resolution: 800 x 600 minimum

PC with serial port (built in, serial card or USB serial port)

Installation - Simply Modbus Master 6.4.1 (1.70 MB) :

Click to download SimplyModbusMaster6.4.1.zip

Unzip the compressed files into a common folder on your hard drive.
Simply Modbus Master 6.4.1.exe - the program
serpdrv - serial port driver
Read me Slave 2.1.txt - documentation
Read me for Windows7.txt - documentation

Known Issues with version 6.4.1: Two instances normally appears in the taskbar while the program is running, the runtime engine and the program itself, Sometimes the runtime engine does not quit when the program is closed, although it is not consistent and behaves differently on different PCs. It is more likely to happen when the program is opened and closed within a few seconds. Waiting longer or sending a request before closing may help it quit properly. It may quit by itself after a few minutes on some systems. Although it's okay on others.

Work Arounds: It can be forced to quit by right clicking on the taskbar item and selecting close. Using Alt-F4 to quit the program also works better in some cases.

Simply Modbus Master 7.1.2 looks and runs exactly like Simply Modbus Master 6.4.1 but was created using a newer compiler. It is a significantly larger download and has an install program. It appears to be more stable with the newer Windows versions. see.....manual7

Simply Modbus Master 7.1.2 will automatically use a license for Simply Modbus Master if already installed on the PC.

Starting the program

Double-click on Simply Modbus Master 6.4.1.exe.

You will see the demonstration startup window.

The progress bar will take approximately 15 seconds to load the demonstration version.
During this time, you can press the ENTER KEY and see

After purchasing and receiving a license key by email, enter the key and press OK.

The licensed program
- goes immediately to the main Simply Modbus Master Read window and bypasses the Loading Demo startup window.
- allows unlimited reads and writes.

The demo version
- offers full functionality
- requires a program restart to send more than six read requests or one write command.

The Simply Modbus Master - Read Window

Controls (inputs) that can be changed by the user have a yellow.background
Indicators (outputs) have a blue ackground and cannot be directly changed.

Set the controls to build the Request string.

Select RTU or ASCII mode. more info...

Select the serial port on your PC that is connected to a modbus slave device.
range: COM1 to COM99

serial settings: Set these settings to match the setting of the modbus slave device connected.
baud: The baud rate (bits per second) of the serial connection.
data bits: The number of data bits in each byte, RTU mode requires 8, ASCII mode is usually 7 but may be 8.
stop bits: The number of stop bits for each byte sent. allowable values are 1, 1.5 or 2 .
parity: The value of the parity bit for each byte sent. allowable values are none, odd, even, mark or space.

The 1st byte in the Command string
The unit address of the Slave device to get data from. normal range: 1 to 247 more info...

Setting a Slave ID over 255 will automatically check this box and allow Slave IDs up to 65535. more info...
Remains on for all addresses until the Slave ID is lowered below 256 and the box manually unchecked.

The 2nd byte in the Request string
Can be automatically set more info...
Used to select which table to read from. more info...
Read Window supports Function codes 01, 02, 03 & 04

The 3rd and 4th bytes in the Request string
The coil or register number at the start of the block to read. more info...

This value is subtracted from the First Register to give the data address used in the Request.

The 5th and 6th bytes in the Request string
The quantity of registers or coils in the block to read.

check to automatically set the default values function code, offset and register size
when the value of First Register is changed.

The size of the registers in the block to be read.
This value should be set to 16 bit registers to read standard modbus registers.
and set to 1 bit coils to read standard modbus coils.
32 bit registers should be used for Enron modbus only. more info...

Events: This box is checked when reading Enron events from register 32 more info...

History: This box is checked when reading Enron historical records from register 701-799 more info...


RTU Mode ASCII Mode

crc The last 2 bytes of the RTU Request are the cyclic redundancy check. These are error detection bytes more info...

lrc ASCII Mode messages are preceded with a colon and the crc is replaced with an longitudinal redundancy check, carriage return and line feed characters. more info...

Auto Set values:
First Registerfunction codeminus offsetregister size
1 to 10000111 bit coils
10001 to 100002100011 bit coils
30001 to 4000043000116 bit registers
40001 & greater34000116 bit registers
Exceptions (for reading Enron modbus data):
First Registerfunction codeminus offsetregister size
32 (events)3032 bit registers
701 to 799 (history)3032 bit registers
1001 to 1999101 bit coils
3001 to 39993016 bit registers
5001 to 59993032 bit registers
7001 to 79993032 bit registers

Physical Connection

Before sending a message, the serial port needs to be physically connected to a modbus slave device. The simplest connection is RS232C on a single serial cable.

DTE masters (PC serial ports) have DB9 male connectors which transmits on pin3, receives pin2 and grounds on pin5. A DCE slave will have a DB9 Female connector which will allow the use of a straight through cable. A DTE slave will have a DB9 Male connector and will require the use of a null modem cable.

The RS232 specification states a maximum distance of 50 feet at 20kbaud. Slightly longer connections are possible at slower baud rates depending on cable quality and noise in the area.

Modems and radios are used to transmit longer distances. These are typically DCE devices so straight through cables can be used. Some MDS non-spread spectrum radios require RTS Delay to be used so a 4th conductor is needed on pin 4.

RS485 converters can be used to extend the distance up to 4000 feet at 100kbaud. This can be a 4 wire or 2 wire system, depending on the converter. This also allows multi-dropping up to 32 devices on one pair of wires.

Sending the Request

Press the SEND button. The program then monitors the serial port and displays all bytes received in the Response indicator.

While receiving, the response time counts up with a progress bar.

Receiving stops when the expected response bytes are received or the time reaches the fail in value entered.

The 'expected response bytes' indicator is calculated from the input settings.
The response timer stops when this many bytes are received.

The expected crc is calculated from the bytes in the response.

Troubleshooting

Check the physical connection to make sure the correct conductors are on the correct pins and the correct serial port.

Check the serial settings in the slave device to make sure they match the settings in the master.

Check the Slave device unit address to make sure it matches the Slave ID set in the master.

Make sure the serial port driver file (serpdrv) is in the same folder as SimplyModbusMaster6.4.1.exe

Reading the Response

The data bytes in the response are displayed in the bytes column of the response table.

Use the pull-down boxes in the first column to set the data type for each value. more info...
The copy down button sets all data types to match the setting for the first value.

The bytes and words can be swapped by toggling the High/Low check boxes.


The bytes are re-processed immediately as the settings are changed and the results are shown in the fourth column.
Sending another request for a new response is not required for a recalculation.

A notes column is provided to enter labels for the values.

Press the clear notes button to blank the whole notes column.

Byte History Log

All bytes sent and received are added to the byte history log with date/time stamps.

Displays a 'Save As..' dialog box to allow the log contents to be saved to a text file.

How To Use Modscan 64

Empties the log contents.

Log Results

All data results received can be saved to a data log with date/time stamps.

Displays a 'Save As..' dialog box to create a tabbed-text data file for logging the results.

register# and notes are used as column headers in the file.

When data is received, a row is added to the file with date/time and the results.

Pressing the button again will close the file and stop logging the results.

The data file can be loaded into just about any system or progam like Excel.

Send Continuously

How to use modscan

Check this box to automatically send requests without pressing the send button.

The seconds after the start of one send request until the start of the next send request.


This will continuously send the same command unless combined with the load before send feature (see below)

Statistics

The seconds taken for the slave to respond to last message.
The number of message responses received (meeting the expected response bytes).
The number of message with an incomplete or absent response

The longest amount of seconds taken for a response (not including failed responses).
The average amount of seconds taken for a response (not including failed responses).
The shortest amount of seconds taken for a response (not including failed responses).
Sets all statistical values back to zero.

RTS Delay

Check this option to communicate over devices requiring the RTS pin to be asserted before
transmission. Enter the milliseconds for the on and off delays.

Save and Restore Configurations

Displays a 'Save As..' dialog box to allow saving the current settings to a text file.

Displays a 'Open File' dialog box to allow selecting a previously saved settings file to load.

The configuration file is saved in tabbed text format (tab separated values) and appears like this in notepad.

The preset tabs in Notepad cause the cells with long labels to push the other columns over.
Sending it to, or opening it from, a spreadsheet program like Excel will use the tabs as column delimiters as shown here...

1st column contains descriptions, 2nd column contains values

3rd column contains the data types 0 through 11 in the order shown in its pull down menu.

4th column is empty, 5th column contains the register numbers.

6th column contains the register values from the last poll, if any

Load Before Send - Sending a series of requests

When this box is selected, and the SEND button is pressed (or SEND CONTINUOUSLY is selected),
the program will Restore a previously defined Configuration File
and then SEND the request as saved in the file.

The filenames must be in the format: request1.txt, request2.txt, etc...
and saved in the default folder (where the exe file is saved)

If request1.txt doesn’t exist, a window showing instructions similar to these will appear.

How to install modscan32

SEND CONTINUOUSLY is not saved in the configuration files.
SEND CONTINUOUSLY is always set to unselected when you use the RESTORE CFG button to restore a configuration file.
This keeps polling from automatically starting when you manually restore a configuration file.

If a request*.txt Configuration file is being loaded during a Load before Send,
and the file was saved with LOAD BEFORE SEND selected,
then both SEND CONTINUOUSLY and LOAD BEFORE SEND will both be selected.
Following the LOAD and SEND, the program will wait for the TIME BETWEEN SENDS to expire
before the next LOAD (request2.txt) and SEND.

The program will continue to automatically LOAD, SEND and WAIT through a series of request*.txt files
as long as each file has LOAD BEFORE SEND selected.
When the end of the series is reached and the next file is not found, the series will start over with request1.txt
and continue until SEND CONTINUOUSLY is manually unchecked.

The program will continue to automatically LOAD, SEND and WAIT through a series of request*.txt files
until a file is LOADED without LOAD BEFORE SEND selected.
Following this last SEND, the series will STOP.
The series can be stopped at any time by unchecking SEND CONTINOUSLY.

To stop the series, uncheck SEND CONTINUOUSLY.

------------------------------------------------------------------------------------

Writing Data

Displays the Simply Modbus Master Write 6.4.1 window

Controls (inputs) that can be changed by the user are shown in yellow.
Indicators (outputs) shown in blue cannot be changed.

Set the controls to build the Command string.

The mode and serial settings are copied from the previous window and can also be changed here. more info...

How To Use Modscan

The 1st byte in the Command string
The unit address of the Slave device to get data from. normal range: 1 to 247 more info...

Setting a Slave ID over 255 will automatically check this box and allow Slave IDs up to 65535. more info...
Remains on for all addresses until the Slave ID is lowered below 256 and the box manually unchecked.

The 2nd byte in the Command string
Can be automatically set more info...
Used to select which table to write to. more info...
Write Window supports Function codes 05, 06, 15 & 16

The 3rd and 4th bytes in the Command string
The coil or register number at the start of the block to be written. more info...

This value is subtracted from the First Register to give the data address used in the Command.

The 5th and 6th bytes in the Command string
The quantity of registers or coils in the block to be written.

check to automatically set the default values for function code, offset and register size
when the value of First Register is changed.

The size of the registers in the block to be written.
This value should be set to 16 bit registers to write standard modbus registers.
and set to 1 bit coils to write standard modbus coils.
32 bit registers should be used for Enron modbus only. more info...

Auto Set values:
First Registerfunction codeminus offsetregister size
1 to 7000511 bit coils
7001 to 7999 (Enron modbus)16032 bit registers
8000 to 10000511 bit coils
10001 to 300005100011 bit coils
30001 to 4000063000116 bit registers
40001 & greater64000116 bit registers

Data to Write

The values to write are entered in the table shown. The table size is automatically adjusted as the #values to write is changed.

Use this pull-down box to set the data type for the whole table to be written.

The bytes and words can be swapped by toggling the High/Low check boxes.

Sending the Command

Press the SEND button. The program then monitors the serial port and displays all bytes received in the Response indicator.

While receiving, the response time counts up with a progress bar.

Receiving stops when the expected response bytes are received or the time reaches the fail in value entered.

The 'expected response bytes' indicator is calculated from the input settings.
The response timer stops when this many bytes are received.

The expected crc is calculated from the bytes in the response.

Reading the Response

The data bytes in the response are displayed in the bytes column of the response table.

Byte History Log

All bytes sent and received are added to the byte history log with date/time stamps.

Displays a 'Save As..' dialog box to allow saving the log contents to a text file.

Empties the log contents

RTS Delay

Check this option to communicate over devices requiring the RTS pin to be asserted before
transmission. Enter the milliseconds for the on and off delays.

Save and Restore Configurations

How To Use Modscan

Displays a 'Save As..' dialog box to allow saving the current settings and results to a text file.

Displays an 'Open File' dialog box to allow selecting a previously saved settings file to load.

Press the Close box in the top corner to Exit the Write program.

Troubleshooting

Check the physical connection to make sure the correct conductors are on the correct pins and the correct serial port.

Check the serial settings in the slave device to make sure they match the settings in the master.

Use

Make sure the serial port driver file (serpdrv) is in the same folder as Simply Modbus Master 6.4.1.exe

Home • FAQ • Enron • Download • Purchase • Contact

Copyright © 2020 Simply Modbus. All rights reserved