How to Implement Omron PLC Host Link Protocol

The hostlink communication protocol is a method developed by Omron for communication to PLCs and other equipment. This ASCII-based protocol is used over RS232 or RS422/RS485. It is a many-to-one implementation which means that you can communicate with up to 32 devices back to a master. (1: N) This communication on the industrial floor can control PLCs, Temperature Controllers, Panel Meters, etc.

Our look at this protocol will include the wiring, setting of RS232 port settings, protocol format, and writing a VB6 program to read information from the PLC. I will also point you links to then store this information into a database and share it over an intranet/internet. Let’s get started.

Wiring Serial Port – Omron PLC Host Link Protocol

The wiring of the communication ports will depend on the equipment purchased. If communicating over 15 meters, it is recommended to switch to an RS422 or RS485 connection. However, I have seen RS232 runs of 50 meters without an issue. It will depend on your implementation and electrical noise in the plant.
CP1 communication wiring

The above diagram is the basic communication needed for RS232C. Note that the shield of the communication wire is connected only to one side. This ensures that any noise induced in the communication is filtered to one end.

Serial Settings – Omron PLC Host Link Protocol

Settings for RS232C communications are set in a number of ways. Older Omron C**K PLC was set through a series of dip switches. Current Omron SMR1/CPM1 PLCs are set though data memory locations.
Note: Most of the time, you need to cycle the power or switch to program/run mode for the setting to be activated.
How to Implement Omron PLC Host Link Protocol How to Implement Omron PLC Host Link Protocol

I generally tend to leave everything at the default settings: 9600 bps, Even parity, 7 data bits, 1 stop bit. The default host link unit number is 00. (32 max. – 00 – 31)

Protocol Format – Omron PLC Host Link Protocol

Each piece of equipment will have a list of parameters that can be read and written using the HostLink protocol. This can be found in the programming manual of the device. Here are the areas in the CPM1/CPM1A/CPM2A/CPM2C/SRM1(-V2) from the programming manual.

How to Implement Omron PLC Host Link Protocol

Let’s take a look at the command to read the DM area. All of the commands and responses will be in an ASCII format.

How to Implement Omron PLC Host Link Protocol

The command format begins with a ‘@‘ sign followed by the Node / Unit number that you wish to communicate. The header code is the command in which you wish to execute. (RD) This header code will determine the next series of information. In our case, the next four digits will be the beginning word followed by the next four digits to indicate the number of words. The next part of the command is the FCS (checksum) calculation. The comparison to this at each end will ensure that the command/response is correct. FCS is an 8-bit data converted into two ASCII characters. The 8 bits are a result of an Exclusive OR performed on the data from the beginning to the end of the text in the frame. In our case this would be performed on the following:


The last part of the command is the terminator. This is an ‘*’ followed by the character for the carriage return. (CHR$(13))

The response format begins with a ‘@’ sign followed by the Node / Unit number that you are communicating to. The header code is next (RD) followed by the End Code. The end code is a two-digit ASCII code that indicates the message response/errors when executing the action. A normal code of ’00’ indicates that everything is fine. See the operation manual for the entire list of end codes for your equipment. The next part of the response depends on the header code executed. In our case, it would contain the data requested. The last two parts of the response are the FCS and terminator just like the command format.

How to Implement Omron PLC Host Link Protocol

The above shows the timing of the command and responses.

Visual Basic VB6 (Example) – Omron PLC Host Link Protocol

Now let’s look at an example of reading the first 10 words from the DM area of an Omron PLC.

CP1 host link communication

The first step is the design the form. You can see that we have our ten DM area words set out to populate with values. We also have a T$ for transmitting. This will show what we are sending to the PLC. The RXD$ will show what the response will be from the PLC.

The MSComm is used to communicate through the serial ports of the computer. The following are the settings for the communication port.

How to Implement Omron PLC Host Link Protocol

Here is the VB6 code for the program:
When the form loads the Date/Time will get updated and Timer1 is enabled. This timer controls the interval in which the commands get executed. (Set to 1 second)

Private Sub Form_Load()
 Label2.Caption = Format(Date, "YYYY/MM/DD") + "    " + Format(Time, "HH:MM:SS")
 Timer1.Enabled = True
 End Sub

The following code will open the communication port, set the command format, send the command through the port, receive the response through the port and display the information. It will then close the communication port.

Private Sub Timer1_Timer()
 Timer1.Enabled = False
 MSComm1.PortOpen = True
 Label2.Caption = Format(Date, "YYYY/MM/DD") + "    " + Format(Time, "HH:MM:SS")
'Check DM AREA DM0000 to DM0009 data update
 T$ = "@00RD00000010"
 charreturn = 51
 GoSub FCS
 GoSub communicate
'Show Transmit information
 Label24.Caption = Buffer
 'Show Returned information
 Label26.Caption = rxd$
If Mid(rxd$, 6, 2) = "00" And (Len(rxd$)) >= charreturn Then
 Label4.Caption = Mid(rxd$, 8, 4)
 Label6.Caption = Mid(rxd$, 12, 4)
 Label8.Caption = Mid(rxd$, 16, 4)
 Label10.Caption = Mid(rxd$, 20, 4)
 Label12.Caption = Mid(rxd$, 24, 4)
 Label14.Caption = Mid(rxd$, 28, 4)
 Label16.Caption = Mid(rxd$, 32, 4)
 Label18.Caption = Mid(rxd$, 36, 4)
 Label20.Caption = Mid(rxd$, 40, 4)
 Label22.Caption = Mid(rxd$, 44, 4)
 End If
 Timer1.Enabled = True
 MSComm1.PortOpen = False
 Exit Sub

