日本語 English

How to Perform FINS Communication with CX-Compolet

With OMRON CX-Compolet, you can read and write PLC memory such as the DM and CIO areas via FINS communication. This article explains how to connect using the SysmacCJ component and how to read and write the DM area, with a C# sample.

What Is FINS Communication?

Explains how to access PLC memory areas such as DM, CIO and WR via Ethernet. In FINS communication, data is read and written by specifying addresses such as DM0000 or CIO100 rather than variable names.
Place SysmacCJ on the form with the instance name sysmacCJ1
SysmacCJ component placed in Visual Studio
The sample code below is written in C#
Creating the form (placing buttons, etc.) is omitted, so place buttons and so on as needed

Activate sysmacCJ1

To communicate, set the FINS address (network number, node number, unit number) of the target PLC and set the Active property to True
In the sample, these are set when the form loads

private void Form1_Load(object sender, EventArgs e)
{
	sysmacCJ1.NetworkAddress = 0;
	sysmacCJ1.NodeAddress = 1;
	sysmacCJ1.UnitAddress = 0;
	sysmacCJ1.Active = true;
}
	

Explanation

Lines 3-4

sysmacCJ1.NetworkAddress = 0;
sysmacCJ1.NodeAddress = 1;
sysmacCJ1.UnitAddress = 0;
sysmacCJ1.Active = true;
	

Set the FINS address of the destination PLC and set Active to True
Setting Active to True connects to the PLC at the destination FINS address

Reading DM

Clicking button1 executes the ReadMemory method and reads the values of DM0 to 9

private void button1_Click(object sender, EventArgs e)
{
	try
	{
		int[] value = (int[])sysmacCJ1.ReadMemory(OMRON.Compolet.SYSMAC.SysmacCSBase.MemoryTypes.DM, 0, 10, false);
		Console.WriteLine(value[0]);
	}
	catch(Exception ex)
	{
		Console.WriteLine(ex.Message);
	}
}
	

Explanation

Line 5


int[] value = (int[])sysmacCJ1.ReadMemory(OMRON.Compolet.SYSMAC.SysmacCSBase.MemoryTypes.DM, 0, 10, false);
	

ReadMemory reads 10 words from DM0
The return value is of type Object, so it is cast to int[] and stored in value

Writing DM

Clicking button2 executes the WriteMemory method and writes values to DM0 to 2

private void button2_Click(object sender, EventArgs e)
{
	try
	{
		int[] value = new int[3];
		value[0] = 1;
		value[1] = 2;
		value[2] = 3;

		sysmacCJ1.WriteMemory(OMRON.Compolet.SYSMAC.SysmacCSBase.MemoryTypes.DM, 0, value);
	}
	catch(Exception ex)
	{
		Console.WriteLine(ex.Message);
	}
}
	

Explanation

Lines 5-8


int[] value = new int[3];
value[0] = 1;
value[1] = 2;
value[2] = 3;
	

Set the values to write

Line 10


sysmacCJ1.WriteMemory(OMRON.Compolet.SYSMAC.SysmacCSBase.MemoryTypes.DM, 0, value);
	

WriteMemory writes the values of Value starting at DM0

Related pages

Comments