Burkert Type 8056 User Manual

Page 80

Advertising
background image

- 80 -

RS232_485_ETP_MODBUS_BU_REV02.doc

5.9.

EXAMPLE OF SOURCE CODE FOR VB .NET 2005 PROJECT

The code below is intended as an example of source code for return the process data from the flow
meter via Modbus protocol.
The example uses the serial port control present in the tool box of the Visual Basic Net 2005
For the hardware communication it is used a converter RS232 – RS485 connected to the RS232 serial
port of the pc and the RS485 port of the converter.
The control line used in the example for the control of the transmission data in the RS232-RS485
converter is the RTS line.
The example program is an executable application that run in a Windows XP operative system. For
this reason the commutation of the RTS line is not immediately reached because the Windows XP is
multithreading system and the application haven’t the direct control of the hardware.
In other words there isn’t a direct control of the UART of the mother board by the application.
For this reason there is possible to insert a delay time by the function A.delay in the

Menu «7-

Communication» of the

flow meter for compensate the retarder.





Public

Class

Form1


Public

Delegate

Sub

myDelegate()


Dim

afIntChkHigh(0

To

255)

As

Integer

Dim

afIntChkLow(0

To

255)

As

Integer

Dim

vfStrErrorString

As

String

Dim

vfStrCommand

As

String

Dim

vfStrCrc

As

String


Private

Sub

Form1_FormClosing(

ByVal

sender

As

Object

,

ByVal

e

As

System.Windows.Forms.FormClosingEventArgs)

Handles

Me

.FormClosing

End

End

Sub


Private

Sub

Form1_Load(

ByVal

sender

As

System.Object,

ByVal

e

As

System.EventArgs)

Handles

MyBase

.Load


Try

'load checksum

afIntChkHigh(0) = &H0
afIntChkHigh(1) = &HC1

afIntChkHigh(2) = &H81
afIntChkHigh(3) = &H40

afIntChkHigh(4) = &H1

Advertising
This manual is related to the following products: