Arduino and Raspberry Pi Controlled Robotic System with DC and Brushless Motors
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This document provides a detailed overview of a circuit that integrates various components including an Arduino Mega 2560, a Raspberry Pi 4B, multiple DC and brushless motors, motor drivers, LEDs, a LiDAR sensor, and magnetic encoder position sensors. The circuit is designed to control and monitor the motors and sensors, with power supplied by a 12V battery. The Arduino Mega 2560 and Raspberry Pi 4B serve as the primary microcontrollers for this setup.
Component List
Arduino Mega 2560
- Description: A microcontroller board based on the ATmega2560.
- Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0-A15, D0-D53, AREF, SDA, SCL
Raspberry Pi 4B
- Description: A small single-board computer.
- Pins: 3V3, 5V, GPIO2-GPIO27, ID_SD, ID_SC, TR01_TAP, TR00_TAP, TR03_TAP, TR02_TAP, RUN, GLOBAL_EN
12V Battery
- Description: A power source providing 12V.
- Pins: VCC, GND
DC Motor
- Description: A motor that runs on direct current.
- Pins: pin 1, pin 2
Brushless Motor
- Description: A motor that runs on alternating current.
- Pins: L1, L2, L3
L298N DC Motor Driver
- Description: A dual H-Bridge motor driver.
- Pins: OUT1, OUT2, 12V, GND, 5V, OUT3, OUT4, 5V-ENA-JMP-I, 5V-ENA-JMP-O, +5V-J1, +5V-J2, ENA, IN1, IN2, IN3, IN4, ENB
Electronic Speed Controller (ESC)
- Description: A device to control brushless motors.
- Pins: Battery VCC, Battery GND, Signal, 5v out, GND out, M1, M2, M3
LiDAR TF Mini S
- Description: A LiDAR sensor for distance measurement.
- Pins: Ground, VC, RX (blue), TX (green)
LED: Two Pin (white)
- Description: A white LED with two pins.
- Pins: cathode, anode
LED: Two Pin (red)
- Description: A red LED with two pins.
- Pins: cathode, anode
AS5048 Magnetic Encoder Position Sensor
- Description: A magnetic encoder for position sensing.
- Pins: GND, nCS, CLK, MOSI, MISO, VDD5V, PWM
Wiring Details
Arduino Mega 2560
- 5V: Connected to VDD5V of AS5048 Magnetic Encoder Position Sensors and 5v out of Electronic Speed Controllers.
- GND: Connected to GND of various components including ESCs, AS5048 Magnetic Encoder Position Sensors, and LEDs.
- VIN: Connected to VCC of the 12V Battery.
- D2 PWM: Connected to PWM of an AS5048 Magnetic Encoder Position Sensor.
- D3 PWM: Connected to PWM of another AS5048 Magnetic Encoder Position Sensor.
- D6 PWM: Connected to Signal of an Electronic Speed Controller.
- D7 PWM: Connected to Signal of another Electronic Speed Controller.
- D8 PWM: Connected to anode of a white LED.
- D9 PWM: Connected to anode of another white LED.
- D10 PWM: Connected to anode of a red LED.
- D11 PWM: Connected to anode of another red LED.
- SDA: Connected to nCS of AS5048 Magnetic Encoder Position Sensors.
- SCL: Connected to CLK of AS5048 Magnetic Encoder Position Sensors.
- D52: Connected to MOSI of an AS5048 Magnetic Encoder Position Sensor.
- D50: Connected to MOSI of another AS5048 Magnetic Encoder Position Sensor.
- D53: Connected to MISO of an AS5048 Magnetic Encoder Position Sensor.
- D51: Connected to MISO of another AS5048 Magnetic Encoder Position Sensor.
Raspberry Pi 4B
- 5V: Connected to VC of the LiDAR TF Mini S.
- GND: Connected to GND of the 12V Battery and other components.
- GPIO14: Connected to TX (green) of the LiDAR TF Mini S.
- GPIO15: Connected to RX (blue) of the LiDAR TF Mini S.
12V Battery
- VCC: Connected to VIN of the Arduino Mega 2560, Battery VCC of Electronic Speed Controllers, and 12V of the L298N DC Motor Driver.
- GND: Connected to GND of various components including the Raspberry Pi 4B, Arduino Mega 2560, and ESCs.
DC Motor
- pin 1: Connected to OUT1 of the L298N DC Motor Driver.
- pin 2: Connected to OUT2 of the L298N DC Motor Driver.
Brushless Motor
- L1: Connected to M1 of an Electronic Speed Controller.
- L2: Connected to M2 of an Electronic Speed Controller.
- L3: Connected to M3 of an Electronic Speed Controller.
L298N DC Motor Driver
- OUT1: Connected to pin 1 of a DC Motor.
- OUT2: Connected to pin 2 of a DC Motor.
- OUT3: Connected to pin 1 of another DC Motor.
- OUT4: Connected to pin 2 of another DC Motor.
- 12V: Connected to VCC of the 12V Battery.
- GND: Connected to GND of the 12V Battery.
Electronic Speed Controller (ESC)
- Battery VCC: Connected to VCC of the 12V Battery.
- Battery GND: Connected to GND of the 12V Battery.
- Signal: Connected to D6 PWM and D7 PWM of the Arduino Mega 2560.
- 5v out: Connected to 5V of the Arduino Mega 2560.
- GND out: Connected to GND of the Arduino Mega 2560.
- M1: Connected to L1 of a Brushless Motor.
- M2: Connected to L2 of a Brushless Motor.
- M3: Connected to L3 of a Brushless Motor.
LiDAR TF Mini S
- VC: Connected to 5V of the Raspberry Pi 4B.
- Ground: Connected to GND of the Raspberry Pi 4B.
- RX (blue): Connected to GPIO15 of the Raspberry Pi 4B.
- TX (green): Connected to GPIO14 of the Raspberry Pi 4B.
LED: Two Pin (white)
- anode: Connected to D8 PWM and D9 PWM of the Arduino Mega 2560.
- cathode: Connected to GND of the Arduino Mega 2560.
LED: Two Pin (red)
- anode: Connected to D10 PWM and D11 PWM of the Arduino Mega 2560.
- cathode: Connected to GND of the Arduino Mega 2560.
AS5048 Magnetic Encoder Position Sensor
- VDD5V: Connected to 5V of the Arduino Mega 2560.
- GND: Connected to GND of the Arduino Mega 2560.
- nCS: Connected to SDA of the Arduino Mega 2560.
- CLK: Connected to SCL of the Arduino Mega 2560.
- MOSI: Connected to D52 and D50 of the Arduino Mega 2560.
- MISO: Connected to D53 and D51 of the Arduino Mega 2560.
- PWM: Connected to D2 PWM and D3 PWM of the Arduino Mega 2560.
Documented Code
Arduino Mega 2560 Code
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
This code is a basic template for the Arduino Mega 2560. The setup function is used to initialize any settings or configurations, and the loop function contains the main code that runs repeatedly. Further code can be added to control the motors, read sensor data, and perform other tasks as required by the circuit's functionality.