Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use DG01D-E: Examples, Pinouts, and Specs

Image of DG01D-E
Cirkit Designer LogoDesign with DG01D-E in Cirkit Designer

Introduction

The DG01D-E is a rotary encoder manufactured by Sparkfun, designed to detect the position and rotation of a shaft. It converts mechanical position into an electrical signal, enabling precise control in various applications. Rotary encoders like the DG01D-E are commonly used in robotics, industrial controls, and user interface devices such as volume knobs and jog wheels.

Explore Projects Built with DG01D-E

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
ESP32-Based Weather Station with GPS and SD Card Storage
Image of ACP_Circuit: A project utilizing DG01D-E in a practical application
This circuit is a data logging system that uses an ESP32 microcontroller to collect environmental data from a DHT11 humidity and temperature sensor and GPS location data from a Grove GPS module. The collected data is stored on a Micro SD card, and the entire system is powered by a DC power source through a DC buck step-down converter.
Cirkit Designer LogoOpen Project in Cirkit Designer
Dual GC9A01 Displays Interface with ESP32 for Dynamic Visual Output
Image of spooky eyes: A project utilizing DG01D-E in a practical application
The circuit features an ESP32 Devkit V1 microcontroller connected to two GC9A01 display modules. The displays are wired in parallel for control signals but have separate chip select lines, enabling independent operation of each display from the ESP32.
Cirkit Designer LogoOpen Project in Cirkit Designer
I2C-Controlled OLED Display with External EEPROM and Interactive Pushbuttons
Image of godmode: A project utilizing DG01D-E in a practical application
This is a microcontroller-based interactive device featuring a Wemos D1 Mini, an OLED display, external EEPROM, and an I/O expander. It includes user input buttons and status LEDs, with potential MIDI interface capabilities.
Cirkit Designer LogoOpen Project in Cirkit Designer
ESP32-Controlled Multi-Display Interactive System with Pushbutton Inputs
Image of ORBS: A project utilizing DG01D-E in a practical application
This circuit consists of multiple GC9A01 display modules interfaced with an ESP32 microcontroller. The ESP32 controls the reset (RST), chip select (CS), data/command (DC), serial data (SDA), and serial clock (SCL) lines of each display, allowing for individual communication with each screen. Additionally, there are pushbuttons connected to the ESP32, which could be used for user input to control the displays or other functions within the circuit.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with DG01D-E

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of ACP_Circuit: A project utilizing DG01D-E in a practical application
ESP32-Based Weather Station with GPS and SD Card Storage
This circuit is a data logging system that uses an ESP32 microcontroller to collect environmental data from a DHT11 humidity and temperature sensor and GPS location data from a Grove GPS module. The collected data is stored on a Micro SD card, and the entire system is powered by a DC power source through a DC buck step-down converter.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of spooky eyes: A project utilizing DG01D-E in a practical application
Dual GC9A01 Displays Interface with ESP32 for Dynamic Visual Output
The circuit features an ESP32 Devkit V1 microcontroller connected to two GC9A01 display modules. The displays are wired in parallel for control signals but have separate chip select lines, enabling independent operation of each display from the ESP32.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of godmode: A project utilizing DG01D-E in a practical application
I2C-Controlled OLED Display with External EEPROM and Interactive Pushbuttons
This is a microcontroller-based interactive device featuring a Wemos D1 Mini, an OLED display, external EEPROM, and an I/O expander. It includes user input buttons and status LEDs, with potential MIDI interface capabilities.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of ORBS: A project utilizing DG01D-E in a practical application
ESP32-Controlled Multi-Display Interactive System with Pushbutton Inputs
This circuit consists of multiple GC9A01 display modules interfaced with an ESP32 microcontroller. The ESP32 controls the reset (RST), chip select (CS), data/command (DC), serial data (SDA), and serial clock (SCL) lines of each display, allowing for individual communication with each screen. Additionally, there are pushbuttons connected to the ESP32, which could be used for user input to control the displays or other functions within the circuit.
Cirkit Designer LogoOpen Project in Cirkit Designer

Technical Specifications

Key Technical Details

Parameter Value
Manufacturer Sparkfun
Part ID DG01D-E
Operating Voltage 5V DC
Current Consumption 10mA (typical)
Output Type Quadrature (A and B channels)
Resolution 20 pulses per revolution
Shaft Diameter 6mm
Operating Temperature -10°C to 70°C

Pin Configuration and Descriptions

