using ladder logic for gray code conversion.pdf

3
Using Ladder Logic for Gray Code Conversion If your PLC does not support Gray code to binary conversion then it can be quite a trick developing the ladder logic to do it. First, you might want to double check that this instruction is not buried deep down somewhere in your manual. Here's a couple of PLCs that all ready have a Gray code to binary converter. Manufacturer PLCs Instruction Code Allen Bradley MicroLogix 1200 and 1500 Series C GCD Automation Direct DL05, DL06, DL240, DL250, DL350, DL440, and DL450 GRAY Mitsubishi FX Series GBIN Omron CS Series GRY This list is by no means complete but if you still need to do it in ladder logic then read on. Fortunately, the conversion is somewhat easy to do. Let me try to explain it first. 1. Copy the most significant bit of the Gray code which becomes the most significant bit of the binary code. 2. Take the next bit down in the Gray code and the most significant bit of the binary and do a logical XOR and this becomes the next bit in the binary code. 3. Take the next bit down in the Gray code and the next bit down in the binary code and do a logical XOR and this becomes the next bit in the binary code. 4. Continue this process until you reach the end of the Gray code. I know, writing it out doesn't help me much either. Maybe a picture will do better. This is how the process looks with logical XOR gate symbols. Maybe that doesn't help much either. The XOR symbol is a logical gate that has a truth table of: Input 1 Input 2 Output 0 0 0 0 1 1 1 0 1 1 1 0

Upload: vladimir-ageev

Post on 03-Jan-2016

125 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Using Ladder Logic for Gray Code Conversion.pdf

Using Ladder Logic for Gray Code Conversion

If your PLC does not support Gray code to binary conversion then it can be quite a trick developing the ladder logic to do it. First, you might want to double check that this instruction is not buried deep down somewhere in your manual. Here's a couple of PLCs that all ready have a Gray code to binary converter.

Manufacturer PLCs Instruction Code

Allen Bradley MicroLogix 1200 and 1500 Series C GCD

Automation Direct DL05, DL06, DL240, DL250, DL350, DL440, and DL450 GRAY

Mitsubishi FX Series GBIN

Omron CS Series GRY

This list is by no means complete but if you still need to do it in ladder logic then read on. Fortunately, the conversion is somewhat easy to do. Let me try to explain it first.

1. Copy the most significant bit of the Gray code which becomes the most significant bit of the binary code.

2. Take the next bit down in the Gray code and the most significant bit of the binary and do a logical XOR and this becomes the next bit in the binary code.

3. Take the next bit down in the Gray code and the next bit down in the binary code and do a logical XOR and this becomes the next bit in the binary code.

4. Continue this process until you reach the end of the Gray code.

I know, writing it out doesn't help me much either. Maybe a picture will do better. This is how the process looks with logical XOR gate symbols.

Maybe that doesn't help much either. The XOR symbol is a logical gate that has a truth table of:

Input 1 Input 2 Output

0 0 0

0 1 1

1 0 1

1 1 0

Page 2: Using Ladder Logic for Gray Code Conversion.pdf

Doing it by hand you'd follow the steps like this example with a 4-bit Gray code.

So the Gray code of 1011 here is converted to binary 1101. You can check your work with the online Gray code to Binary converter tool (make sure to change the input number basis to 2 for binary).

Let's get to the reason you're here... the ladder logic. An XOR gate is implemented like this in ladder logic.

The final ladder logic, following our example above, would look like this...

Page 3: Using Ladder Logic for Gray Code Conversion.pdf

This is, of course, a generic example and you'll have to adapt it to your specific PLC. In Allen Bradley RSLogix 500 it would like so...