beautypg.com

Despatch Protocol Plus Modbus Communications User Manual

Page 50

background image

Chromalox Instruments and Controls

A-51643 Rev. 6 10/06/03

44

'set the Settings to select Baud Rate, Parity, Data bits, and Stop bits.

'Note that Baud Rate and Parity must match the Controller's settings,

'always use 8 Data bits and 2 Stop bits.

frmComm.comMain.Settings = "38400,N,8,2"

'set other parameters:

frmComm.comMain.InputLen = 0

frmComm.comMain.Handshaking = comNone

frmComm.comMain.InputMode = comInputModeText

frmComm.comMain.InBufferSize = 1024

frmComm.comMain.RThreshold = 1

frmComm.comMain.InputLen = 0

frmComm.comMain.OutBufferSize = 512

frmComm.comMain.SThreshold = 1

frmComm.comMain.EOFEnable = False

frmComm.comMain.ParityReplace = "?"

frmComm.comMain.NullDiscard = False

frmComm.comMain.RTSEnable = False

frmComm.comMain.DTREnable = True

'open the port:

frmComm.comMain.PortOpen = True

End Sub

The following procedure, placed to respond to the command button‘s click event, is used to build and

transmit a ―Read Holding Registers‖ message to read three registers starting at register 16:

Private Sub Command1_Click()

Dim CRCWord As Long 'CRC calculation result buffer

'initialize message with address, function, and function data bytes:

TxMessage = Chr(1) & Chr(3) & Chr(0) & Chr(16) & Chr(0) & Chr(3)

'call the CRC calculation: