RMCLink Component

How to: Use the RMC70 Indirect Data Map

The Indirect Data Map maps up to 64 registers from anywhere in the RMC70 to an array. The intent of this structure is to allow packing of otherwise non-contiguous data together for efficient I/O and messaging communications.

For example, if you wish to read or write to 20 various registers that are located all over the register map, you have two options, neither of which is efficient. First, to read a very large block of registers and use only the registers you are interested in, or second, to read many very small blocks of registers. To avoid these inefficiencies, the Indirect Data Map allows you to map these registers to contiguous registers (registers that are located next to each other), which will require only one read or write to that block of registers.

Setting Up the Indirect Data Map

You can map as many of the Indirect Data Map entries as you would like. A maximum of 64 registers can be mapped. The  Indirect Data Map mapping can be set up in RMCTools:

  1. Open the Indirect Data Map Editor.

  2. In the Reg# column of each Indirect Data Map entry, enter the RMC70 register you want to map. Click the ellipsis button to search for a register.

  3. Download the project to the RMC70.

Example

The user would like to put some of the RMC70 registers in the Indirect Data Map so that it will speed up the communications. The user decides to put the following registers in the Indirect Data Map:

  • Axis 0 Status Bits

  • Axis 0 Error Bits

  • Axis 0 Actual Position

  • Axis 0 Target Position

  • Axis 1 Status Bits

  • Axis 1 Error Bits

  • Axis 1 Actual Position

  • Axis 1 Target Position

The user then sets up the Indirect Data Map like this:

 

Now, instead of reading eight registers in various locations, the user can read them in one block of eight registers beginning at %MD18.0.

Using the Indirect Map

Once the Indirect Data Map has been set up in RMCTools and downloaded to the RMC70, you can read and write to the RMC70 Indirect Data registers %MD18.0 to %MD18.31. The reads and writes will be as if done to each mapped register.

Handling Different Data Types

Typically, the data types of the mapped registers will be different. For example, the Status bits are an L register (32-bit word), whereas the Actual Position is a 32-bit floating-point decimal number. When a read or write is done to the Indirect Data Map, the data is in an array of data with the same type. To convert between types, use the FRegToLReg and LRegToFReg methods.

Example

The following code example illustrates using the RMC70's Indirect Data Map from Visual Basic .NET. The code is similar for other languages. Notice that this example assumes that the Indirect Data Map has been set up as described in the code comments below.

Visual Basic .NET

Imports RMCLinkNET
 
Module Example
    Sub Main()
        ' Create the object itself.
        Dim rmc As RMCLink = RMCLink.CreateSerialLink(DeviceType.RMC70, "COM1")
 
        ' Connect to the controller.
        rmc.Connect()
 
        ' Assume that the Indirect Data Map has been set up so that its
        ' first eight registers correspond to the following:
        '   %MD18.0 = Axis 0 Status Bits (L register)
        '   %MD18.1 = Axis 0 Error Bits (L register)
        '   %MD18.2 = Axis 0 Actual Position (F register)
        '   %MD18.3 = Axis 0 Target Position (F register)
        '   %MD18.4 = Axis 1 Status Bits (L register)
        '   %MD18.5 = Axis 1 Error Bits (L register)
        '   %MD18.6 = Axis 1 Actual Position (F register)
        '   %MD18.7 = Axis 1 Target Position (F register)
 
        ' Read up all eight registers in a single read.
        Dim data() as Single = New Single(7) {}
        rmc.ReadFFile(FileNumber70.fn70IndDataValues, 0, data, 0, 8)
 
        ' At this point, data holds all eight values. However, since
        ' items 0,1,4 and 5 were strictly L registers, they cannot be used
        ' directly, since data(0) would return a bogus floating point
        ' value. Therefore, we use the FRegToLReg method. Notice that
        ' the F register values are used normally.
        Console.WriteLine(String.Format("Axis 0 Status Bits     = 0x{0:X8}", RMCLink.FRegToLReg(data(0))));
        Console.WriteLine(String.Format("Axis 0 Error Bits      = 0x{0:X8}", RMCLink.FRegToLReg(data(1))));
        Console.WriteLine(String.Format("Axis 0 Actual Position =   {0,-8:F3}", data(2)));
        Console.WriteLine(String.Format("Axis 0 Target Position =   {0,-8:F3}", data(3)));
        Console.WriteLine(String.Format("Axis 1 Status Bits     = 0x{0:X8}", RMCLink.FRegToLReg(data(4))));
        Console.WriteLine(String.Format("Axis 1 Error Bits      = 0x{0:X8}", RMCLink.FRegToLReg(data(5))));
        Console.WriteLine(String.Format("Axis 1 Actual Position =   {0,-8:F3}", data(6)));
        Console.WriteLine(String.Format("Axis 1 Target Position =   {0,-8:F3}", data(7)));
 
        ' Disconnect from the controller.
        rmc.Disconnect()
 
    End Sub
End Module 

 

See Also

How Do I Overview | RMCLink Component


Send comments on this topic.

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