RMCLink Component

How to: Send RMC150 Commands

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

Commands are issued by writing to the Command Area, which is located in file 40. This area consists of 10 registers per axis. %MD40.0-9 hold the command for axis 0, %MD40.11-19 hold the command for axis 1, and so on. The first register for each axis is the command number, and the next five registers are Command Parameters 1-9. The meaning of the command parameters vary depending on the command selected by the first register.

When an outside source writes to the Command Area, 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. Therefore, to issue commands to axes 0 and 1 at the same time, write 20 registers starting at %MD40.0.

Notice that a special command of No-Op (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 30 registers starting at %MD40.0, but make sure that the value written to %MD40.10 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 RMC150:

Refer to the example below.

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

Command Request and Acknowledge Bits

The Command Request and Acknowledge bits works as they normally do when used via RMCLink.

The Command Request and Command Acknowledge bits provide synchronization of commands and status information between the host controller and RMC. These bits are always available, but using these bits is optional. For many applications, they are very important. When reading status bits and status registers, these bits let the host controller know that the data being requested is valid. For example, after a Move command is issued, the In Position status bit is not valid until the RMC has informed the host controller that it received the command. The RMC does this by matching the Command Acknowledge bit to the Command Request bit.

See the Command Request and Acknowledge Bits topic in the RMCTools help for more details.

Example

The following code example illustrates sending commands to an RMC150.

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(dtRMC150, "192.168.0.22")
 
    ' Establish the connection.
    rmc.Connect
 
    ' Issue a Move Absolute command to Axis 0 (registers %MD40.0-9).
    Dim data(9) As Single
    data(0) = 20    ' Move Absolute (20)
    data(1) = 10.5  ' Requested Position (10.5 in)
    data(2) = 12.5  ' Requested Speed (12.5 in/s)
    data(3) = 100   ' Acceleration Rate (100 in/s/s)
    data(4) = 100   ' Deceleration Rate (100 in/s/s)
    data(5) = 0     ' Direction (0=nearest)
    data(6) = 0     ' unused
    data(7) = 0     ' unused
    data(8) = 0     ' unused
    data(9) = 0     ' unused
    rmc.WriteFFile fn150CommandArea, 0, rmc150CmdRegsPerAxis, 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.RMC150, "192.168.0.10")
 
        ' Connect to the controller.
        rmc.Connect()
 
        ' Issue a Move Absolute (20) command to Axis 0 (registers %MD40.0-9).
        Dim cmd() As Single = new Single(9) {}
        cmd(0) = 20     ' Move Absolute (20)
        cmd(1) = 10.5   ' Requested Position (10.5 in)
        cmd(2) = 12.5   ' Requested Speed (12.5 in/s)
        cmd(3) = 100.0  ' Acceleration Rate (100 in/s/s)
        cmd(4) = 100.0  ' Deceleration Rate (100 in/s/s)
        cmd(5) = 0      ' Direction (0=Nearest)
        cmd(6) = 0      ' unused
        cmd(7) = 0      ' unused
        cmd(8) = 0      ' unused
        cmd(9) = 0      ' unused 
        rmc.WriteFFile(FileNumber150.fn150CommandArea,0,cmd,0, _
            Constants150.rmc150CmdRegsPerAxis);
 
        ' 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.RMC150, "192.168.0.10");
 
            // Connect to the controller.
            rmc.Connect();
 
            // Issue a Move Absolute (20) command to Axis 0 (registers %MD40.0-9).
            float[] cmd = new float[10];
            cmd[0] = 20;    // Move Absolute (20)
            cmd[1] = 10.5;  // Requested Position (10.5 in)
            cmd[2] = 12.5;  // Requested Speed (12.5 in/s)
            cmd[3] = 100.0; // Acceleration Rate (100 in/s/s)
            cmd[4] = 100.0; // Deceleration Rate (100 in/s/s)
            cmd[5] = 0;     // Direction (0=Nearest)
            cmd[6] = 0;     // unused
            cmd[7] = 0;     // unused
            cmd[8] = 0;     // unused
            cmd[9] = 0;     // unused             rmc.WriteFFile(FileNumber150.fn150CommandArea,0,cmd,0,
                Constants100.rmc150CmdRegsPerAxis);
 
            // 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::dtRMC150, _T("192.168.0.22"));
    if ( pRMC != NULL )
    {
        // Establish the connection.
        HRESULT hr = pRMC->Connect();
        if ( SUCCEEDED(hr) )
        {
            // Issue a Move Absolute command to Axis 0 (registers %MD40.0-9).
            float afCmd[10];
            afCmd[0] = 20;   // Move Absolute (20)
            afCmd[1] = 10.5; // Requested Position (10.5 in)
            afCmd[2] = 12.5; // Requested Speed (12.5 in/s)
            afCmd[3] = 100;  // Acceleration Rate (100 in/s/s)
            afCmd[4] = 100;  // Deceleration Rate (100 in/s/s)
            afCmd[5] = 0;    // Direction (0=nearest)
            afCmd[6] = 0;    // unused
            afCmd[7] = 0;    // unused
            afCmd[8] = 0;    // unused
            afCmd[9] = 0;    // unused
            hr = pRMC->WriteFFile(CRMCLink::fn150CommandArea, 0,
                CRMCLink::rmc150CmdRegsPerAxis, afCmd);
            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::RMC150, "192.168.0.10");
 
    // Connect to the controller.
    rmc->Connect();
 
    // Issue a Move Absolute command to Axis 0 (registers %MD40.0-9).
    array<float>^ cmd = gcnew array<float>^(10);
    cmd[0] = 20;    // Move Absolute (20)
    cmd[1] = 10.5;  // Requested Position (10.5 in)
    cmd[2] = 12.5;  // Requested Speed (12.5 in/s)
    cmd[3] = 100.0; // Acceleration Rate (100 in/s/s)
    cmd[4] = 100.0; // Deceleration Rate (100 in/s/s)
    cmd[5] = 0;     // Direction (0=Nearest)
    cmd[6] = 0;     // unused
    cmd[7] = 0;     // unused
    cmd[8] = 0;     // unused
    cmd[9] = 0;     // unused
    rmc.WriteFFile(FileNumber150::fn150CommandArea,0,cmd,0,
        Constants100::rmc150CmdRegsPerAxis);
 
    // 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 (dtRMC150=3).
Set rmc = srv.CreateEthernetLink(3, "192.168.0.22")
 
' Establish the connection.
rmc.Connect
 
' Issue a Move Absolute command to Axis 0 (registers %MD40.0-9).
Dim data(9)
data(0) = 20    ' Move Absolute (20)
data(1) = 10.5  ' Requested Position (10.5 in)
data(2) = 12.5  ' Requested Speed (12.5 in/s)
data(3) = 100   ' Acceleration Rate (100 in/s/s)
data(4) = 100   ' Deceleration Rate (100 in/s/s)
data(5) = 0     ' Direction (0=nearest)
data(5) = 0     ' unused
data(7) = 0     ' unused
data(8) = 0     ' unused
data(9) = 0     ' unused
rmc.WriteFFile 40,0,10,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 (dtRMC150=3).
var rmc = srv.CreateEthernetLink(3, "192.168.0.22");
 
// Establish the connection.
rmc.Connect();
 
 // Issue a Move Absolute command to Axis 0 (registers %MD40.0-9).
var data = new Array(10);
data[0] = 20;   // Move Absolute (20)
data[1] = 10.5; // Requested Position (10.5 in)
data[2] = 12.5; // Requested Speed (12.5 in/s)
data[3] = 100;  // Acceleration Rate (100 in/s/s)
data[4] = 100;  // Deceleration Rate (100 in/s/s)
data[5] = 0;    // Direction (0=nearest)
data[6] = 0;    // unused
data[7] = 0;    // unused
data[8] = 0;    // unused
data[9] = 0;    // unused
rmc.WriteFFile(40,0,10,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