Arduino Mega 2560 Controlled Time-Tracking System with Relay-Operated Solenoid and Stepper Motor Drivers
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This document provides a comprehensive overview of a circuit designed to interface various components including an Arduino Mega 2560, DS3231 RTC, pushbuttons, a limit switch, relays, a solenoid, a DC source, diodes, a MOSFET, resistors, mini air pumps, stepper motors (Nema 17 42-STH48), stepper motor drivers (A988 DRIVER), a Raspberry Pi 4B, and a 7 inch WaveShare (H) display. The circuit is powered by a 5V DC source and a 12V power supply, and it includes communication between the Arduino Mega 2560 and the DS3231 RTC via I2C, as well as serial communication between the Arduino Mega 2560 and the Raspberry Pi 4B. The circuit controls the stepper motors, solenoid, and mini air pump through the Arduino Mega 2560, with the MOSFET and relays acting as switches.
Component List
Arduino Mega 2560
A microcontroller board based on the ATmega2560, featuring numerous digital and analog I/O pins, PWM outputs, and communication interfaces.
DS3231 RTC
A real-time clock module that provides accurate timekeeping with I2C communication.
Pushbutton (x2)
A simple switch mechanism for controlling some aspect of a machine or a process.
Limit Switch
An electromechanical device that consists of an actuator mechanically linked to a set of contacts.
5V Relay
An electrically operated switch that allows low-power circuits to switch a relatively high current/voltage on/off.
Solenoid
An electromechanical device that converts electrical energy into a linear motion.
DC Source 5V
A power supply unit that provides a 5V DC output.
Diode (x2)
A semiconductor device that allows current to flow in one direction only, used for protection and rectification.
nMOS Transistor (MOSFET)
A type of field-effect transistor used as an electronic switch or amplifier.
Resistor
A passive electrical component that implements electrical resistance as a circuit element.
Mini Air Pump
A small pump used for moving air, often used in small-scale automation projects.
Nema 17 42-STH48 (x2)
A stepper motor commonly used for precision control in CNC machines and 3D printers.
12V Power Supply
A power supply unit that provides a 12V DC output.
A988 DRIVER (x2)
A stepper motor driver that controls the stepper motors by varying the current in the phases.
Raspberry Pi 4B
A small single-board computer with GPIO pins for interfacing with electronic components.
7 inch WaveShare (H)
A 7-inch display with HDMI, VGA, and USB interfaces for visual output and touch input.
Wiring Details
Arduino Mega 2560
- 5V connected to DS3231 RTC VCC, 5V relay VCC, and both A988 DRIVER VDD.
- GND connected to DS3231 RTC GND, both pushbuttons, limit switch NO, 5V relay GND, both A988 DRIVER GND, and 12V power supply -.
- D21/SCL connected to DS3231 RTC SCL.
- D20/SDA connected to DS3231 RTC SDA.
- D19/RX1 connected to Raspberry Pi 4B GPIO14.
- D18/TX1 connected to Raspberry Pi 4B GPIO15.
- D10 PWM connected to A988 DRIVER STEP (c6488e98).
- D11 PWM connected to A988 DRIVER STEP (60e70373).
- D12 PWM connected to nMOS Transistor gate.
- D13 PWM connected to 5V relay In.
- D40 connected to A988 DRIVER DIR (c6488e98).
- D38 connected to A988 DRIVER RST (c6488e98).
- D36 connected to A988 DRIVER MS2 (c6488e98).
- D34 connected to A988 DRIVER EN (c6488e98).
- D32 connected to A988 DRIVER DIR (60e70373).
- D30 connected to A988 DRIVER RST (60e70373).
- D28 connected to A988 DRIVER MS2 (60e70373).
- D26 connected to A988 DRIVER EN (60e70373).
- D24 connected to limit switch C.
- D22 connected to pushbutton Pin 1 (in) (c13fe091).
- D39 connected to A988 DRIVER SLP (c6488e98).
- D37 connected to A988 DRIVER MS3 (c6488e98).
- D35 connected to A988 DRIVER MS1 (c6488e98).
- D31 connected to A988 DRIVER SLP (60e70373).
- D29 connected to A988 DRIVER MS3 (60e70373).
- D27 connected to A988 DRIVER MS1 (60e70373).
- D23 connected to pushbutton Pin 1 (in) (2057d4d8).
DS3231 RTC
- SCL connected to Arduino Mega 2560 D21/SCL.
- SDA connected to Arduino Mega 2560 D20/SDA.
- VCC connected to Arduino Mega 2560 5V.
- GND connected to Arduino Mega 2560 GND.
Pushbuttons
- Pin 1 (in) of one pushbutton connected to Arduino Mega 2560 D22.
- Pin 1 (in) of the other pushbutton connected to Arduino Mega 2560 D23.
- Pin 2 (in) of both pushbuttons connected to Arduino Mega 2560 GND.
- Pin 3 (out) and Pin 4 (out) of both pushbuttons are interconnected.
Limit Switch
- C connected to Arduino Mega 2560 D24.
- NO connected to Arduino Mega 2560 GND.
5V Relay
- VCC connected to Arduino Mega 2560 5V.
- GND connected to Arduino Mega 2560 GND.
- In connected to Arduino Mega 2560 D13 PWM.
- Common terminal connected to DC Source 5V VCC.
- Normally Open connected to Solenoid pin2 through Diode cathode.
Solenoid
- Pin1 connected to nMOS Transistor drain through Diode anode.
- Pin2 connected to 5V relay Normally Open through Diode cathode.
DC Source 5V
- VCC connected to Raspberry Pi 4B 5V and 5V relay Common terminal.
- GND connected to nMOS Transistor source.
Diodes
- Anode of one diode connected to nMOS Transistor drain and Solenoid pin1.
- Cathode of the same diode connected to Mini Air Pump PIN1.
- Anode of the other diode connected to nMOS Transistor source.
- Cathode of the other diode connected to 5V relay Normally Open and Solenoid pin2.
nMOS Transistor (MOSFET)
- Gate connected to Arduino Mega 2560 D12 PWM through Resistor pin1.
- Drain connected to Solenoid pin1 through Diode anode and Mini Air Pump PIN1 through Diode cathode.
- Source connected to DC Source 5V GND.
Resistor
- Pin1 connected to nMOS Transistor gate.
- Pin2 connected to Arduino Mega 2560 GND.
Mini Air Pump
- PIN1 connected to nMOS Transistor drain through Diode cathode.
- PIN2 connected to Diode cathode.
Nema 17 42-STH48
- A2 (black) and A1 Green of one stepper motor connected to A988 DRIVER 1B and 1A (60e70373).
- B2 Red and B1 Blue of the same stepper motor connected to A988 DRIVER 2B and 2A (60e70373).
- A2 (black) and A1 Green of the other stepper motor connected to A988 DRIVER 2A and 2B (c6488e98).
- B2 Red and B1 Blue of the other stepper motor connected to A988 DRIVER 1A and 1B (c6488e98).
12V Power Supply
-
- connected to both A988 DRIVER VMOT.
-
- connected to Arduino Mega 2560 GND.
A988 DRIVER
- VMOT connected to 12V power supply +.
- GND connected to Arduino Mega 2560 GND.
- 1A, 1B, 2A, 2B connected to corresponding pins of Nema 17 42-STH48 stepper motors.
- VDD connected to Arduino Mega 2560 5V.
- STEP, DIR, RST, SLP, MS1, MS2, MS3, EN connected to corresponding pins on Arduino Mega 2560.
Raspberry Pi 4B
- GPIO14 connected to Arduino Mega 2560 D19/RX1.
- GPIO15 connected to Arduino Mega 2560 D18/TX1.
- 5V connected to DC Source 5V VCC and 7 inch WaveShare (H) +.
- GND connected to Arduino Mega 2560 GND and 7 inch WaveShare (H) -.
7 inch WaveShare (H)
-
- connected to Raspberry Pi 4B