RMCLink Component

How to: Send RMC100 Commands

One common task when controlling an RMC100 through the RMCLink component is to issue commands to one or more axes (see the online help in RMCWin for details on what commands are available and what they do).

Commands are issued by writing to the command files for each axis, which are numbered L8-L15 for axes 0-7 respectively. Each file consists of six (6) registers per axis. The last (sixth) register in each axis's command file is the command, and the first five registers are command parameters for that command. The meaning of the command parameters vary depending on the command selected by the first register.

Notice that on the RMC100, most commands are given as letters or symbols (for example, the "Go" command is "G", and the "Set Pressure" command is "^"). However, when writing to the command register for an axis, a number must be written. To find the number corresponding to a letter or symbol command, use the ASCII value of that letter or symbol, which can be found either by looking up the command in the RMCWin online help, where the number value will be listed, or you can use a language-specific method, if one is available, such as Visual Basic's Asc function (in Visual Basic, Asc("G") will return the numeric value for "G", 71).

When an outside source writes to the command files, each axis written to will run the command sent to it immediately. Notice that it is important that all axes that are to run their commands simultaneously must be written to in the same write. In order to allow this to work, writes that extend beyond the end of one command file continue in the next command file. Therefore, to issue commands to axes 0 and 1 at the same time, write 12 registers starting at L8:0.

Notice that a special command of NoOp (0) can be issued to have the axis ignore the command written to it. Therefore, to issue commands simultaneously to axes 0 and 2 at the same time, write 18 registers starting at L8:0, but make sure that the seven value (the one written to L9:0) is zero (0) so that only commands 0 and 2 act on their commands.

The following steps should be used to write a command to one or more axes in the RMC100:

Refer to the example below.

Reading from the command files is not meaningful; zeros will simply be returned for each register.

Acknowledge Bit

The acknowledge bit works as it normally does when used via RMCLink.

Example

The following code example illustrates sending commands to an RMC100.

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

 

Visual Basic .NET

Imports RMCLinkNET
 
Module Example
    Sub Main()
        ' Create the object itself.
        Dim rmc As RMCLink = RMCLink.CreateEthernetLink(DeviceType.RMC100, "192.168.0.10")
 
        ' Connect to the controller.
        rmc.Connect() 
 
        ' Issue a Go (G) command to Axis 0 (registers L8:0-5).
        Dim cmd() As Integer = new Integer(5) {}
        cmd(0) = &H81       ' Mode (S-Curves, Accel/Decel Mode 1)
        cmd(1) = 100        ' Acceleration Rate (100 in/s/s)
        cmd(2) = 100        ' Deceleration Rate (100 in/s/s)
        cmd(3) = 10000      ' Requested Speed (10 in/s)
        cmd(4) = 4000       ' Requested Position (4 in)
        cmd(5) = Asc("G")   ' Go (G) Command
        rmc.WriteLFile(FileNumber100.fn100CommandAxis0,0,cmd,0, _
            Constants100.rmc100CmdRegsPerAxis);
 
        ' Disconnect from the controller.
        rmc.Disconnect()
 
    End Sub
End Module

 

C#

using System;
using RMCLinkNET;
 
namespace Example
{
    public class Program
    {
        static void Main()
        {
            // Create the object itself.
            RMCLink rmc = RMCLink.CreateEthernetLink(DeviceType.RMC100, "192.168.0.10");
 
            // Connect to the controller.
            rmc.Connect();
 
            // Issue a Go (G) command to Axis 0 (registers L8:0-5).
            int[] cmd = new int[6];
            cmd[0] = 0x0081;    // Mode (S-Curves, Accel/Decel Mode 1)
            cmd[1] = 100;       // Acceleration Rate (100 in/s/s)
            cmd[2] = 100;       // Deceleration Rate (100 in/s/s)
            cmd[3] = 10000;     // Requested Speed (10 in/s)
            cmd[4] = 4000;      // Requested Position (4 in)
            cmd[5] = (int)'G';  // Go (G) Command
            rmc.WriteLFile(FileNumber100.fn100CommandAxis0,0,cmd,0,
                Constants100.rmc100CmdRegsPerAxis);
 
            // Disconnect from the controller.
            rmc.Disconnect();
        }
    }
}

 

C++

#include <windows.h>
#include <stdio.h>
#include "RMCLink.h"
 
void main()
{
    // In order to create COM objects, we must initialize the COM sub-system.
    ::CoInitialize(0);
 
    // Create a new RMCLink object.
    CRMCLink* pRMC = CRMCLink::CreateEthernetLink(CRMCLink::dtRMC100, _T("192.168.0.28"));
    if ( pRMC != NULL )
    {
        // Establish the connection.
        HRESULT hr = pRMC->Connect();
        if ( SUCCEEDED(hr) )
        {
            // Issue a Go (G) command to Axis 0 (registers L8:0-5).
            long alCmd[6];
            alCmd[0] = 0x0081; // Mode (S-Curves, Accel/Decel Mode 1)
            alCmd[1] = 100;    // Acceleration Rate (100 in/s/s)
            alCmd[2] = 100;    // Deceleration Rate (100 in/s/s)
            alCmd[3] = 10000;  // Requested Speed (10 in/s)
            alCmd[4] = 4000;   // Requested Position (4 in)
            alCmd[5] = 'G';    // Go (G) command
            hr = pRMC->WriteLFile(CRMCLink::fn100CommandAxis0, 0,
                CRMCLink::rmc100CmdRegsPerAxis, alCmd);
            if ( SUCCEEDED(hr) )
                printf("Command successfully written.");
            // Close the connection.
            pRMC->Disconnect();
        }
 
        // Free the RMCLink object we created.
        delete pRMC;
    }
 
    // Release the COM sub-system.
    ::CoUninitialize();
}

 

C++/CLI

using namespace System;
using namespace RMCLinkNET;
 
int main()
{
    // Create the object itself.
    RMCLink^ rmc = RMCLink::CreateEthernetLink(DeviceType::RMC70, "192.168.0.10");
 
    // Connect to the controller.
    rmc->Connect();
 
    // Issue a Go (G) command to Axis 0 (registers L8:0-5).
    array<int>^ cmd = gcnew array<int>(6);
    cmd[0] = 0x0081;    // Mode (S-Curves, Accel/Decel Mode 1)
    cmd[1] = 100;       // Acceleration Rate (100 in/s/s)
    cmd[2] = 100;       // Deceleration Rate (100 in/s/s)
    cmd[3] = 10000;     // Requested Speed (10 in/s)
    cmd[4] = 4000;      // Requested Position (4 in)
    cmd[5] = (int)'G';  // Go (G) Command
    rmc->WriteLFile(FileNumber100.fn100CommandAxis0,0,cmd,0,
        Constants100::rmc100CmdRegsPerAxis);
 
    // Disconnect from the controller.
    rmc->Disconnect();
 
    return 0;
}

 

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

How Do I Overview | RMCLink Component


Send comments on this topic.

Copyright (c) 2024 Delta Computer Systems, Inc. dba Delta Motion