Sign in to follow this  
Followers 0
vangough

ASCII/Serial Communications with KV PLC with VB6

2 posts in this topic

I need a little help. I am trying to communicate with a Keyence KV-40 PLC from Visual Basic. Ideally I would like to read some data memories and I/O status back to VB. I have read some of the other posts below and read the manual and will be the first to admit that it shouldn't be that difficult. However, I have tried using a terminal program with my protocol analyzer as well as programming a very simple querry in VB (asking the plc what mode it is in ?M i think) and if I get any response back from the PLC at all I get E1 which means that it didn't like the format of my request. I am sending the following at 9600,8,n,1 Send Break send CR followed by carrage return send ?M or any other command from the book followed by carrage return send CQ followed by carriage return I asked my keyence rep if he had any example code for VB to communicate with the KV but he has been unable to find anything other than the old quickbasic example in the book. Obviously I am missing something simple or doing something stupid here, does anyone have an example of how to talk to this thing with VB that they would be willing to share with me so that I can figure out what I am doing wrong here. Thanks Van Gough vangough@aol.com

Share this post


Link to post
Share on other sites
Hi! I'd some experience for you. 1.using mscomm32.ocx for communication between VB or Delphi to PLC. 2. Form_load() mscomm1.settings = "9600,e,8,1" // setting the same instruction manual mscomm1.comport = 1 // com port #1 mscomm1.portopen = true 3. send the signal from PC->PLC mscomm1.output = chr(67)+chr(82)+chr(13) // sending "C""R" and carrie return for connect to PLC mscomm1.output = "ST 0501" + chr(13) // set output 501 to "ON" 4. recieve signal from PLC mscomm1_oncomm event msgbox mscomm1.input // display message box for input signal remark : before writing with VB,you should test communication between PC & PLC by software "Hyper Terminal" that's include with MS Windows all version in communication menu. Wish you success. Note : If sometimes you can not communicate with PLC,you must create the loop program to send the "C""R" and carrie return from PC to PLC until it'd not show "E1" and show "CC" for success commnucating. Wish you success.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0