Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
how to communication Ab plc to c# or .net code to read write data without scada
i have rs linxs classic lite
plc data export in excle

What I have tried:

plz help me i dont know about c#  code so plz hepl to provide any code
Posted
Updated 2-Mar-23 19:00pm
Comments
Richard MacCutchan 5-Sep-22 3:49am    
You will need to provide more details of your problem; it is not clear exactly what you are trying to do. Also, you need to understand that this site does not provide code to order.
OriginalGriff 5-Sep-22 3:58am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - we get no other context for your project.
Imagine this: you go for a drive in the country, but you have a problem with the car. You call the garage, say "it broke" and turn off your phone. How long will you be waiting before the garage arrives with the right bits and tools to fix the car given they don't know what make or model it is, who you are, what happened when it all went wrong, or even where you are?

That's what you've done here. So stop typing as little as possible and try explaining things to people who have no way to access your project!

Use the "Improve question" widget to edit your question and provide better information.

A very simple step would be to buy a third-party support driver based on your choice of PLC and choice of protocols you select. If you are looking at a hard way [pun intended] then I would suggest you start learning a little more about how the PLC communication works. Anyways AdvancedHMI is one of the options that can make your life easy. Just google it, they have a very good forum and have all the basic drivers required to connect to multiple controllers.
 
Share this answer
 
using libplctag;
using libplctag.DataTypes;
using Microsoft.VisualBasic;

namespace PLC_Communication
{
    public partial class Form1 : Form
    {

        Tag<DintPlcMapper, int> N7;
        Tag<RealPlcMapper, float> F8;
        
        public Form1()
        {

            InitializeComponent();

            //Init Tag
           N7 = new Tag<DintPlcMapper, int>()
            {
                Name = "N7:0",
                Gateway = "192.168.1.1",
            
                PlcType = PlcType.MicroLogix,
                Protocol = Protocol.ab_eip,
                Timeout = TimeSpan.FromSeconds(5)
            };
         F8 = new Tag<RealPlcMapper, float>()
            {
                Name = "F8:0",
                Gateway = "192.168.1.1",
              
                PlcType = PlcType.MicroLogix,
                Protocol = Protocol.ab_eip,
                Timeout = TimeSpan.FromSeconds(5)
            };

            //Thread
            Thread plcUpdateThread=new Thread(new ThreadStart(plcThread));
            plcUpdateThread.Start();
        }

        void plcThread()
        {
            while (true)
            {
                
                F8.Read();
                int temp = N7.Value;
                float temp2=F8.Value;
                tempField.Text = Convert.ToString(Convert.ToString(temp2));
                dintField.Text = Convert.ToString(temp);
            }
        }

        private void dintField_TextChanged(object sender, EventArgs e)
        {
            status.Text = "Value Update";
        }

        private void change2_Click(object sender, EventArgs e)
        {
            string input=Interaction.InputBox("Input Value", "Input new Value");
            if(input != null)
            {
                int val;
                if (Int32.TryParse(input, out val))
                {
                   N7.Value = val;
                    N7.Write();
                } else
                {
                    MessageBox.Show("Invalid Input", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900