RMCLink.Interop .NET Assembly

RMCLink.LRegToFReg Method

Converts an L register value into an intermediate form used when writing mixed F and L registers with WriteFFile.

Syntax

Visual Basic (Declaration)

Shared Public Function LRegToFReg ( _

   registerValue As Integer, _

) As Single

 

Visual Basic (Usage)

Dim registerValue As Integer

Dim returnValue As Single

 

returnValue = RMCLink.LRegToFReg(registerValue)

 

C#

static public float LRegToFReg (

   int registerValue

)

 

Visual C++/CLI

public:

static float LRegToFReg (

   int registerValue

)

Parameters

registerValue

The value of the L register.

Return Value

The same regValue L register value, but as a System.Single data type ready to write with WriteFFile. Notice that this value is not usable at this stage. That is, it will appear to be a garbage value.

Remarks

This function is used when writing to L registers in an RMC70, RMC150, or RMC200 using the WriteFFile method. Notice that this should only be done when the write is writing a mixture of L and F registers. Otherwise the WriteLFile method should be used to write exclusively F registers. Refer to the RMC70, RMC150 and RMC200 Register Data Types topic for details on L and F register types and on how to mix the two in a single read or write.

Exceptions

No exceptions are generated by this method.

Example

The following code example illustrates the use of the LRegToFReg method.

Visual Basic

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 first two variables are defined as follows:
        '   L56:0 - LoopCount (DINT, L register)
        '   F56:1 - SetPoint (REAL, F register)
        ' We want to write to both is a single write, but because they
        ' are mixed L and F registers, we must use the special LRegToFReg
        ' function to place the L register values in the array.
        Dim data() As Single = New Single(1) {}
        data(0) = RMCLink.LRegToFReg(4) ' LoopCount will be 4.
        data(1) = 10.5                  ' SetPoint will be 10.5.
 
        ' Write to these two registers.
        rmc.WriteFFile(FileNumber70.fn70VarCurValues, 0, data, 0, 2);
 
        ' 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.CreateSerialLink(DeviceType.RMC70, "COM1");
 
            // Connect to the controller.
            rmc.Connect();
 
            // Assume that the first two variables are defined as follows:
            //   L56:0 - LoopCount (DINT, L register)
            //   F56:1 - SetPoint (REAL, F register)
            // We want to write to both is a single write, but because they
            // are mixed L and F registers, we must use the special LRegToFReg
            // function to place the L register values in the array.
            float[] data = new float[2];
            data[0] = RMCLink.LRegToFReg(4); // LoopCount will be 4.
            data[1] = 10.5;                  // SetPoint will be 10.5.
 
            // Write to these two registers.
            rmc.WriteFFile(FileNumber70.fn70VarCurValues, 0, data, 0, 2);
 
            // Disconnect from the controller.
            rmc.Disconnect();
        }
    }
}

 

Visual C++/CLI

using namespace System;
using namespace RMCLinkNET;
 
int main()
{
    // Create the object itself.
    RMCLink^ rmc = RMCLink::CreateSerialLink(DeviceType::RMC70, "COM1");
 
    // Connect to the controller.
    rmc->Connect();
 
    // Assume that the first two variables are defined as follows:
    //   L56:0 - LoopCount (DINT, L register)
    //   F56:1 - SetPoint (REAL, F register)
    // We want to write to both is a single write, but because they
    // are mixed L and F registers, we must use the special LRegToFReg
    // function to place the L register values in the array.
    array<float>^ data = gcnew array<float>(2);
    data[0] = RMCLink::LRegToFReg(4); // LoopCount will be 4.
    data[1] = 10.5;                   // SetPoint will be 10.5.
 
    // Write to these two registers.
    rmc->WriteFFile(FileNumber70::fn70VarCurValues, 0, data, 0, 2);
 
    // Disconnect from the controller.
    rmc->Disconnect();
 
    return 0;
}

 

See Also

RMCLink.Interop .NET Assembly | RMCLinkNET Namespace | RMCLink Class


Send comments on this topic.

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