Using Quadrature Encoders with Capacitive Scale TouchDRO Adapters

Starting with firmware version 1.1, the TouchDRO Adapter for iGaging Scales and TouchDRO Adapter for Shahe Scales can read quadrature input. In other words, these adapters can now be used with a mix of capacitive scales, quadrature rotary encoders and Glass/Magnetic DRO scales. This offers more flexibility since it allows you to easily upgrade a capacitive scales setup to glass or magnetic scales, one axis at the time.

The firmware uses the same logic and hardware quadrature counters as the TouchDRO adapter for Glass and Magnetic DRO scales. As a result, there is no difference in accuracy and performance between the three adapters when used with glass or magnetic scales. That said, there are two trade offs. First of all, the adapters don't support differential input, so differential scales will be used in single-ended mode. Second, the refresh rate is 10 Hz, as opposed to 25Hz that the glass scale adapter uses.

Since these adapters are primarily designed for 3V capacitive scales, using them with 5V scales requires a bit of additional work. The input circuit differs between the two adapters, and as a result, adapter for Shahe scales can work with 5V scales without any extra components, while the adapter for iGaging scales requires a level shifting circuit to lower the signal voltage from 5V to 3.3V when used with certain encoders.

Quadrature Encoder Types

Quadrature [incremental] encoders come in all sorts of shapes, sizes and sensor types. The two types most commonly in digital readout systems are linear encoders (such as glass and magnetic DRO scales) and various rotary encoders.

The underlying circuit might be using an opto interrupter arrangement, Hall effect sensor or inductive coil, but they all output two square waves that are offset by 90 degrees (or ΒΌ of the wave length). By convention, they are usually marked as channel A and channel B. For the sake of simplicity, you can think of each channel as a wire connected to a switch that gets actuated by the encoder wheel or strip.

The most important difference is in the way the switch is connected since it determines how the encoder outputs the "high" and "low" signal. This, in fact, is the most important factor that influences how each particular encoder type can be connected to a TouchDRO scale adapter.To better understand the implications, let's take a look at the three encoder output types individually.

NPN Encoders

NPN encoders use sensors that manipulate the negative side of the output. An easy way to memorize this is that the "N" in "NPN" stands for "Negative". These sensors are also commonly called "sinking sensors'' since they sink the output to the ground in their active state. On the receiving end, the output line is connected to the positive power supply via a large value resistor (called "pull up" resistor). When the switch is open, the output is pulled up and the receiver (TouchDRO in this case) reads a "high" value. When the switch closes, the line is connected to the ground and the receiver reads a "low" value.

PNP Encoders

PNP encoders use sensors that manipulate the positive side (P stands for Positive). They are called "sourcing sensors" since they source positive power to the output. The PNP sensor's internal switch is connected to the encoder's positive power supply; a resistor on the receiving end pulls the line down to the ground. Analogous to the case above, when the switch is turned off, the line is pulled down to the ground and the receiver reads a "low" value. When the switch is turned on, the line is connected to the positive supply voltage and the receiver reads a "high" value.

Push/Pull Encoders

Push/Pull encoders use sensors similar to a double throw switch with one side connected to positive supply voltage and the other to the ground. As the switch changes states, the output line is always connected to one of the sides. This type of sensor doesn't need any external pull up or down resistors since it connects the output to one of the rails to provide "high" and "low" output.

Practical TouchDRO Implications

Most of the commonly available glass or magnetic DRO scales and rotary encoders work from 5V power supply. Due to their design, NPN encoders provide an output signal that swings between 0V and the value to which it is pulled up. As such, it can be safely connected to any circuit by selecting the appropriate pull-up voltage. PNP and Push/Pull encoders, on the other hand, provide a signal that swings between 0V and the encoder's operating voltage, which is 5V or more. If the voltage exceeds the maximum safe level listed in the TouchDRO encoder specifications, the inputs will be quickly damaged by the excess voltage.

Both TouchDRO capacitive scale adapters have pull-up resistors on all input lines, so NPN encoders can be directly connected to the board without any additional components. 5V glass and magnetic DRO scales (or other push/pull encoders) can be connected directly to the TouchDRO Adapter for Shahe scales since it has 5V-tolerant scale inputs. The TouchDRO Adapter for iGaging scales requires an additional level shifter to bring the 5V signal to a safe 3.3V level.

PNP encoders require pull-down resistor arrangement, while both TouchDRO adapters come with pull-up resistors. As a result, PNP sensors can't be easily used with either adapter without a modification to the input circuit; this is outside of the scope of this article.

General Connection Notes

TouchDRO Shahe and iGaging DRO Scale adapters have almost identical layout and include an unpopulated 5-pin header for scale connection and a 2-pin 5V supply header. Pin functions for the scale connections are marked on the bottom side of the board. Additionally, a pin function diagram is available on the product details page that is accessible from the TouchDRO store.

Incorrect connection can easily damage the encoder or the TouchDRO adapter.

Connecting Glass and Magnetic Scales

The majority of Glass and Magnetic DRO scales use Push/Pull output that swings between 0V and 5V.

Adapter for iGaging Scales

The input pins on this adapter have a direct connection to the ESP32 processor, which can not tolerate voltage higher than 3.3V. Consequently, the 5V signal from the scales needs to be brought down to around 3V. The best way to achieve this is to use a simple FET-based logic level shifter, such a Pololu item #2595 or a similar device that can be purchased on Amazon and many other online retailers. Such devices are originally designed for interfacing 5V and 3.3V or 1.8V digital circuits and work very well for 5V DRO scales.

The level shifter has two sides, each with its own supply voltage and can usually handle four lines (or two scales), but there are variants with eight lines as well. The resulting connection would look similar to the picture below.

DIY DRO Adapter for iGaging Scales 5V scale connection diagram
5V Scale connection diagram

Adapter for Shahe Scales

The TouchDRO Adapter for Shahe scales has 5V tolerant inputs, so there is no need for additional level shifters. As shown below, the connection is much simpler. In particular, the scale should be connectd as follows:

Connecting multiple 5V scales will require a splitter for 5V supply, since there is only one pin on the board.

DIY DRO Adapter for Shahe Scales with attached DB9 connector
DB9 connector attached to the TouchDRO Adapter for Shahe Scales

Connecting NPN Rotary Encoders

Connecting NPN rotary encoders to a TouchDRO capacitive DRO scale adapter is very straightforward since no level shifter circuit is required. The only concern is the availability of the necessary power supply voltage.

Majority of inexpensive Chinese rotary encoders can operate from 5V supply. Both TouchDRO adapters have a hookup point for 5V supply. The resulting connection will look similar to the picture below.

DIY DRO Adapter for Shahe Scales with a NPN rotary encoder
NPN rotary encoder connected to the TouchDRO Adapter for Shahe Scales

The connections are as follows:

Note that the iGaging and Shahe adapters have different pinouts. Pin funcitons are marked on the underside of the board.

When using NPN encoders that operate from 12V or 24V supply, an additional power supply is needed. In such a case, it is necessary to tie together the external power supply ground to the TouchDRO adapter ground.