Omron CP1H Data Conversion Instructions

We will now look at data conversion instructions in the Omron Cp1H Controller. Programmable logic controller programming is all about manipulating the bits within the memory of the controller. Sometimes we need to convert from one form to another. This is where we will use data conversion instructions. BCD to Binary, Line to Column, Grey Scale, and Multiplexing are just some of the data conversion instructions. We will be looking at some of these instructions in the Omron CP1H PLC. Examples of some of the instructions will be presented.

Previously in this CP1H series, we have discussed:
System Hardware – Video
CX-Programmer – Video
Establish Communication – Video
Setting, Forcing, and Online Editing – Video
Numbering System and Addressing – Video
CP1H Timers – Video
Counters – Video
Data Movement – Video
Compare Instructions – Video
Data Shift Instructions
Video Part 1
Video Part 2
Math Instructions – Video
Data Conversion – Video
Program Control Instructions – Video
Table Data Instructions – Video
Data Control Instructions – Video
AdvancedHMI Communication – Video

Data Conversion Instructions – Omron CP1H

Several different data conversion instructions are available in the CP1H. A full explanation can be obtained by using the help menu in the CX-Programmer software or the Programming Manual for the CP1H. Links are provided at the end of this post.
Instructions can have different variations.
Let’s look at when this instruction will execute:
BIN(023) when used will be scanned and executed every cycle of the PLC that the input condition is on.
@BIN(023) when used will be executed when the input condition turns from off to on. This will trigger the instruction to happen only once.
Please refer to the programming manual or help file in CX-Programmer for different variations of the instructions that you want to use. We will now go over some of the data conversion instructions in the Omron CP1H. This will give you a general idea of the instructions available.
Omron CP1H Data Conversion Instructions

The first few conversions are usually used on math instructions to convert from one numbering system or coding to another. There are several numbering conversion instructions in the CP1H.

BCD-TO-BINARY: BIN(023) – Omron CP1H

Omron CP1H Data Conversion Instructions
This instruction will convert BCD (Binary Coded Decimal) to Binary.

Omron CP1H Data Conversion Instructions

BINARY-TO-BCD: BCD(024) – Omron CP1H

Omron CP1H Data Conversion Instructions
This will convert a Binary number to BCD.

Omron CP1H Data Conversion Instructions

2’S COMPLEMENT: NEG(160) – Omron CP1H

Omron CP1H Data Conversion Instructions
In order PLC models, you had to use the 2’s complement to handle negative numbers in the controller.
Let’s say we have two numbers that we want to add together: 2 and -1. Using 4-bit binary we would represent this information as follows:
2 – 0010
-1 – 1001
Using 2’s complement on -1 we get 1111.
Adding these numbers together we see:
0010 + 1111 = 0001 (discard the carry (4 bits))
We now have the correct answer of 2 + (-1) = 1

Omron CP1H Data Conversion Instructions

DATA DECODER: MLPX(076) – Omron CP1H

Omron CP1H Data Conversion Instructions
The multiplex instruction will read a digit in the source word and turn on the bit representing that digit in the result word. This is used allot of the times in elevator controls. Each of the inputs for the floor call buttons are placed in an internal word. Multiplex and De-multiplex are used to determine the floor number to display and move the lift.

The instruction uses a control word that determines how may digits are used and where the digits are started.

Omron CP1H Data Conversion Instructions

DATA ENCODER: DMPX(077) – Omron CP1H

Omron CP1H Data Conversion Instructions
The de-multiplex instruction will determine the first or last bit on in the source word and writes that value into the result word.


Omron CP1H Data Conversion Instructions

ASCII CONVERT: ASC(086) – Omron CP1H

Omron CP1H Data Conversion Instructions
This instruction will convert a 4 bit hexadecimal digit in the source word into its 8 bit ASCII equivalent.
The digit designator is used to indicate the number of digits to use, starting location and parity. Parity is used in serial communications.


Example: 1 hex = 0001 binary = 31 ASCII (American Standard Code for Information Interchange)
What everybody ought to know about PLC numbering system. This post will discuss the ASCII table.
Omron CP1H Data Conversion Instructions

LINE TO COLUMN: COLM(064) – Omron CP1H

Omron CP1H Data Conversion Instructions
This instruction will take the 16 bits of the source word to a column of bits in a 16 word range of the destination. The bits in the destination are specified with the bit number.

Omron CP1H Data Conversion Instructions
Note: The opposite of this instruction is the Column to Line. LINE(063)

GRAY CODE CONVERT: GRY(474) – Omron CP1H

Omron CP1H Data Conversion Instructions
Gray code is used because of only one-bit changes at a time. This is ideal for PLC inputs such as encoders because if the power is removed and started again you can tell exactly where you left off. See the following post on Gray Code for a complete explanation of this coding idea.
Here’s a quick way to convert grey code into binary for PLCs. This post will go through the logic of converting gray code.
Omron CP1H Data Conversion Instructions
Here is a quick chart on a 4-bit gray code to binary. Notice that only one bit changes at a time from value to value.

Control words are used to determine the resolution, conversion mode, and zero-point compensation.
Omron CP1H Data Conversion Instructions

You can see that we have many different data conversion instructions in the Omron CP1H. This should give you a good idea of what is possible.

See the YouTube video below on data conversion instructions in the Omron CP1H PLC.

The following is a list of manuals associated with the CP1H programmable logic controller. See the descriptions for each of these manuals in the first post: Omron CP1H System Hardware
W450 – SYSMAC CP Series CP1H CPU Unit Operation Manual
W451 – SYSMAC CP Series CP1H CPU Unit Programming Manual
W342 – SYSMAC CS/CJ series Communications Commands Reference Manual
W446 – SYSMAC CX-Programmer Ver. 6.1 Operation Manual
W447 – SYSMAC CX-Programmer Ver. 6.1 Operation Manual Function Blocks
W444 – CX-One FA Integrated Tool Package Setup Manual
W445 – CX-Integrator Operation Manual
W344 – CX-Protocol Operation Manual

You can download the PLC program as discussed above here.

Next time we will look at program control instructions in the Omron CP1H PLC.

Watch on YouTube: Omron CP1H Data Conversion Instructions


If you have any questions or need further information please contact me.
Thank you,
Garry



If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLC’s 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.

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


Leave a Comment