Explore Using a Customized Arduino Nano-based Board to Wirelessly Control Up to 9 Servo Motors Via Bluetooth
by MertArduino in Circuits > Arduino
3864 Views, 35 Favorites, 0 Comments
Explore Using a Customized Arduino Nano-based Board to Wirelessly Control Up to 9 Servo Motors Via Bluetooth
In this project, we will take a look at the soldering process and how to use a Multiple Servo motor board with an Atmega-based Arduino Nano microcontroller. In one of my previous projects, I designed an ESP32-based board that allows Multiple Servo motor control, and I discussed how to control the board via Wi-Fi, and Bluetooth. Some of my followers gave me the idea to design an Atmega-based version of this board. The new board I designed allows you to control up to 9 Servo motors and also allows you to control the motors wirelessly using the Bluetooth module mounted on it.
Circuit Schematic
If we take a closer look at the circuit diagram of the design, there is an adjustable voltage regulator module on the board. The converter module makes it possible to adjust the voltage in line with the power needs of the Servo motors independently of the Arduino Nano. The required voltage level can be adjusted with the potentiometer on the module.
A Schottky diode is added to the servo motor power line, its function is to increase the reliability of the circuit by helping to control power line fluctuations, voltage reverse flow, and electromagnetic noise. I have also added two capacitors to the circuit. Servo motors can require large amounts of current during sudden movements. Capacitors can be used to meet such sudden power demands stabilize the power supply and also help to reduce power supply fluctuations.
I also added a resistor to each servo motor signal leg. The resistors act as a protection resistor in the circuit. The resistor protects the servomotor's signal leg from overcurrent and harmful voltages by limiting the signal from the microcontroller in some way.
Finally, since the servo motors and Arduino Nano share the power line of the circuit, a jumper is added to disconnect the power line to which the servo motors are connected when programming the microcontroller. The same applies to the Bluetooth module, since the TX and RX pins are busy during programming, a jumper was added to the Bluetooth power input to prevent communication errors, making it possible to cut the Bluetooth power during programming. Finally, a capacitor was added to the Arduino Nano VIN supply input to reduce power fluctuations.
Downloads
Printed Circuit Board Design
If we take a look at the design of the printed circuit board as well as the circuit diagram, a 2-layer PCB was preferred and the circuit elements and modules on the PCB were aimed to be easily removable and solderable. In addition, the width of the tracks that can be affected by high currents in the circuit was kept wider. Finally, the heat dissipation on the circuit board was optimized by applying ground copper area on both layers.
The print quality is as important as the design of the printed circuit board. I have been successfully cooperating with PCBWay for PCB printing services for many years. I regularly upload all necessary files and details of my projects to PCBWay's project-sharing page. In this context, you can use the link provided to access the detailed information and design file of the project, review the project and if you wish, you can have this circuit board using only PCB or assembled PCB services. You can visit the link to go to the project page and download the design file.
Downloads
Soldering Process
If you have received the low-cost and high-quality PCBs, we can now move on to the soldering process. As a first step, I recommend placing and soldering some of the resistors connected to the servo motor signal legs. This way you can avoid the complexity of the component legs. For soldering you will need a basic soldering iron, solder wire, a stand, and a cutter. Touch the tip of the heated soldering iron to the pad and then apply the solder wire so that it makes contact between the pad and the component. Then use a cutter to cut the leg length of the components.
Place the remaining resistors and continue the soldering process. Then place the diode on the board with the polarity on the correct side and solder it. Now let's move on to the male and female headers. You can mount the voltage module without headers, but I recommend using male headers to provide a space between the module and the board. This will avoid any heat from the module touching the board. First, four male headers are soldered to the module. Then all the other headers are placed and a pin of each header is fixed to the board with some solder on the tip of the soldering iron. In this way, when the back side of the board is rotated, all the headers are fixed and the soldering process can be easily completed.
Now it is the turn of the capacitors. When placing the capacitors on the board, make sure that the polarity is correct; the side with the gray marking is negative, in other words, the ground pole. Finally, you can complete the soldering process by placing and soldering the connector required for the power supply input. I recommend applying electronic cleaner to the back surface of the board and cleaning it with a PCB solder brush.
Power Supply for Servo Motors
After soldering, make sure that the circuit power line provides the correct voltage. To do this, first, adjust the potentiometer on the power module using a screwdriver to the output voltage level suitable for the power requirement of the servo motors. The potentiometer must be moved slowly and carefully as it requires a very fine adjustment.
Next, check for the correct function of the jumper, which can interrupt and complete the power line to the servomotors. The circuit is powered via the connector; the microcontroller and servomotors are fed directly from this power supply. During programming or communication via USB, a servo motor power cut-off jumper is used to prevent the servo motors from drawing high currents and damaging the microcontroller or computer. When the jumper is plugged in, power is supplied to the servomotors; when the jumper is removed, the power supply to the servomotors is cut off. This allows control and safe management of the servomotors.
Multiple Servo Motor Test
After testing the power supply of the circuit, let's move on to the multiple servo motor test. 9 micro servo motors with an average operating voltage of 5 Volts are connected to the circuit. When connecting the motors, you need to pay attention that the pins are connected in the correct direction. The PINs to which the signal legs are connected are marked on the board, so the servo motor signal legs (usually orange in color) must match these pins.
Next, open the shared source code. As much explanation as possible has been added when creating the code, so it will be easier for you to understand the code. The standard Servo motor library has been added, and an array for servo definitions has been created since multiple servos are used. PINs to which servo motors are connected are defined. Two variables are defined for start and end positions. Also, one more variable was defined for delay time.
In the "Loop" section, two "for" loops are created so that the motors will rotate from the start position to the end position and then back to the start position with the opposite rotation. After uploading the code and disconnecting the USB connection, we connect the power supply to the circuit. As you can see, the servo motors are not powered without the servo power jumper in place. An on/off switch is also preferable instead of a jumper.
As observed, the circuit works well and provides smooth movement even though the servo motors are all running at the same time. However, there is currently no load on the servos, so it will be necessary to wait and observe the next project to evaluate the actual performance.
Downloads
Bluetooth Communication Test
A single servo motor will be used as the first step to perform the Bluetooth communication test. Once the servo power jumper is removed, you can connect the microcontroller to the computer via the USB port. Insert the Bluetooth module into the circuit. The important thing here is that the Arduino Nano uses the TX and RX pins during code upload, these pins are also used by the Bluetooth module.
For good communication, there is a power jumper, which allows you to cut the 5-volt power to the Bluetooth module. As long as the jumper is plugged in, the Bluetooth module continues to use the pins it is connected to. Therefore, this power jumper or the Bluetooth module must be removed during code upload. Otherwise, you may encounter a communication error during code upload.
When you take a look at the shared code, you will see that it contains basic Bluetooth communication. In other words, it reads the position values received via Bluetooth and moves the servo motor according to these values.
Downloads
Create Servo Motor Control Application
Of course, an application is needed to send data via Bluetooth. In this project, the App Inventor platform was preferred to create a free and simple application instead of using a ready-made application. The UI of the application includes a list of devices, 5 direction buttons, and a direction slider. In the backend of the application, code blocks were created to list the devices, show the connection status, and communicate the positions of the slider and buttons.
To get the app on your device, you can use the "Android App" option from the "Build" tab. Also, the project file of the application is shared and you have the opportunity to import this file into App Inventor and edit it.
The App Inventor aia extension is not supported here, so you can download the file from here - https://www.pcbway.com/project/shareproject/Explore_using_a_customized_Arduino_Nano_based_board.html
Control Servo Motors Via Bluetooth Using the App
Once you have the app, turn on your device's Bluetooth connection. Then, launch the app, click on the Bluetooth icon, and connect to the HC-06 Bluetooth module among the listed devices. If a password is requested during the connection, complete the connection by entering the password '1234'. When communication is established, you will see 'Connection Successful'. You can now wirelessly control a servomotor or multiple servomotors via the application. As observed, the Bluetooth connection, the communication between the board and the app, and the servomotor movements are working perfectly.
At this stage, the project has come to an end as the board is considered to be completed. You can access all project details and files from the shared links. Thanks for reading!