RMCLink COM Component RMCLink.WriteLFile Method |
Writes to one or more integer (L) registers in the controller. Since all RMC100 registers are integer registers, this function should be used for all writes to RMC100 controllers. It should also be used when writing integer values to RMC70, RMC150, or RMC200 registers. Compare with WriteFFile.
Visual Basic (Declaration) |
Sub WriteLFile ( _ file As Long, _ element As Long, _ count As Long, _ data As Variant _ ) |
Visual Basic (Usage) |
Dim instance As RMCLink Dim file As Long Dim element As Long Dim count As Long Dim data As Variant
instance.WriteLFile(file, element, count, data) |
file
File number of the first register to write to. See the RMCLink Register Reference for details.
element
Element number of the first register to write to. See the RMCLink Register Reference for details.
count
The number of registers to write.
data
The data to write to the controller. The following data types are supported:
A single value of Long data type (not an array)
Single-dimensional array of Long data type elements
Two-dimensional array of 1xN or Nx1 Long data type elements
For details on integer (L) and floating-point (F) registers and how to read from and write to both, see RMC100 Register Data Types or RMC70, RMC150, and RMC200 Register Data Types.
This method is synchronous, which means that it will not return until the write is completed, which may take several seconds. If this method is called on the main thread, then the application will likely be unresponsive until this method completes. For applications where this is not acceptable, this and other synchronous methods should be called from a worker thread, and may use the CancelRequest method to cancel an in progress request.
Error Code |
Description |
rmcEOutOfMemory = 5 |
Out of memory. |
rmcEInvalidArg = 7 |
One of the file, element, count, or data parameters are out of range. |
rmcEDisconnecting = 1002 |
Link is being disconnected by another thread. |
rmcEBadType = 1003 |
Invalid type passed in for write data parameter. |
rmcEBadLength = 1004 |
Array length of write data does not match count parameter. |
rmcEDisconnected = 1005 |
The link has not been connected. |
rmcESocketInternal = 1008 |
Internal socket error. |
rmcECancelled = 1010 |
Operation cancelled by call to CancelRequest. |
rmcETimeout = 1011 |
Operation timed out. |
rmcESocketGracefullyClosed = 1014 |
TCP/IP connection closed by remote device. |
rmcESocketReadError = 1015 |
Connection error while waiting for response from the remote device. |
rmcESocketInvReadLen = 1016 |
Connection error while waiting for response from the remote device. |
rmcESocketWriteError = 1017 |
Connection error while sending request to the remote device. |
rmcESocketInvWriteLen = 1018 |
Connection error while sending request to the remote device. |
rmcESerialIOE = 1021 |
Serial IOE error. |
rmcESerialFramingError = 1022 |
Serial framing error. |
rmcESerialBreak = 1023 |
Serial Break error. |
rmcESerialOverrun = 1024 |
Serial overrun. |
rmcESerialRxOverrun = 1025 |
Serial receive overrun. |
rmcESerialParityError = 1026 |
Serial parity error. |
rmcESerialTxFull = 1027 |
Serial transmitter full. |
rmcEConnectionBroken = 1028 |
Connection broken. |
rmcEPartialWrite = 1029 |
Unable to send full request to the remote device. |
rmcEReadOnly = 1030 |
Attempt to write to read-only registers. |
rmcEBadAddress = 1032 |
Attempt to write beyond the end of a file. |
rmcEUSBInternal1 = 1051 |
Internal USB driver error. |
rmcEUSBOperationAborted = 1053 |
Unsuccessful transfer of data between the PC and the controller. Ensure that the physical connection between the PC and controller is still intact. |
rmcEUSBDisconnected = 1054 |
The controller appears to have been disconnected from the USB port. Ensure that the physical connection between the PC and controller is still intact. |
The following code example illustrates the use of the WriteLFile 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.CreateEthernetLink(dtRMC100, "192.168.0.28")
' Establish the connection.
rmc.Connect
' Issue a Go (G) command to Axis 0 (registers L8:0-5).
Dim data(5) As Long
data(0) = &H81 ' Mode (S-Curves, Accel/Decel Mode 1)
data(1) = 100 ' Acceleration Rate (100 in/s/s)
data(2) = 100 ' Deceleration Rate (100 in/s/s)
data(3) = 10000 ' Requested Speed (10 in/s)
data(4) = 4000 ' Requested Position (4 in)
data(5) = Asc("G") ' Go (G) command
rmc.WriteLFile fn100CommandAxis0, 0, rmc100CmdRegsPerAxis, data
' Close the connection.
rmc.Disconnect
End Sub
|
VBScript |
Option Explicit
Dim srv, rmc
' 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 (dtRMC100=1).
Set rmc = srv.CreateEthernetLink(1, "192.168.0.28")
' Establish the connection.
rmc.Connect
' Issue a Go (G) command to Axis 0 (registers L8:0-5).
Dim data(5)
data(0) = &H81 ' Mode (S-Curves, Accel/Decel Mode 1)
data(1) = 100 ' Acceleration Rate (100 in/s/s)
data(2) = 100 ' Deceleration Rate (100 in/s/s)
data(3) = 10000 ' Requested Speed (10 in/s)
data(4) = 4000 ' Requested Position (4 in)
data(5) = ASC("G") ' Go (G) command
rmc.WriteLFile 8,0,6,data
' 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 (dtRMC100=1).
var rmc = srv.CreateEthernetLink(1, "192.168.0.28");
// Establish the connection.
rmc.Connect();
// Issue a Go (G) command to Axis 0 (registers L8:0-5).
var data = new Array(6);
data[0] = 0x0081; // Mode (S-Curves, Accel/Decel Mode 1)
data[1] = 100; // Acceleration Rate (100 in/s/s)
data[2] = 100; // Deceleration Rate (100 in/s/s)
data[3] = 10000; // Requested Speed (10 in/s)
data[4] = 4000; // Requested Position (4 in)
data[5] = 71; // Go (G) command
rmc.WriteLFile(8,0,6,data);
// Close the connection.
rmc.Disconnect();
|
See Also
RMCLink Class | RMCLink COM Component | WriteFFile
Copyright (c) 2024 Delta Computer Systems, Inc. dba Delta Motion