You are on page 1of 4

1/13/2018 MBAXP Quick Start

modbus tools
For test, simulation and programming.

HOME PRODUCTS ORDER DOWNLOAD MODBUS CONTACT

MBAXP Quick start guide


This guide show how to use MBAXP with Microsoft Excel 2010.
All MBAXP functions are described in the included help file.
Find the help file and example files in START->MBAXP

Add the ActiveX to the toolbox:

1. Click the developer tab

If the developer tab is not visible then enable it:

a. On the File tab, choose the Options button

b. In the Excel Options dialog box, choose the Customize Ribbon button

http://www.modbustools.com/mbaxp_quickstart.html 1/4
1/13/2018 MBAXP Quick Start
c. In the list of main tabs, select the Developer check box

d. Choose the OK button to close the Options dialog box

2. Now the developer tab is visible and it may be necessary to enable macros

3. Enable ActiveX and restart Excel

4. Click Insert and select "More Controls

http://www.modbustools.com/mbaxp_quickstart.html 2/4
1/13/2018 MBAXP Quick Start
5. Select MBAXP from the list and press ok

6. Now MBAXP is inserted

7. Click Insert and select button (ActiveX Controls)

8. Right click on the button you just inserted and select properties

9. Select caption and name it Open port

10. Double click on the button to open the VBA editor

http://www.modbustools.com/mbaxp_quickstart.html 3/4
1/13/2018 MBAXP Quick Start
11. Add code to the button sub function
Private Sub CommandButton1_Click()

Mbaxp1.Connection = Port1
Mbaxp1.BaudRate = B9600
Mbaxp1.DataBits = Eight
Mbaxp1.Parity = NONE
Mbaxp1.StopBits = Two

Mbaxp1.ProtocolMode = RTU 'RTU Mode


Mbaxp1.Timeout = 1000

'Read 1 register from device addres 40001 every 1000ms.


'40001 = protocol address 0. 4x means holding registers function code 03
'Handle 1, Slave ID 1, Address 0, Quantity 1, Every 1000ms
result = Mbaxp1.ReadHoldingRegisters(1, 1, 0, 1, 1000)
'Start the task
result = Mbaxp1.UpdateEnable(1)

'Open the serial port


result = Mbaxp1.OpenConnection()

End Sub

12. Double click the MBAXP to add an event sub function

13. Add code to the ResultOk event


' This event is called when a transaction is done
' Check if the event is from handle 1
Private Sub Mbaxp1_ResultOk(ByVal Handle As Integer)
If Handle = 1 Then
' Copy from MBAXP internal data array handle 1 index 0
Cells(6, 6) = Mbaxp1.Register(1, 0)
End If
End Sub

14. Turn off design mode

15. Press the "Open port" button. The communication should run now

See also the included Excel examples.

Copyright © 2017 Witte Software - All rights reserved.

http://www.modbustools.com/mbaxp_quickstart.html 4/4

You might also like