For test, simulation and programming.
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:
If the developer tab is not visible then enable it:
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
' 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
See also the included Excel examples.