Results 1 to 11 of 11

Thread: serial Communication between PLC and C#

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Location
    Mumbai
    Posts
    2

    serial Communication between PLC and C#

    Hi All

    I am working on a project where I have to design a front end(on C#) and have to display the data coming from PLC.

    Can you all please let me know that

    1. What name space I have to used.
    2. What function I have to used for Serial communication.
    3. What .dll file I have to add in my project.
    4. Any more idea if you have then please let me know.


    Waiting for your reply its urgent.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: serial Communication between PLC and C#

    Quote Originally Posted by bksingh View Post
    I am working on a project where I have to design a front end(on C#)
    Then why have you posted in the VB.NET forum? I've asked the mods to move this to the C# forum.

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Location
    Mumbai
    Posts
    2

    Re: serial Communication between PLC and C#

    Quote Originally Posted by jmcilhinney View Post
    Then why have you posted in the VB.NET forum? I've asked the mods to move this to the C# forum.
    I wanted to do in both i.e. vb.net and asp.net also.

    So can you plz help me in vb.net....

  4. #4
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: serial Communication between PLC and C#

    This is better to be posted on the API forum.You will have to manipulate the exposed methods of the specific PLC dll(that we know nothing about).Look at the manual for the file you are using.If no exposed methods exists we probably can't help you at all.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  5. #5
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: serial Communication between PLC and C#

    Hello,

    You are not going to get an out of the box namespace to do this for you.

    In order to be vendor agnostic, you would be better looking for an OPC Server to provide the data from the PLC, and then have your ASP.Net Application, talk via an OPC Client to grab the data that you want to display.

    Gary

  6. #6
    Fanatic Member
    Join Date
    Sep 2009
    Location
    Lakewood, Colorado
    Posts
    621

    Re: serial Communication between PLC and C#

    1. The SerialPort control in the Toolbox (System.IO.Ports.SerialPort)
    2. Send data using a Write method; use the Read method or a variation to receive data.
    3. SerialPort is part of the .NET Framework, thus you do not have to use a separate dll.
    4. There are lots of examples available online. For example, you can download the EnhancedSerialPort example from my website (www.hardandsoftware.net). This does use a dll, which is included (because of the "enhancements"), but the code that is included will work with the built-in SerialPort object.

    I cannot offer any specifics for your PLC. The manufacturer should provide information on the protocol to be used. This might be ModBus, which is often used, though the PLC might employ its own serial protocol.

    Dick
    Richard Grier, Consultant, Hard & Software
    Microsoft MVP (Visual Basic)

  7. #7
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: serial Communication between PLC and C#

    Hello,

    I have merged the two threads that were created for this topic, and I have placed the result into the ASP.Net forum.

    bksingh, please do not create two threads for the same question.

    Thanks

    Gary

  8. #8
    Junior Member
    Join Date
    Aug 2008
    Posts
    24

    Re: serial Communication between PLC and C#

    What make and model PLC?

  9. #9
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: serial Communication between PLC and C#

    Quote Originally Posted by arj3090 View Post
    What make and model PLC?
    Although a valid question, I would have said that at this point, that doesn't really matter. In order to be useful, any application that talks to a PLC, or any form of DCS, needs to be vendor agnostic. If you connect directly to a particular PLC, using any form of their API, you are limiting yourself only to that vendor going forward.

    That is why it would be much better to move up a level to OPC, or even OPC UA, and have your application communicate using this protocol, that way your application can talk to any vendor.

    Gary

  10. #10
    Junior Member
    Join Date
    Aug 2008
    Posts
    24

    Re: serial Communication between PLC and C#

    Quote Originally Posted by gep13 View Post
    That is why it would be much better to move up a level to OPC, or even OPC UA, and have your application communicate using this protocol, that way your application can talk to any vendor.
    OPC DA may give the most options in the way of various vendor's PLCs, but is by no means the easiest to use. It is based on ActiveX technology which is not ideal for .NET languages. It also requires 3rd party software installation with run time fees for every deployment. The requirement to install a 3rd party software then takes away the option to XCOPY deploy a .NET app.

    OPC UA can be more .NET friendly, but lacks in the number of available drivers and wide acceptance when compared to DA.

    There are many driver options available that are natively .NET including some that are open source and/or free. Some PLCs use open and published protocols that give the option of developing your own driver although this can get very involved.

  11. #11
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: serial Communication between PLC and C#

    Quote Originally Posted by arj3090 View Post
    OPC UA can be more .NET friendly, but lacks in the number of available drivers and wide acceptance when compared to DA.
    Agreed, but the OPC UA Foundation provide a OPC UA Server which can expose any COM OPC Server to OPC UA. I have spoken to at least one vendor who is spefically NOT creating their own OPC UA Server, since there is already a system in place to "translate" from COM OPC to OPC UA.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width