RMCLink COM Component RMCLinkServer.CreateUSBLink Method |
Creates an RMCLink object for communicating with a controller (RMC70, RMC150, or RMC200) over a USB port.
Visual Basic (Declaration) |
Function CreateUSBLink ( _ devType As DeviceType, _ deviceId As String _ ) As RMCLink |
Visual Basic (Usage) |
Dim instance As RMCLinkServer Dim devType As DeviceType Dim deviceId As String Dim returnValue As RMCLink returnValue = instance.CreateUSBLink(devType, deviceId) |
devType
Specifies which type of RMC will be linked to. It must be either dtRMC70, dtRMC150, or dtRMC200.
deviceID
Specifies which controller to connect to over the USB port:
RMC75E: The controller’s 10-digit serial number in the format ”7573xxyyzz”.
RMC150: The Ethernet (MAC) Address in the format ”00-50-A0-xx-yy-zz”.
RMC200: The CPU module's serial number in the format ”22Cyynnnn”.
Returns a reference to a new RMCLink object created for communicating with the specified device type with the specified deviceId over a USB port.
Notice that this method does not in any way try to connect to the controller. This method simply creates the RMCLink object. To connect to the device, you will need to call the RMCLink.Connect instance method.
Because the object is only created and the connection is not made, this method returns immediately.
Error Code |
Description |
rmcEOutOfMemory = 5 |
Out of memory. |
rmcEInvalidArg = 7 |
Invalid argument. Ensure that devType was either dtRMC70, dtRMC150, or dtRMC200 and that deviceId had a valid device ID. |
The following code example illustrates the use of the CreateUSBLink method.
Visual Basic 6 / VBA |
Option Explicit
Public Sub Sample()
' Declare and create the RMCLinkServer COM object.
Dim srv As New RMCLinkServer
' Use our RMCLinkServer to create the correct type of RMCLink object.
Dim rmc As RMCLink
Set rmc = srv.CreateUSBLink(dtRMC70, "7573091001")
' Establish the connection.
rmc.Connect
' Read F8:8 and F8:9 (Axis 0 Actual Position and Velocity)
Dim data As Variant
data = rmc.ReadFFile(fn70StatusAxis0, 8, 2)
resultText = "Actual Position = " & data(0) & ", Actual Velocity = " & data(1)
' Close the connection.
rmc.Disconnect
End Sub
|
VBScript |
Option Explicit
Dim srv, rmc, data
' First we need to create the RMCLinkServer COM object.
Set srv = CreateObject("RMCLink.RMCLinkServer")
' Use our RMCLinkServer to create the correct type of RMCLink object.
' NOTE: VBScript does not support enumerations, so we use the literal value (dtRMC70=2).
Set rmc = srv.CreateUSBLink(2, "7573091001")
' Establish the connection.
rmc.Connect
' Read F8:8 and F8:9 (Axis 0 Actual Position and Velocity)
data = rmc.ReadFFile_Script(8,8,2)
WScript.Echo "Actual Position = " & data(0) & ", Actual Velocity = " & data(1)
' Close the connection.
rmc.Disconnect
|
JScript |
// First we need to create the RMCLinkServer COM object.
var srv = new ActiveXObject("RMCLink.RMCLinkServer");
// Use our RMCLinkServer to create the correct type of RMCLink object.
// NOTE: JScript does not support enumerations, so we use the literal value (dtRMC70=2).
var rmc = srv.CreateUSBLink(2, "7573091001");
// Establish the connection.
rmc.Connect();
// Read F8:8 and F8:9 (Axis 0 Actual Position and Velocity)
var data = rmc.ReadFFile_Script(8,8,2).toArray();
WScript.echo("Actual Position = " + data[0] + ", Actual Velocity = " + data[1]);
// Close the connection.
rmc.Disconnect();
|
See Also
RMCLinkServer Class | RMCLink Class | RMCLink COM Component
Copyright (c) 2024 Delta Computer Systems, Inc. dba Delta Motion