Jump to content

jaiven05

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by jaiven05

  1. Hi,

    I should let you know right off the back that I a brand new to programming in C#.

    My objective in this project is to communicate to a DL05 PLC. I want to create a directNET library in C# in order to accomplish this task. From the DirectNET manual I found that In order to "Read Request" I need to first initiate request, define request, acknowledge receipt of data, finish. And in order to "Write Request" I need to initiate request, Defin Request, Transmit Data, and finish.

    Now, my question is:

    using System;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Data;

    using System.Drawing;

    using System.Linq;

    using System.Text;

    using System.Windows.Forms;

    using System.Net.Sockets;

    using Modbus;

    namespace Ethernet

    {

    public partial class Form1 : Form

    {

    public Form1()

    {

    InitializeComponent();

    }

    private void button1_Click(object sender, EventArgs e)

    {

    ushort[] clock4rmPLC = new ushort [7];

    TcpClient Tcp = new TcpClient("192.168.1.100", 502 );

    Modbus.Device.ModbusIpMaster myBus = Modbus.Device.ModbusIpMaster.CreateIp(Tcp);

    // ushort[] = memory4rmPLC;

    clock4rmPLC = myBus.ReadHoldingRegisters(4086, 7); //Converted Octal number to a Decimal number. Increment 4 points from 4086

    }

    private void button2_Click(object sender, EventArgs e)

    {

    ushort[] clock4rmPLC = new ushort[7];

    TcpClient Tcp = new TcpClient("192.168.1.100", 502);

    Modbus.Device.ModbusIpMaster myBus = Modbus.Device.ModbusIpMaster.CreateIp(Tcp);

    // ushort[] = memory4rmPLC;

    clock4rmPLC = myBus.ReadHoldingRegisters(1024, 1); //Converted Octal number to a Decimal number. Using 1024 becuase it is the decimal value of octal 2000

    }

    }

    }

    Question:

    Can the code I pasted in (which is used to connect to a DL06 PLC via Modbus library in C#) be used with slight modifications?

    Advice is much appreciated!

×
×
  • Create New...