┬ÁTasker Forum > MODBUS

MODBUS simulation/testing on PC

(1/3) > >>

Hi Mark,

Following some comments made by some of your many satisfied customers/users, I was wondering how much of the MODBUS capability was supported on the simulator?

We currently support a subset of the commands for MODBUS RTU over serial line and we're interested in widening this to include MODBUS over IP.

The next question for us is how then to test the additional capability - we have software to independently verify our MODBUS RTU over serial line support but I'm wondering how much need we would have for this for MODBUS over IP?

Basically I guess I'm asking how we can go beyond using the simulation on the PC for testing?
Could we for instance use some of the code in the simulation as the basis for our own MODBUS over IP test software on the PC? Or would we really need to buy some other software to cover this? If so, do you have any recommendations we could follow?


Hi Jez,

I'm one of the users of the Modbus module and I can fully use it in the simulator. I use various modbus applications to connected to my simulated device via both serial and Ethernet.

To connected to the device I have used a handy little tester from here

I've also written some simple VB6 programs using this ActiveX control

Note if you are writing your own VB6 programs, you might want to look at the comm32 OCX control, which improves on the standard MSCOMM32.OCX, one key feature is that it supports access to com ports higher than com16. see http://www.comm32.com/

When testing RTU and ASCII protocols on the PC I've been using Com0Com http://com0com.sourceforge.net/ to create virtual serial port pars with one port of the pair connected to my uTasker simulation and the other connected to this simulator http://www.plcsimulator.org

I've also used the terminal emulator Realterm http://realterm.sourceforge.net/ I'm using version V2.0.0.65 from here http://www.i2cchip.com/realterm/
Realterm has a bit of a clunky interface but the killer tool for me is that for a small donation you can get a spy driver that will allow you to spy on communications on a com port (Virtual or real).

Another powerful tool to monitor serial port comms can be found here http://www.serial-port-monitor.com/

Also to answer your question yes you could use the code in uTasker to build your own test masters and clients. But if there was a bug in the uTasker modbus code (heaven forbid ;-) ) you might not be exposing it.

Hope the above helps


Martin Honeywill

Hi Jez

The uTasker simulator allows MODBUS RTU/ASCII master/slave and MODBUS TCP master/slave to be simulated/tested.

There are various programs available for testing over TCP - some free ones and some which can be purchased. The wonderful thing about MODBUS TCP however is that Wireshark can interpret the content of such Ethernet frames (displays MODBUS content) and so allows simple verification.

If you look at the uTasker MODBUS User's Guide http://www.utasker.com/docs/MODBUS/uTasker_MODBUS.PDF (chapter 20) you will see that the demo MODBUS project actually tests itself by including a TCP master which establishes a link to a TCP slave and tests MODBUS function queries and commands. The MODBUS TCP slave then routes the received queries to a MODBUS serial master which sends them over the serial interface (ASCII or RTU). By looping the COM ports the query arrives at a MODBUS serial slave which finally responds to the query or executes its commands. The answer is then routed back through the reverse path and arrives at the MODBUS TCP master, where it is displayed and the next test in the sequence kick off.

This is only possible in the simulator since it allows the TCP master to send to a slave at its own IP address (which is not normally possible) but the same test works if the master is on a second board (or second simulator) and communicates with a different IP address. The demo project can therefore also be used as a TCP master to test remote TCP slaves (with or without the routing via a further MODBUS serial link) - either in the form of the simulator running or the code running on a real hardware. All transactions can be easily followed by Wireshark.

The uTasker MODBUS module was in fact developed without any further MODBUS SW support; purely allowing it to test itself as described above. However the project was also used in parallel in a small number of Beta projects (these were real industrial developments) where a number of bugs were indeed found along the way and then corrected as appropriate. However the bugs were often things that were also not necessarily obvious even if working with a PC based MODBUS test SW since the communication was generally correct but the content not (the MODBUS protocol analyzer can't tell if the content has an incorrect value - eg. a coil is signaled at state '1' when it was really at state '0') so there was no great need for anything else.

One further advantage of this setup for real development is that when a break point is set in the slave code the TCP communication doesn't breakdown, or the MODBUS master timeout because no response is quickly received (this is because the master is also frozen!!). In fact this is a major advantage in comparison to working with a MODBUS analyzer during this phase of the work. For other tests there is however no reason not to use a MODBUS test program/analyzer if found useful.

There is quite a list of MODBUS test programs on the MODBUS org site: http://www.modbus.org/tech.php

The MODBUS solution is otherwise quite (or very?) comprehensive (apart from a couple of public functions which have never been used yet - mainly read and write of records: full list of supported and non-supported public functions ate in Appendix A). I think that the fact that it is fully configurable to perform both master and/or slave functions on multiple serial and/or TCP interfaces, as well as its almost unlimited routing and gateway capabilities (note that I didn't think up these uses but instead there were quite a variety of such requirements in the first Beta projects alone) makes it very attractive.

The project is also a living project with any new functionality ideas or needs being added when and if possible (for example the project now also supports slave ASCII serial operation on a USB CDC interface - also a real project requirement, which in fact only required an addition 3 program lines in the MODBUS module itself, but of course the available of CDC class in the uTasker USB section).



Hi Mark & Martin,

Many thanks to you both for such complete and helpful responses!

It certainly sounds like there's plenty of options for us to use to validate/test the MODBUS over IP operation - I guess the first step is to get the licenses sorted so that we can test the capability on a dev kit for ourselves!

I can hardly wait to sort this out and see how well it works for our applications!

Thanks to you both once again - the support puts many commercial products to shame!


Hi Mark,

I've been trying to run the standard modbus_app.c in the simulator as a starting point (using the LP23xx project configured for Olimex LPC2478 dev board).

I've installed COM0COM (as my laptop doesn't have any real serial ports) as well as Wireshark, and I can see the MODBUS packets on the Ethernet connection in Wireshark but so far I've not managed to see these being forwarded onto the serial port or any responses to these packets.

Can you please suggest what steps I've missed out? I'm sure it's something basic (probably with the serial ports & COM0COM) that I've (not) done.

Any help will be most welcome!



[0] Message Index

[#] Next page

Go to full version