Keyence Serial Communication with Visual Basic

rwj1313

Member
Join Date
May 2003
Posts
2
Hi,

I'm not new to programming PLC's but I have never done anything with serial communication from a PC to a PLC. I have a project I'm working on that I need to have a PC and a Keyence KV-24AR PLC communicate. I am writing a program in Visual Basic for the PC. There are 2 things that I need to do. I need to check the status of a contact (Open or Closed) with Visual Basic. I also need to be able to force the contact open or closed with Visual Basic. Does anybody know were I can find a sample of Visual Basic code that is being used to communicate with a Keyence PLC or even know how to do what I'm asking? I know that it can be done from what I've read in the Keyence programming manual but they are not clear on how to do it.

Thanks in advance,

Rick Jones
[email protected]
 
First, you need to know what protocol the Keyence uses on its serial port, and whether Keyence publishes the details of how to implement that protocol. If the details are available, then you can write your own code and apply it to a MSCOMM control in your VB application.

If you don't want to roll your own, you may be able to purchase a serial communications driver from Parijat http://www.parijat.com or Kepware http://www.kepware.com and incorporate it into your VB app.
 
>First, you need to know what protocol the Keyence uses on its serial >port, and whether Keyence publishes the details of how to implement >that protocol. If the details are available, then you can write your >own code and apply it to a MSCOMM control in your VB application.

Hi Steve,

I'm not sure what you mean by protocol but Keyence does publish the info. in their Keyence User's Manual for Programming.

Communication Parameters are listed as :
Duplex.................Full
Synchronization........Start/Stop
Data Format............ASCII
Baud Rate..............9600 bps
Data Length............8 Bits
Parity Check...........Even
Stop Bit Length........1 Bit
Delimiter..............CR

In the manual they state that when the KV is connected to a personal computer, the current value or preset value of timers,counters or contents of data memories in the KV can be loaded to and modified by the computer.

The Command Transmission Procedure is as follows:
1. Transmit a break signal (SD)
2. Transmit communications start command (CR)
3. Transmit a command (Note #1)
4. Receive a response
5. Transmit communications end command (CQ)

Note #1: An example of a command would be as follows:

(ST_nnnnn)
This is the command to force a relay "ON" where nnnnn is the number of the contact.

(RS_nnnnn)
This is the command to force a relay "OFF" where nnnnn is the number of the contact.

The manual list several pages of commands.

It looks like ST is Set and RS is reset...........maybe.
I know a little about MSCOMM. I am currently using it to read data from RF Tags that will be used on this same project.

Thanks,

Rick
 
What you've described from the Keyence manual is the protocol. You need to follow the directions explicitly. You also need to provide a method to deal with the responses from the Keyence. Normal response would be to acknowledge your command, but there has to be some sort of response if the PLC can't understand your message.

You also have to make sure that your MSCOMM control is set for the same baud rate, parity, etc settings as the PLC.
 
Writing a communications driver can be challenging. I suspect there is more involved in the Keyence string - most protocols also include some kind of checksum for error checking, a specific structure for the PLC address and register address, and so on. As Steve points out, when you get the response back from the read command for the bit status you will need to decode it. The response may be a simple 1 or 0 for the status, or it may be a whole word including the bit you are interested in so you have to strip the bits. You will probably also have to de-concatenate (isn't that a lovely word?) the string to remove headers and checksums and so on.

If Keyence publishes the protocol, they probably also publish sample programs in BASIC or C for the communications. Have you asked them?
 
Hello,

>can anybody post more ideas about this..

The protocol is described in chapter 7 of the manual.

As protocols go, IMHO, it is one of the simpler ones.
 

Similar Topics

In my application, I use a Keyence KV16DT PLC attached to a Proface ST HMI via a serial port. Does anybody know details of the serial...
Replies
5
Views
14,592
hi guys, can the keyence visual kv plc directly connect to a barcode scanner through rs232 to get the barcode data? i am planning to hook up two...
Replies
0
Views
2,913
Hello all I've got a cell with four Keyence IV3 cameras that are saving images to a FTP server, we are also labeling the parts with a time date...
Replies
3
Views
184
I will find cable series but I don't know for fs260 model, kindly suggestions and help to me for connect cable
Replies
1
Views
95
Hey guys, has anyone worked with any type of Keyence PLC and could share their experience with it? Vendor showed me camera footage reply of a work...
Replies
7
Views
1,073
Back
Top Bottom