The following is the subroutine to communicate. Timer2 is the amount of time to wait before expecting an answer to the communication port. Once the command has been sent a maximum of two seconds is waited for a response. If no response nothing is returned. When the response is obtained, the FCS is checked and if correct the information is returned.

 rxd$ = ""
 Buffer = T$ + FCS$ + "*" + Chr$(13)
 MSComm1.Output = Buffer
 Timer2.Enabled = True
 Loop Until Timer2.Enabled = False
 If Time > #11:59:50 PM# Then
 timeout = #12:00:02 AM#
 timeout = DateAdd("s", 2, Time)
 End If
 MSComm1.InputLen = 0
 If timeout <= Time Then GoTo timeoutcom
 Loop Until MSComm1.InBufferCount >= charreturn
 rxd$ = MSComm1.Input
 fcs_rxd$ = Left((Right(rxd$, 4)), 2)
 If Left(rxd$, 1) = "@" Then
 T$ = Mid(rxd$, 1, (Len(rxd$) - 4))
 ElseIf Mid(rxd$, 2, 1) = "@" Then
 T$ = Mid(rxd$, 2, (Len(rxd$) - 5))
 rxd$ = Mid(rxd$, 2, (Len(rxd$) - 1))
 End If
 GoSub FCS
 If FCS <> fcs_rxd$ Then
 rxd$ = ""
 End If
 clearbuffer$ = MSComm1.Input

This is the FCS (checksum) calculation routine.

 L = Len(T$)
 A = 0
 For J = 1 To L
 TJ$ = Mid$(T$, J, 1)
 A = Asc(TJ$) Xor A
 Next J
 FCS$ = Hex$(A)
 If Len(FCS$) = 1 Then FCS$ = "0" + FCS$

This is the routine that will execute if the response is not received within the time period expected.

 clearbuffer$ = MSComm1.Input
 rxd$ = ""
End Sub

Timer2 was used as a delay before looking for a response after sending the command.

Private Sub Timer2_Timer()
 Timer2.Enabled = False
 End Sub
Here is the code running – Omron PLC Host Link Protocol

CP1 host link communication

Helpful Tips/Links:
– When troubleshooting serial communications it is sometimes helpful to use HyperTerminal. This program will send and receive information in/out of the serial ports.
HostLink Command Generator
HostLink Command Format

Watch on YouTube: How to Implement the Omron PLC Host Link Protocol

If you have any questions, need further information or would like a copy of this program please contact me.
Thank you,

If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLCs are not difficult to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII, and Floating Point.

To get this free article, subscribe to my free email newsletter.

Use the information to inform other people how numbering systems work. Sign up now.

How to Implement Omron PLC Host Link Protocol

The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.

12 thoughts on “How to Implement Omron PLC Host Link Protocol”

    • Hi Praveen,
      What is the model of temperature controller that you have? RS485 is the media for the communication, but what is the protocol?
      In some cases the PLC will have the built in protocols to communicate to the controller directly. What model of Omron PLC do you have?
      Thanks Praveen,

  1. I try to write at DM0011 using “@00WD0011000350*” cmd, but
    PLC back response is “@00WD0152*”. Yet the DM0011 content do not change to 3. What is the problem?
    I use CP1E-N20dr PLC type.

    • Hi Heris,
      The response code coming back is 01. If the command is executed correctly the response code would be 00.
      “@00WD” + Response code + FCS + Terminator
      In your case, we are getting “@00WD0152*”. 01 response code is that this cannot be executable in RUN mode.
      4-2 End Codes – Is a listing of all of the responses.
      To correct this problem, put the PLC in MONITOR mode when trying to write information to the PLC.
      You can do this through the CX programming software. Select monitor mode, or change the PLC System Setting area to automatically enter monitor mode.
      The above manual in section 3-1-2 CPU Unit Operating Modes will cover the parameters that need to be set.
      I hope this helps you out.

      • Thanks for your reply. It solve the problem.
        If I need to read/write data to other device that support Modbus-RTU using PLC, what communication mode should I choose? Could I also use this protocol too?

        • Hi Heris,
          The Modbus RTU protocol is similar to the Hostlink but you cannot mix them per network. You would have to use another serial port for the additional protocol.
          Here is an example of Modbus TCP with Excel. This will give you an idea of the protocol.

          This will also give you an example in

          Hope this helps you out.

        • Hi Heris ,
          Currently , We using model PLC PLC CP1H-X40DT-D and we have problem when we send data to PLC machine .
          – We use host link prototcol , R232 port .
          – we need send value =1 to PLC machine .
          The problem below :
          When they sent value 1 by PLC proram .
          And then I use MES program to send value 1 ( @00WD00400001000157* ) to PLC machine .
          PLC machine received is : @00WD0053* . It’s ok .
          But when turn off power and then turn on PLC machine .
          I use MES program send value 1 ( @00WD00400001000157* ) to PLC machine .
          PLC machine recived is : @00WD0152 , therefore It is not ok .
          Can you tell me what is problem ?
          Thank you very much .

          • Hi Hoang Van Luu,
            The received information is @OOWD0152. This code breaks down into the following:
            @00 – Unit number 0
            WD – Write DM area
            01 – Response Code – The command that was sent cannot be executed when the PC is in RUN mode.
            52 – FCS calculation
            Your program is working correctly.
            The PLC is in run mode. In order for the information to be written into the PLC, it must be in monitor mode.
            2-5-2 Status and Operations in Each Operating Mode – In the above manual will explain the modes of the PLC.
            2-5-4 Startup Mode Setting – Will show you how to change the mode setting so the PLC will always start in monitor mode. Your program will then always work after a power interruption.
            I hope this helps you out.
            Let me know how you make out.

Leave a Comment