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:

    1. On the File tab, choose the Options button
    2. In the Excel Options dialog box, choose the Customize Ribbon button
    3. In the list of main tabs, select the Developer check box
    4. 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
    Excel macro security

  3. Enable ActiveX and restart Excel
    Enable ActiveX

  4. Click Insert and select "More Controls
    More controls

  5. Select MBAXP from the list and press ok
    Select MBAXP from list

  6. Now MBAXP is inserted
    MBAXP on Excel sheet

  7. Click Insert and select button (ActiveX Controls)
    Insert button

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

  9. Select caption and name it Open port
    Button caption

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

  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.