ModbusTools

Menu > Home
> Products

   • Modbus Poll
   • Modbus Slave
   • Modbus TCP/IP .NET
   • Modbus RTU/ASCII .NET
   • Modbus ActiveX
> Download
> Order
> Contact Info.
> Links

> Modbus

MBAXP Quick start guide

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

If you use Windows 7 or Vista read here.

 

Add the ActiveX to the toolbox

1. Click the developer tab.

 

If the developer tab is not visible then enable it:

a. Click the office button and push Excel options.

b. Check the check box "Show Developer tab in the Ribbon"

 

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

 

3. Click Insert and select "More Controls" 

 

4. Select MBAXP from the list and press ok and click on cell 2A.

 

5. Now MBAXP is inserted

 

6. Click Insert and select button (ActiveX Control). Then click on cell 6A

 

7. Right click on the button you just inserted and name it Open port.

 

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

 

9. Add some 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

result = Mbaxp1.ReadHoldingRegisters(1, 1, 0, 1, 1000) 'Handle 1, Slave ID 1, Address 0, Quantity 1, Every 1000ms

' Start the task
result = Mbaxp1.UpdateEnable(1)

' Open the serial port
result = Mbaxp1.OpenConnection()

End Sub

 

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

 

11. Add code to the ResultOk event.

' This event is called when a transaction is done

' Check if the event is from handle 1

If Handle = 1 Then
Cells(6, 6) = Mbaxp1.Register(1, 0) ' Copy from MBAXP internal data array handle 1 index 0
End If

 

12. Turn off design mode.

 

13. Press the "Open port" button. The communication should run now.
See also the included Excel examples.

 

Copyright © 2012 ModbusTools - All rights reserved. Modbus is trademark of Modicon.