beautypg.com

B&B Electronics MODSCAN32 - Manual User Manual

Page 88

background image

88

Modbus_Slave OCX Overview


Modbus_slave.ocx contains a 32-bit custom control, which allows Visual Basic and other OLE Container
applications to quickly, and easily interface user-defined data points to a modbus master device connected
to the PC. The modbus master may be connected directly to a PC COM port or accessed via a network
connection using modbus/TCP. The modbus_slave control provides a simple API for establishing a
connection and defining data points which are to be made available to any master device according to the
modbus communications protocol. The control handles all message formatting and interaction with the
Windows COM and network drivers. The only responsibility of the controlling application is to supply a
pointer to the data description which is to be exposed to the connection.

Operation of the modbus_slave control to simulate modbus data involves a two-step process. First, the
controlling application must define and open the physical connection to the modbus. This involves setting
various properties such as BaudRate, Parity, etc. and issuing either the OpenSerial() or OpenTCP() method.

The second step involves defining the data to be exposed to the modbus by issuing the DefineModbusData()
method. Assuming successful implementation of the above, data from within the user program is now
automatically made accessible to any connected modbus master device. The control can support multiple
connections and define multiple arrays of data to be accessed.

Control Description

The following properties and methods define the operating characteristics of the Modbus_slave Control:

Properties


BaudRate

Defines the baud rate to be used for serial connections,
(300,600,1200,2400,4800,9600,19200).

DataBits

Defines the number of data bits, (7, 8).

Parity

Defines parity, (0=No Parity, 1=Odd, 2=Even).

StopBits

Defines the number of stop bits, (0=1 stop bit, 1-1.5 stop bits, 2=2 stop bits).

NodeAddress

Specifies the slave node address to simulate. Changing this property has no
effect until the next CreateModbusData() method is issued. The control may be
used to simulate multiple slave addresses by changing this property between
calls to CreateModbusData().

TransmissionMode

The control can support either ASCII (0) or RTU(1) modbus transmission
modes.


Changing any of the connection properties such as BaudRate, TransmissionMode, etc., will have no effect
until the next OpenSerial() method is issued.