ESP32-Based DIY Digital Readout

This DRO adapter is based on the new 32-bit ESP32 module and uses the second generation universal TouchDRO firmware that can decode data from quadrature encoders, iGaging 21-bit scales, iGaging absolute scales, and Shahe BIN6 scales. In fact, the firmware is functionally identical to the version that ships on the pre-assembled iGaging and Shahe scale adapters.

DIY DRO example components

The circuit is identical to the one used by the TouchDRO DIY Kit and is optimized for 5V and 3.3V scales. This includes glass/magnetic DRO scales, iGaging EZ-View DRO, iGaging DigiMag DRO, iGaging Absolute DRO linear scales, and Shahe Liner Remote DRO scales. This design has been chosen due to its good balance between being DIY-friendly and providing good noise and glitch resistance.

Bundling this circuit on a prototyping board is rather challenging due to the number of required point-to-point connections. Consequently, we are making the assumption that anyone undertaking this build already has a solid understanding of electronics and good soldering skills. As such, there will be no detailed assembly instructions, since it's assumed that you can read and follow the provided circuit schematic.

Circuit Overview

At the core of this adapter is the ESP32 DevKit V1 development board. It is a self-contained circuit that includes the ESP32 WROOM module, USB-to-Serial interface, voltage regulator, and status LEDs. ESP32 WROOM has two powerful processors, hardware quadrature decoders, hardware tachometer, and built-in BlueTooth transceiver. Moreover, it's very inexpensive and readily available in most parts of the world. As a result, it makes a great platform for a DIY DRO. It has one notable downside - it's not designed to be directly interfaced with the outside world, so its input pins don't have built-in Schmitt triggers, etc.. As a result, we can't connect the scales directly and, instead, need to build a suitable input conditioning circuit.

ESP32 Devkit V1 Pinout

The circuit for this DIY adapter uses two 74HC14 hex inverting Schmitt triggers to provide a robust and noise resistant input signal conditioning. In essence, each scale input line has a series 4.7KOhm resistor and a NOT gate with a Schmitt trigger. The line is pulled up to the scales Vcc by a 47KOhm resistor.

The series resistor is necessary to protect the IC from overvoltage. Since 74HC14 is powered from 3.3V supply (so its output high signal is 3.3V), 5V scale input is outside of its recommended high input voltage. To protect the IC from damage, we are adding the 4.7K resistor, which will limit the current to a level that can safely be handled by the chip's internal diodes.

Additionally, each scale input, as well as tachometer and problem inputs, have 0.1uF bypass capacitors. Those are necessary to reduce noise on the scale's power supply line. Those capacitors should be installed as close to the scale inputs as possible. Similarly, next to each of the 74HC14 there is a 0.1uF bypass capacitor.

Finally, there are two 100uF electrolytic capacitors, one on 3.3V supply rail and one on 5V supply rail. If you are planning to use only one of those rails to power the scales, the second capacitor can be omitted.

Circuit Schematic

Fig 2: Circuit Schematic

Bill Of Materials

This DIY DRO kit includes all of the components needed to assemble a TouchDRO adapter.

Value Description Qty. Reference
ESP32 Devkit V1 ESP32 WROOM Dev. Kit 1 U1
74xx14 SN74HC14N Hex Schmitt Trigger 2 IC1, IC2
Capacitor, 100 uF Cap. electrolytic, 100uF, 35V 2 C14, C15
Capacitor, 0.1uF Cap. ceramic, 0.1uF 50V 8 C1, C3, C5, C7, C9, C10, C11, C12
Resistor, 4.7 KOhm Metal film resistor, 4.7 KOhm, 1/4W, 5% 10 R1-10
Resistor 47KOhm Metal film resistor, 47 KOhm, 1/4W, 5% 10 R21-R30

Scale Input Configuration

For each input you will need to connect the Vcc pin to the correct supply rail. If you follow the schematic, this will also connect the pull-up resistors to the same rail (this is very important; otherwise, you can permanently damage your scales). Additionally, iGaging 21-bit scales need to have the "CLOCK OUT" pin connected (jumpers are market R11-R14 on the schematic).