Pin Number Pin Name Description
1 GND Ground
2 VCC Power Supply (5V DC)
3 A Channel A output (quadrature signal)
4 B Channel B output (quadrature signal)
5 SW Switch output (active low when pressed)

Usage Instructions

How to Use the DG01D-E in a Circuit

  1. Power Supply: Connect the VCC pin to a 5V DC power supply and the GND pin to the ground.
  2. Signal Outputs: Connect the A and B pins to the input pins of a microcontroller or an interface circuit to read the quadrature signals.
  3. Switch Output: Connect the SW pin to a digital input pin of a microcontroller to detect the switch press.

Important Considerations and Best Practices

  • Debouncing: The mechanical switch may produce noise or "bouncing" when pressed. Implement software debouncing to ensure reliable switch detection.
  • Pull-up Resistors: Use internal or external pull-up resistors for the switch output to ensure a defined logic level when the switch is not pressed.
  • Signal Filtering: If the encoder is used in a noisy environment, consider adding capacitors to filter out high-frequency noise on the signal lines.

Example Circuit Diagram

Below is a simple example of how to connect the DG01D-E to an Arduino UNO:

DG01D-E Pin | Arduino UNO Pin
------------|----------------
GND         | GND
VCC         | 5V
A           | Digital Pin 2
B           | Digital Pin 3
SW          | Digital Pin 4

Example Arduino Code

// DG01D-E Rotary Encoder Example Code
// Connect the encoder pins as follows:
// GND -> GND
// VCC -> 5V
// A -> Digital Pin 2
// B -> Digital Pin 3
// SW -> Digital Pin 4

#define ENCODER_PIN_A 2
#define ENCODER_PIN_B 3
#define SWITCH_PIN 4

volatile int encoderValue = 0;
volatile bool switchPressed = false;

void setup() {
  pinMode(ENCODER_PIN_A, INPUT);
  pinMode(ENCODER_PIN_B, INPUT);
  pinMode(SWITCH_PIN, INPUT_PULLUP);

  attachInterrupt(digitalPinToInterrupt(ENCODER_PIN_A), 
                  encoderISR, CHANGE);
  attachInterrupt(digitalPinToInterrupt(SWITCH_PIN), 
                  switchISR, FALLING);

  Serial.begin(9600);
}

void loop() {
  static int lastEncoderValue = 0;
  static bool lastSwitchState = false;

  if (encoderValue != lastEncoderValue) {
    Serial.print("Encoder Value: ");
    Serial.println(encoderValue);
    lastEncoderValue = encoderValue;
  }

  if (switchPressed != lastSwitchState) {
    Serial.print("Switch Pressed: ");
    Serial.println(switchPressed);
    lastSwitchState = switchPressed;
  }
}

void encoderISR() {
  int stateA = digitalRead(ENCODER_PIN_A);
  int stateB = digitalRead(ENCODER_PIN_B);

  if (stateA == stateB) {
    encoderValue++;
  } else {
    encoderValue--;
  }
}

void switchISR() {
  switchPressed = !switchPressed;
}

Troubleshooting and FAQs

Common Issues

  1. No Signal Output: Ensure that the power supply connections (VCC and GND) are correct and that the encoder is receiving 5V DC.
  2. Erratic Readings: Check for proper debouncing of the switch and ensure that the signal lines are not picking up noise.
  3. Switch Not Detected: Verify that the switch pin is configured with a pull-up resistor and that the interrupt is correctly set up.

Solutions and Tips for Troubleshooting

  • Check Connections: Double-check all wiring connections to ensure they are secure and correct.
  • Use Pull-up Resistors: Ensure that the switch pin has a pull-up resistor to maintain a defined logic level.
  • Implement Debouncing: Use software debouncing techniques to filter out noise from the mechanical switch.

FAQs

Q: Can the DG01D-E be used with a 3.3V microcontroller? A: The DG01D-E is designed for 5V operation. Using it with a 3.3V microcontroller may result in unreliable performance. Consider using a level shifter if necessary.

Q: How do I increase the resolution of the encoder? A: The resolution of the DG01D-E is fixed at 20 pulses per revolution. To increase resolution, you may need to use a different encoder with a higher resolution.

Q: What is the maximum rotation speed the encoder can handle? A: The maximum rotation speed depends on the ability of your microcontroller to read and process the signals. Ensure that your code and hardware can handle the expected speed.

By following this documentation, users can effectively integrate the DG01D-E rotary encoder into their projects, ensuring precise control and reliable performance.