Data transmission library using MODBUS Protocol Driver. Serial Communications and via TCP/IP. MODBUS RTU ASCII Modus. Modbus Library with Master, Client and Slave support.
Modbus for TCP RTU over TCP. Bridge RTU over IP Gateway. Modbus for serial RS-485 library. MODBUS/TCP Master and Slave. Data Acquisition Products. MODBUS Protocol with LabView samples. Modbus Master Protocol library. Modbus bridging serial to TCP/IP. Serial MODBUS Library. MODBUS Library with Siemens S7.
Serial Communications and via TCP/IP. MODBUS RTU ASCII Modus. Data transmission using MODBUS Protocol. Modbus Library.
SuperCom - MODBUS Protocol Library
MODBUS Protocol Library
MODBUS is an industrial data communication protocol to be used over serial lines (serial communication protocol for RS-232, RS-422, RS-485) and over TCP/IP connections.
The SuperCom MODBUS Protocol Library provides a rock solid foundation to develop fast robust MODBUS capable applications. The SuperCom MODBUS Protocol Library hides the complex MODBUS protocol offering one easy to use set of functions that can communicate data packets over serial and TCP/IP connections thus saving valuable time, reducing costs and ensuring quality results.
The SuperCom MODBUS Protocol Library supports data communication between devices connected to a serial port, on a bus system or network. The protocol module supports ASCII and RTU (Remote Terminal Unit) operation mode (ASCII mode transfers ASCII codes and RTU binary data bytes in binary mode).
There is only one API to learn! The same functions and parameters with Serial, TCP/IP or ISDN type of connections and operation mode (Modbus ASCII, Modbus RTU, Modbus TCP).
The SuperCom MODBUS Protocol Library also supports custom function codes and data packets by implementing functions that communicate transparently. Controlling machine specific extensions is realy easy using these functions.
Accomplish with ease
In most cases only a handful functions are needed to talk to the PLC. Your project is updated real fast. A lot of functions is backing you up to accomplish different tasks or configurations.
- Run multiple Modbus masters.
- Connect one or more MODBUS RTU or ASCII masters to one or more Modbus slaves.
- The SuperCom MODBUS protocol module can control, based on the used SuperCom software, serial and/or TCP/IP connections.
- The SuperCom MODBUS protocol module can run concurrently connections thus polling more than one plc the same time is possible.
- Receive Modbus data packets and simulate one or more MODBUS slaves or Protocol Gateway.
- Create your own Modbus Gateway or Bridge to route data between serial interface and TCP/IP network, for example a MODBUS TCP to MODBUS RTU Gateway.
- Use SuperCom for Modbus bridging (e.g. serial to TCP/IP).
- Create your own Protocol Gateway using one of the other industrial protocols (PLC protocols) offered with SuperCom or your own custom protocol.
- Use with PLC from SIEMENS, Allen Bradley, etc. A pre-installed MODBUS protocol module on PLC assumed.
The SuperCom MODBUS Protocol Library uses the SuperCom Communication Layer which provides a rock solid foundation to develop data communication software fast and without headache. Thus it makes no difference to the programmer if the MODBUS protocol used over TCP/IP or serial lines (RS-232, RS-422, RS-485, Modem, TAPI).
Samples - MODBUS Protocol API:
1. Read a single coil
C/C++
#define SLAVE_ID 1
BYTE Com = COM_2; // Use serial port COM2
ComInit (Com);
ComSetState (Com, 9600, ...);
:
RS_MBSetConfig(Com,,SuperCom.MODBUS.MODBUS_MODE_RTU,,);
if (RS_MBReadCoil (Com,
SLAVE_ID,
wCoil,
&Buffer))
{
printf("Coil[%d] = %s ", wCoil, Buffer?"TRUE":"FALSE");
}
else
{
int ErrorCode = RS_MBGetLastError(Com);
if (ErrorCode == MB_ERR_EXCEPTION)
printf("Exception %02X reported from slave ", RS_MBGetException(Com));
else
printf("Error %d", ErrorCode);
}
ComReset (Com);
Delphi
Const SLAVE_ID = 1;
Com = COM_2; // Use serial port COM2
Var ErrorCode:Integer;
ComInit (Com);
ComSetState (Com, 9600, ...);
:
RS_MBSetConfig(Com,,SuperCom.MODBUS.MODBUS_MODE_RTU,,);
If (RS_MBReadCoil (Com,
SLAVE_ID,
wCoil,
Buffer)) Then
Write('Coil[', wCoil, '] =', Buffer)
Else
Begin
ErrorCode = RS_MBGetLastError(Com);
If (ErrorCode = MB_ERR_EXCEPTION) Then
Write('Exception ', RS_MBGetException(Com), ' reported from slave ')
Else
Write('Error %d', ErrorCode);
End;
ComReset (Com);
C# using the TSCom class (ActiveX API)
SCom = new MYSCOM(Com, frm1);
SCom.Settings = "9600,N,8,1";
SCom.PortOpen = true;
:
SuperCom.MODBUS.RS_MBSetConfig(Com,,SuperCom.MODBUS.MODBUS_MODE_RTU,,);
if (SuperCom.MODBUS.RS_MBReadCoil (Com,
SLAVE_ID,
wCoil,
Buffer))
WriteLine("Coil[{0}] = {0}", wCoil, Buffer);
else
{
int ErrorCode = SuperCom.MODBUS.RS_MBGetLastError(Com);
if (ErrorCode = MB_ERR_EXCEPTION) Then
{
WriteLine("Exception {0} reported from slave", SuperCom.MODBUS.RS_MBGetException(Com));
}
else
{
WriteLine("Error {0}", ErrorCode);
}
}
SCom.PortOpen = false;
Visual Basic
Const SLAVE_ID = 1
Const Com = COM_2 ' Use serial port COM2
Dim ErrorCode As Integer
Call ComInit (Com)
Call ComSetState (Com, 9600, ...)
:
Call RS_MBSetConfig(Com,,SuperCom.MODBUS.MODBUS_MODE_RTU,,)
If (RS_MBReadCoils(Com, _
SLAVE_ID, _
wFromCoil, _
wCount, _
cBuffer(0))) Then
WriteLine ("Response (" & Format(wCount) & " bits), Coil:" & Format(wFromCoil) & vbCrLf)
Else
ErrorCode = RS_MBGetLastError(Com)
If (ErrorCode = MB_ERR_EXCEPTION) Then
WriteLine ("Exception " & Format(RS_MBGetException(Com)) & " reported from slave " & vbCrLf)
End If
End If
Call ComReset (Com);
|
2. Read/Write Registers
C/C++
#define SLAVE_ID 1
BYTE Com = COM_2; // Using serial port COM2
WORD Buffer [10];
WORD wStart=0x0000;
WORD wCount=1;
WORD wValue=0x0020;
:
ComInit (Com);
ComSetState (Com, 9600, ...);
:
RS_MBSetConfig(Com,,SuperCom.MODBUS.MODBUS_MODE_RTU,,);
if (RS_MBWriteRegister(Com, SLAVE_ID, wStart, wValue))
printf ("Read Success.\n");
else
printf ("Error: %d\n", RS_MBGetLastError(Com));
if (RS_MBReadHoldingRegisters(Com,
SLAVE_ID,
wStart,
&wCount,
Buffer))
{
printf("Read %d Register:", wCount);
for (int i=0; i<wCount; i++) printf ("%4X",Buffer[i]);
}
else
printf ("Error: %d\n", RS_MBGetLastError(Com));
ComReset (Com);
Delphi
Const SLAVE_ID = 1;
Com = COM_2; // Use serial port COM2
Var ErrorCode:Integer;
Buffer:Array [0..9] Of Word;
wStart:WORD=$0000;
wCount:WORD=1;
wValue:WORD=0x0020;
:
ComInit (Com);
ComSetState (Com, 9600, ...);
:
RS_MBSetConfig(Com,,SuperCom.MODBUS.MODBUS_MODE_RTU,,);
If (RS_MBWriteRegister(Com, SLAVE_ID, wStart, wValue)) Then
WriteLn('Read Success.')
Else
WriteLn('Error: ', RS_MBGetLastError(Com));
If (RS_MBReadHoldingRegisters(Com,
SLAVE_ID,
wStart,
&wCount,
Buffer)) Then
Begin
Write('Read ', wCount, ' Register:');
For I:=0 To wCount-1 Do Write(Hex(Buffer[i]));
End
Else
WriteLn('Error: ', RS_MBGetLastError(Com));
ComReset (Com);
C# using TSCom class (ActiveX API)
int ErrorCode
int Buffer=new int[10];
int wStart ,wCount, wValue;
wStart = 0x0000; wCount = 1; wValue = 0x0020;
:
SCom = new MYSCOM(Com, frm1);
SCom.Settings = "9600,N,8,1";
SCom.PortOpen = true;
:
SuperCom.MODBUS.RS_MBSetConfig(Com,,SuperCom.MODBUS.MODBUS_MODE_RTU,,);
if (SuperCom.MODBUS.RS_MBWriteRegister(Com, SLAVE_ID, wStart, wValue))
WriteLine ("Read Success.\n");
else
WriteLine("Error: {0}", RS_MBGetLastError(Com));
if (RS_MBReadHoldingRegisters(Com,
SLAVE_ID,
wStart,
ref wCount,
ref Buffer))
{
WriteLine("Read {0} Register:", wCount);
for (int i=0; i<wCount; i++)
WriteLine("{0:x4}",Buffer[i]);
}
else
printf ("Error: {0}\n", RS_MBGetLastError(Com));
SCom.PortOpen = false;
Visual Basic
Const SLAVE_ID = 1
Const Com = COM_2 ' Use serial port COM2
Dim ErrorCode As Integer
Dim Buffer(10) As Integer
Dim wStart ,wCount, wValue As Integer
wStart = &H0000 : wCount = 1 : wValue = &H0020
:
Call ComInit (Com)
Call ComSetState (Com, 9600, ...)
:
Call RS_MBSetConfig(Com,,SuperCom.MODBUS.MODBUS_MODE_RTU,,)
If (RS_MBWriteRegister(Com, SLAVE_ID, wStart, wValue)) Then
WriteLine("Read Success.")
Else
WriteLine("Error: " & Format(RS_MBGetLastError(Com)));
If (RS_MBReadHoldingRegisters(Com,
SLAVE_ID,
wStart,
&wCount,
Buffer(0))) Then
WriteLine("Read " & Format(wCount) & " Register:" &vbCrLf);
For I=0 To wCount-1 Do WriteLine(Hex(Buffer[i]));
Else
WriteLine("Error: " & Format(RS_MBGetLastError(Com)));
EndIf
Call ComReset (Com);
|
Capture, Store, Forward - MODBUS Slave or Gateway functions
Communication at lower data packet level is possible thus allowing to capture, store and forward of MODBUS data packets or transmit replies. Monitoring MODBUS data packets, simulating a MODBUS Slave or building a protocol converter / gateway is possible. Simulating a MODBUS Slave can be very handy while testing the software.
License Information
Executables developed using SuperCom MODBUS Protocol Module can be distributed royalty free.
Supported compilers
C#, C++, Delphi, Visual C++, Visual Basic, Visual Basic NET, C++ Builder, Borland C/C++, Microsoft C/C++, Borland Pascal, VBA, LabVIEW, PowerBuilder and other Windows programming tools (MS .NET ?).
Samples
for C/C++, C#, Visual C++, C++ Builder, Pascal/Delphi, Visual Basic, Visual Basic NET (VB .NET), LabVIEW.
Supported Protocols
The SuperCom MODBUS Protocol library implements the standard MODBUS protocol for serial and TCP/IP connections* based on the official specification by the MODBUS organization. SuperCom supports MODBUS ASCII and MODBUS RTU protocol with serial interfaces (RS-232, RS-422, RS-485) and the MODBUS TCP/IP (MODBUS/TCP) and Open MODBUS TCP with TCP/IP networks.
*A corresponding SuperCom license (Serial and/or TCP/IP) assumed.
A non standard variant of the MODBUS protocol called RTU over IP (MODBUS RTU/IP, MODBUS RTU over TCP) is also supported. The RTU over IP enables the SuperCom application to talk to OMTS devices (OMTS = Out of the MODBUS TCP/IP specification). Since not an official specification, additional names and variants may exists.
How to use?
The SuperCom MODBUS Protocol library can be used over any communication link supported by SuperCom (currently Serial (RS-232, RS-422, RS-485), TCP/IP, ISDN). For a list of available SuperCom packages containing MODBUS protocol, see the following chart.
The use of one common API for Serial, TCP/IP and ISDN applies here too (any SuperCom ActiveX API and/or DLL API).
What to order?
You will find promotional combinations with MODBUS (e.g. SuperCom Serial incl. MODBUS, SuperCom for TCP/IP incl. MODBUS, SuperCom Protocol Engine, SuperCom Suite)
The code 638 and/or 638400 is needed only when the MODBUS protocol module is ordered later in addition to a current SuperCom package.