Common configurations are as follows:

Note: Although 3.3V signal coming from capacitive scales is [generally] safe for ESP32, you can't connect them directly. First of all, the firmware expects an inverted signal and will not work without a "NOT" gate. Second, without the Schmitt trigger, the readout might be too glitchy. Finally, any noise spikes that exceed 3.6V can permanently damage ESP32's input pins.

DRO Firmware

The firmware needed to run this DIY DRO adapter can be found in the Downloads section (Universal Firmware - 32 Bit). This ESP32 firmware is written in low-level C, not Arduino. To flash it into the ESP32 module you will need to install Espressif tool chain callend IDF. The process is more involved that upliading a sketch to an Arduino and requires installation of USB drivers and a few command line tools.The documentation is provide on the Espressif site.

To verify that the Espressif IDF is installed correctly, run the following command: version Your result should look similar to this:

Example output from the above command

Once you have a working environment, decompress the downloaded firmware into a folder and in the command line execute the following:

            -p /dev/ttyACM0 \
            -b 460800 \
            --before default_reset \
            --after hard_reset \
            --chip esp32  write_flash \
            --flash_mode dio \
            --flash_size detect \
            --flash_freq 40m \
            0x1000 bootloader.bin \
            0x8000 partition-table.bin \
            0x10000 touchdro-universal-32-v14.bin

Depending on your OS, the parameters will likely vary. Specifically, the -p parameter that specifies the port.

Build Tips and Testing

The build process for this adapter has two challenges:

To simplify the testing you might want to break it into those two stages and test each stage individually.

ESP32 Firmware

ESP32 is a self contained module, and will run TouchDRO firmware just fine without the support circuitry. As such, your first step should be flashing the firmware onto the module and making sure that it works as expected:

  1. Power up the module from USB and confirm that red LED is lit and blue LED is blinking
  2. Pair the module with your Android tablet and make sure the pairing process succeeds. Device name in the BT device list should be "TouchDRO DIY"
  3. Open TouchDRO application and connect it to the module
  4. Leave TouchDRO running for at least a minute. The application should not lose the connection

Optionally, you can install a BlueTooth terminal application (such as BlueTerm) and do the following:

  1. Disconnect TouchDRO application (if connected)
  2. Connect to the DRO adapter via BlueTerm
  3. You should see a data stream that contains x0;y0;z0;w0;t0;p0;
  4. Find the probe pin (see pinout above) and short it to the ground
  5. The value for p in the data stream should change to p1; and the stream should speed up
  6. Disconnect the pin from the ground; p should return to p0;

If the tests pass, the firmware is running as expected.

Input Circuit

Once you build the input circuit (before connecting anything to the ESP32 module), it's a good idea to test each line to make sure the connections are working. For this, you can do the following:

  1. Connect 5V, 3.3V and Ground to the ESP32 module (see pinout above). Alternatively, you can use a bench power supply or even batteries.
  2. Using a Voltmeter, check voltage at each input pin. Since the pins are pulled up to Vcc, the voltage should be very close to nominal Vcc (5V or 3.3V, depending on your configuration)
  3. Using a Voltmeter, check the voltage at each output (the line that will be connected to ESP32). The voltage should be close to 0V, since 74HC14 is an inverting Schmitt trigger.
  4. Ground each input line and check the voltage at the output. It should be close to 3.3V

If all these tests pass, your circuit is working as expected and you can now connect it to the ESP32 module. Otherwise, re-check your connection, fix any problems and retest again.

Scale Wiring

Glass and magnetic scales are generally very resilient to spurious line noise, etc. The 0.1uF capacitors are not strictly necessary, but they provide a bit of protection against noise spikes on the supply line. For capacitive scales, the bypass capacitors are very important, since these scales are very prone to noise and glitches. Ideally, these capacitors should be installed inside the scale's reading head. If you are not comfortable modifying the reading head, the capacitors should be installed on the USB breakout boards [unless you are planning to hard-wire the scales to the main PCB].