Circuit Documentation
Summary
The circuit in question is designed to control a pair of gear motors with integrated encoders, using an Arduino Mega 2560 as the primary microcontroller and an ESP32 as a secondary controller or for additional functionality. The circuit includes motor drivers for controlling the motors, a sensor array for input, and various power management components to handle battery charging and voltage regulation. The circuit is powered by 18650 Li-ion batteries with a protection board module and includes a charging board for battery management. The circuit also features a buck converter and a step-up boost power converter to regulate voltages for different parts of the circuit. A rocker switch is used to control power flow, and ultrasonic sensors provide additional input for distance measurement.
Component List
Microcontrollers
- Arduino Mega 2560: A microcontroller board based on the ATmega2560, with numerous digital and analog I/O pins.
- ESP32 (30 pin): A microcontroller with Wi-Fi and Bluetooth capabilities, featuring a variety of pins for I/O operations.
Power Components
- 18650 Li-ion Battery: A rechargeable battery providing power to the circuit.
- Motor Driver 1A Dual TB6612FNG: A motor driver capable of driving two motors.
- 2S lithium battery protection board module: Protects the lithium batteries from overcharging and discharging.
- Lithium Battery Charging Board Type-C: A charging board for the 18650 Li-ion batteries.
- Step Up Boost Power Converter, Adjustable Voltage Regulator: Boosts voltage to a higher, adjustable level.
- Buck Converter, Adjustable Regulator: Steps down voltage to a lower, adjustable level.
Sensors and Actuators
- Gear Motor with integrated Encoder: A motor with a built-in encoder for position feedback.
- QTRX-HD-07RC Reflectance Sensor Array: A sensor array for detecting reflectance.
- HC-SR04 Ultrasonic Sensor: An ultrasonic sensor for measuring distances.
Other Components
- Rocker switch: A switch to control the power supply to the circuit.
- Resistor: A passive component used to limit current or divide voltages.
Wiring Details
Arduino Mega 2560
- GND: Connected to the ground pins of various components including the motor driver, gear motors, ESP32, ultrasonic sensor, and sensor array.
- 5V: Powers the motor driver, ultrasonic sensor, and sensor array.
- Digital Pins (D2-D5, D22-D34): Control signals for the motor driver, gear motor encoders, and sensor array.
- Analog Pins (A0): Connected to a voltage divider network for analog input.
- VIN: Receives power from the buck converter.
- I2C Pins (D20/SDA, D21/SCL): Available for I2C communication.
ESP32 (30 pin)
- GND: Connected to the ground of the buck converter and Arduino Mega 2560.
- Vin: Receives power from the buck converter.
- RX2/TX2: Serial communication with the Arduino Mega 2560.
Gear Motor with integrated Encoder
- MOTOR +/-: Connected to the motor driver outputs.
- Encoder +/-: Power supply from the Arduino Mega 2560 (5V and GND).
- Encoder A/B: Signal outputs to the Arduino Mega 2560 digital pins.
Motor Driver 1A Dual TB6612FNG
- VM: Power for the motors from the step-up boost power converter.
- VCC: Logic power from the Arduino Mega 2560 (5V).
- GND: Common ground with other components.
- AIN1/AIN2/BIN1/BIN2: Control inputs from the Arduino Mega 2560 digital pins.
- PWMA/PWMB: PWM control signals from the Arduino Mega 2560.
- A01/A02/B01/B02: Outputs to the gear motors.
QTRX-HD-07RC Reflectance Sensor Array
- VCC/GND: Power supply from the Arduino Mega 2560.
- 1-7: Signal outputs to the Arduino Mega 2560 digital pins.
HC-SR04 Ultrasonic Sensor
- VCC/GND: Power supply from the Arduino Mega 2560.
- TRIG/ECHO: Control and signal pins connected to the Arduino Mega 2560 digital pins.
Power Management
- 18650 Li-ion Battery: Provides power to the protection board and charging board.
- 2S lithium battery protection board module: Ensures safe charging and discharging of the batteries.
- Lithium Battery Charging Board Type-C: Charges the batteries.
- Step Up Boost Power Converter: Boosts voltage for the motor driver.
- Buck Converter: Steps down voltage for the Arduino Mega 2560 and ESP32.
Rocker Switch
- Input/Output: Controls the connection between the battery protection board and the charging board.
Resistor
- Resistors: Used in various parts of the circuit for current limiting and voltage dividing.
Documented Code
Arduino Mega 2560 Code (sketch.ino)
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Note: The provided code for the Arduino Mega 2560 is a template with empty setup and loop functions. The actual functionality needs to be implemented based on the requirements of the circuit.
ESP32 Code
No code provided for the ESP32 microcontroller.
