Go to page:
1 2 Next
Introduction
Simulator for Modbus slaves over RS232/RS485 and TCP/IP amongst other protocols.
(continued)In the words of Paul DiLascia: If this code works, it was written by Conrad Braam. If not, I don't know who wrote it.
Compiles with Visual C++ 6.0, and runs on Windows 98/NT4/2000/XP and probably 95/Me, too.

Click here for a larger image.
Purpose
This simulator was originally written to allow the testing of a MODBUS RTU serial driver without having to get 254 little MODBUS PLCs into one office. It, however, grew and is growing to support other protocols (open-mbus TCP/IP, Allen-Bradly DF1 slave+master) as well. It is not, by any means, a full implementation of the protocol(s) that it implements; it is only the basic or commonly used functions.
History
This simulator actually originated whiile I was trying to write a stable socket wrapper of the Windows Sockets API, and the Texas Instruments TCP/IP protocol, but that is another story. It then was re-written for Modbus RTU, and I added TCP/IP according to the OpenMBUS spec. Next, I added Allen-Bradley DF1, and have a specialized modification of a DF1 MASTER, called JOY, which is highly specific.
This program was initially written over a few weekends, and now that I no longer work much with comms., it has become a labor of love. I Still fix bugs if you explain them nicely. Although testing is difficult because I have no equipment, I even add features from time to time.
Modbus surpasses the limitations in other programs I have found in the past by:
- Allowing it to simulate more than one RTU at once.
- Allowing the editing and displaying of all the registers.
- Allowing the scanning of registers not actually in the display.
- Running on >1 comm ports. (You have to run two copies of the program.) You need to run the first copy; then, when you run it again, it defaults to use the next free RS-232 port.
- A way to disable just certain stations. (Is done now; just click on the boxes at the bottom.)
- Load and save values you type into each register (the file is saved in the same folder) as well as simulate changes in the values using scripting!
- A comm debugger screen (Hotkey Ctrl+C.).
- Show statuses for all stations, not just the first couple.
Missing
- Nothing really. I would have liked to have written this thing in a more generic fashion (time does not permit) to support as many protocols as I liked.
- Maybe MODBUS ASCII protocol support.
- Any suggestions, please send.
Compiling It
I'm pretty sure it does compile nicely. Linking is a bit hairy if you are missing the lib-file "mylib.lib". Please download it as a separate zip file below, and compile. Then, set the linker options appropriately to point to it. Not all of this code is production code, and as such is not fully tested. Use it at your own risk.
I am working on a new comm. library intended to give a better starting point for cut-and-pasters; at the moment, you have to get past a lot of hard-wiring in the program. I hope to create a cleaner layered and wrappered version with a simpler demo application, free, stru!
Modbus Compatibility Classes
To get a really high score when it comes to compatibility with different devices, you want lots of functionality, but miminal code—especially if RAM is limited.
Because the source for this project is open, I imagine it will get many bug-reports and fixes at low cost, and add stability as it ages.
| Function Code |
Meaning |
| Class 0: the bare minumum |
| 03 hex |
Read Multiple Registers |
| 10 hex |
Write Multiple Registers |
| Class 1: ideal |
| 01 hex |
Read Coils |
| 02 hex |
Read Inputs |
| 04 hex |
Read Input Registers |
| 05 hex |
Write Coil |
| 06 hex |
Write Single Register |
| 07 hex |
Read Exception Status |
| Class 2: almost overkill |
| 0F hex |
Force Multiple Coils |
| 16 hex |
Mask-write Register |
| 17 hex |
Read,Write Multiple registers |
Nuggets
There are 13 new classes and a dozen useful utility routines in here.
Running It
I am not going to give a full feature and User-Interface run-down because it has built-in/linked-in help; just press F1. Here are the basics, which most of us will get in five minutes anyway.
I get lots of people asking, How do I select TCP/IP? Well, that is easy; find the drop-list control near the right, and pick TCP/IP from that. All toolbar buttons change their functions as a result.
About the Author
A die-hard C++ guru, Conrad has no exciting outdoor hobbies, does not jump out of aeroplanes, nor look good. Studied in Elect. Engineering and dissrespectfull of anything that cannot be dissasembled (x86 was my first language). Currently hard at work in the process industry, I am looking to turn my hand to some espionage. Communications is my game.
Web www.plcsimulator.org
Blog www.zaphodikusrealm.blogspot.com
CURRENTLY HUNTING FOR WORK IN CAMBRIDGE!
Go to page:
1 2 Next
Downloads
Legacymod_simSource.zip - Origional source (really old version)
mod_RSsim76exe.zip - Demo executable v7.6
mod_RSsim7_4b.zip - mode_RsSim V 7.4b source
mylib.zip - Source : (library needed 2 compile)