Visual basic .net and PLC-VBForums
Results 1 to 7 of 7

Thread: Visual basic .net and PLC

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2010
    Posts
    4

    Visual basic .net and PLC

    Hi all,
    currently, i am working out with the visual basic and PLC. i decide to use serial port(rs232/usb) to connect between both. but i do not know how to write the code and protocol in vb.net. The PLC that i use is omron CQM1H-CPU21. Anyone can provide me more information or guidance on this?
    thanks

    kokhong

  2. #2
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Pointless Forest 38.517,-92.023
    Posts
    7,966

    Re: Visual basic .net and PLC

    Is this work related? How good at VB are you? How good at SerialPorts?
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- SerialPort Answer

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein
    "They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety." Benjamin Franklin
    "It is not all that I know that is the problem, it is all I think I do that is."

  3. #3
    Fanatic Member
    Join Date
    Mar 2008
    Posts
    519

    Re: Visual basic .net and PLC

    I have no experience on working with PLC but as most of the threads I've read on this forum that's about communication through SerialPorts, the best way to find information is to read the manual of your apparatus.

    Then you can specify some more information and try somethings out for yourself and if it doesn't work, post what you've tried and what error you get, possibly what you think could be wrong and it will be easier for us to help you

    *EDIT* Also, if you don't have that much experience with SerialPorts, I recommend reading dbasnett's post about Serial Port which you can find in his signature

  4. #4

    Thread Starter
    New Member
    Join Date
    Aug 2010
    Posts
    4

    Re: Visual basic .net and PLC

    actually i have tried out to look for the user munual of the PLC, it does not provide much information on this. Anyway, thanks for your information. i will try to find more stuff on that. Any problem, i will post it up.tq

  5. #5
    Junior Member
    Join Date
    Aug 2008
    Posts
    21

    Re: Visual basic .net and PLC

    Some Omron PLCs use the HostLink protocol which is fairly simple to implement.

    I have some code I did several years ago and this is the string I sent to the PLC to get data:

    request="@00RR02050006"
    request = request & GetChecSum(Request) & "*" & Chr(13)

    I can email you the whole program if you give me an email address. It was a gateway between Beckhoff TwinCAT and an Omron PLC.

  6. #6

    Thread Starter
    New Member
    Join Date
    Aug 2010
    Posts
    4

    Smile Re: Visual basic .net and PLC

    This is my email address wongkh_54@hotmail.com..To simplify what is my project, i will give a example here.

    If the input port 1 of PLC is triggered, some event in Visual Basic .Net will be triggered (example: show message box: input one is trigger). And when input port 1 is back to 0, message box disappeared.

    If the input port 2 of PLC is triggered, some event in Visual Basic .Net will be triggered (example: show message box: input two is trigger). And when input port 2 is back to 0, message box disappeared.

    Is it possible my Visual Basic .Net support this?

    Thank you.

  7. #7
    Fanatic Member
    Join Date
    Sep 2009
    Location
    Lakewood, Colorado
    Posts
    620

    Re: Visual basic .net and PLC

    What you have to do depends on the communications protocol that is implemented by the PLC. Some PLCs can be configure to use the ModBus protocol, or their own (usually simpler) proprietary protocol. In either case, what you have to do is to send a serial command to the PLC to perform one or more input functions, then wait until the PLC responds -- or there is a timeout. The code to request data might best be implemented in a Timer control Tick event, and the wait for response code implemented in a simple routine that polls for receive data and parses whatever data is returned.

    I have a number of similar command/response implementations in my book, Visual Basic Programmer's Guide to Serial Communications 4 (none for your specific PLC, however, because I haven't used it). Each is different from the other, in some small or larger detail, because the actual code requires converting the manufactuer's documentation into code; and unless this is a standard protocol, the code will vary by device.

    So, the first step is to go to the manufactuer's web site and download programming information, if you don't already have it. They may even have example code that you can port to your specific needs. If they don't have an example that matches what you need (or you don't understand what is said), provide a link to the documentation, and I or someone else here can suggest some code to start you off.

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

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.