How-to
Wiring a 10-bit Gray Code Absolute Encoder to Standard DC Inputs
Short answer
A ten-bit parallel Gray code absolute encoder needs no special interface card: land Bit 0 through Bit 9 on ten spare points of a standard DC input card, read them as one CIO word, clear the six high bits with a ten-bit mask, and run the value through GRAY_BIN to get absolute position 0 to 1023, valid at power-up with no homing move. The SSI card is only for encoders that actually output SSI.

On this page
A ten-bit Gray code absolute encoder does not need a special interface card. Land its ten data conductors, Bit 0 through Bit 9, on ten spare points of a standard DC input card, read the card's word, clear the six unused high bits, and push the result through the GRAY_BIN instruction. What comes out is absolute position 0 to 1023, valid the moment the PLC powers up, with no homing move and nothing counted. The CJ1W-CTS21-E is the right card only when an encoder actually outputs SSI serial data; ten parallel bit wires are not SSI, so it is the wrong part here. The sections below give the wiring, the bit mapping, the mask arithmetic, the conversion with a worked example, and the commissioning checks that prove the count before the axis is released.
Decide the interface from the encoder's outputs #
A CJ2 system reads incremental signals natively, and its dedicated absolute-interface option is SSI through the CJ1W-CTS21-E. The TRD-NA-style encoder in question instead exposes ten parallel conductors, Bit 0 through Bit 9 plus supply and shield, so neither of those paths applies. Nothing here is being counted, which is why no high-speed counter input belongs in this design: the position arrives as a parallel pattern, one bit per input point. If your encoder speaks SSI instead of offering ten bit wires, the interface question changes completely, and which absolute encoder interface works with a high-speed counter PLC is the article that sorts those cases.
| Encoder output | Right hardware | How position arrives |
|---|---|---|
| Ten parallel Gray code bits (this encoder) | Standard DC input points | One bit per point, read as one word |
| SSI serial data | CJ1W-CTS21-E | Clocked serial data on a special card |
The decision, stated once: ten parallel Gray code bits go to standard DC inputs; an SSI output goes to the SSI card. For the parallel case, allocate at least ten spare input points, in one word if the card layout allows.
Match the electrical side before landing any wire #
Two documents decide this section: the encoder manual, which gives the output circuit type, the ON and OFF output levels, the OFF-state leakage and the maximum output current, and the input unit datasheet, which gives the rated voltage range, the ON and OFF input thresholds, the input current and the common-terminal arrangement. For this encoder family the TRD-NA series installation manual is the encoder-side document; its supply terminals take 12/24 V DC on the brown conductor with 0 V on blue, and the shield lands on ground.
The one rule that moves with the output circuit type: an open-collector sinking output pulls the input down to 0 V, so the input unit's common goes to the positive side of that supply; a sourcing output drives the positive side, so the common goes to 0 V. The 12/24 V marking on the supply conductors does not tell you which output type the encoder has, so take the circuit type from the manual before choosing common polarity.
Safety note: land all wiring under lockout, keep the encoder cable out of the power wiring duct and never run it parallel to power lines, and fit the surge-absorption components (capacitors or surge elements) the installation manual calls for. The shield is never the DC return conductor.
Verify the electrical match before any programming: with power on, rotate the shaft slowly and measure one data conductor against 0 V. Its two states must straddle the input unit's documented ON and OFF thresholds. If they do not, fix the supply voltage, the common polarity or the card's voltage class before moving on.
Land the ten conductors on consecutive bits #
The wiring scheme names every conductor; land them in the encoder's own order so nothing needs swapping later.
| Conductor | Signal | Word bit |
|---|---|---|
| Black | Bit 0 | bit 00, least significant |
| Red | Bit 1 | bit 01 |
| Orange | Bit 2 | bit 02 |
| Yellow | Bit 3 | bit 03 |
| Green | Bit 4 | bit 04 |
| Purple | Bit 5 | bit 05 |
| Gray | Bit 6 | bit 06 |
| White | Bit 7 | bit 07 |
| Black/White | Bit 8 | bit 08 |
| Red/White | Bit 9 | bit 09, most significant |
Consecutive points let the controller treat the card as one position word: if the card happens to occupy CIO 0000, for example, the ten bits arrive in bits 00 through 09 of that word and no packing logic is needed. If the ten points are scattered across words, copy each physical input into the matching bit of a working word first; every later step is unchanged. Keep the raw word in the program either way, because it is the diagnostics view.
Mask the word down to its ten active bits #
Bits 10 through 15 do not belong to the encoder, and whatever sits in them must stay out of the conversion. Logical-AND the raw word with hexadecimal #03FF. The arithmetic: ten active bits give 2^10 = 1024 codes, and 1024 - 1 = 1023, which is #03FF, ten ones in the low ten positions and zeros above. One AND instruction removes the noise.
Watch the raw word online while turning the shaft slowly by hand. A Gray code changes exactly one bit between adjacent positions, so the pattern will not count up like a binary number; that is the encoder working correctly, not a wiring fault. Sweep the travel once and confirm each of the ten bits toggles somewhere, in the word position the table above predicts.
Convert with GRAY_BIN #
The masked word is a Gray pattern, not yet a position. The CJ-series CJ2 software manual documents GRAY_BIN as the conversion instruction: it reads a source word of Gray code and writes the binary equivalent to a destination word. Feed it the masked word, store the result in a separate position word, and leave the raw Gray word untouched for diagnostics. The fold each binary bit follows is simple: starting from the most significant bit, each binary bit is the running XOR of the Gray bits above and including its own.
Worked example, calculated for these example inputs:
- The online monitor shows the card word at
#C300with the shaft parked at a marked mid-travel position; bits 15 and 14 are ON because two other points share the card. - Mask first:
#C300AND#03FF=#0300, keeping bits 09 and 08 and clearing everything above. #0300is binary 1100000000, so Gray bits 9 and 8 are ON.- GRAY_BIN folds from the top: b9 = g9 = 1, then b8 = b9 XOR g8 = 1 XOR 1 = 0, and every lower fold lands on 0. The result is binary 1000000000, which is
#0200, or 512 decimal. - 512 out of the 0 to 1023 span is exactly half scale, so the converted count agrees with the mid-travel mark.
Two anchor checks come free: all ten bits OFF converts to 0, and the pattern with only Bit 9 ON converts to the top-of-range count. If slow shaft movement produces a converted value that runs out of order or jumps, with the single rollover from top of range to zero as the only allowed discontinuity, the usual culprits are a reversed bit order, a wrong mask or a wrong source operand on GRAY_BIN, in that order. The bit pattern behind the conversion itself is explained further in Reading a Gray Code Absolute Encoder Into a PLC.
Commission before releasing the axis #
Work down this list in order; each step isolates one failure mode.
- Power the PLC and the encoder and monitor the raw word online. Turn the shaft by hand, slowly: between adjacent positions exactly one bit should change, and a flicker across several bits means you sampled mid-transition.
- Sweep the full travel once. Every one of the ten bits must toggle at some point, in the word position the mapping table predicts. If one bit never moves, measure its voltage at the PLC terminal and check conductor, terminal and input LED before touching the program.
- Stop at several distinct positions and record the raw word and the converted value side by side.
- Nudge the shaft a small amount in one direction: the converted value must move consistently that way. Reverse the shaft and confirm the value reverses, with no jumps other than the single rollover from top of range to zero.
- Mark a repeatable mechanical reference and record the converted count there. Return to the mark from both directions of travel; the same count, within the machine's mechanical tolerance, must come back.
- Cycle PLC and encoder power together and return to the mark. The same count must appear with no homing sequence, which is the entire point of the parallel absolute interface. What each encoder type genuinely retains across a power cycle is compared in absolute vs quadrature encoder: what survives a power cycle.
- Run the axis at operating speed and watch the converted value in a trend. If a reading taken mid-transition is unacceptable for the application, accept a position only after two consecutive scans agree, and confirm that filter does not add delay the motion cannot afford.
- Release the axis only when the electrical checks, the conversion anchors, the repeatability at the reference and the full-speed run have all passed.
The decision #
Ten parallel Gray code conductors, Bit 0 through Bit 9 on a 1024-position shaft: standard DC input card, ten spare points in one word where the layout allows, mask #03FF, GRAY_BIN, and absolute position 0 to 1023 with no homing. An encoder that outputs SSI: the CJ1W-CTS21-E and a different integration path altogether. More bits: the same wiring and conversion with a wider mask; twelve bits take #0FFF and span 0 to 4095. No high-speed counter input belongs in any of these cases, because nothing is being counted.
Questions asked
My input card does not have ten points in one word. Can I still use it?
Yes. Consecutive points in one word only save logic. Land the ten conductors on any ten spare points, then copy each physical input into its matching bit of a working word, encoder Bit 0 to working bit 00 and Bit 9 to working bit 09, before the mask and GRAY_BIN conversion. The mask clears whatever sits in bits 10 through 15.
How do I turn the count into degrees on a single-turn shaft?
Multiply the count by 360 and divide by 1024, which is about 0.352 degrees per count. The worked mid-scale reading of 512 counts therefore sits at 180 degrees. Run the scaling as its own step after GRAY_BIN and round only at the display, so the axis never accumulates rounding error.
Is a homing sequence needed after power-up?
No. The ten parallel wires present the absolute code whenever the encoder is powered, so the position word is valid the moment the PLC reads it. Still prove it once at a marked mechanical reference from both directions of travel, and again after cycling encoder and PLC power together, before trusting the axis in production.
Does the same method work for a 12-bit Gray code encoder?
Yes, with two changes: use twelve input points instead of ten and mask with hexadecimal 0FFF, which is 2 to the 12th power minus 1, or 4095. GRAY_BIN then delivers position 0 to 4095. The wiring, packing and commissioning checks stay the same; only the bit count, the mask and the valid range move.