Project Report On Gimbal Controller Using STM32
Project Report On Gimbal Controller Using STM32
By
1. GODSE PRATEEK YASHODHAN XD-21-0077
2. JOSHI AVADHOOT KIRAN XD-21-0071
3. NIMKAR RUTURAJ PRABHAKAR XD-21-0074
4. DESAI SANCHIT SUBHASH XD-21-0069
Hope Foundation’s
Finolex Academy of Management & Technology, Ratnagiri
Academic Year 2022-23
I
CERTIFICATE
This is to certify that the project entitled GIMBAL CONTROLLER USING STM32
is a bonafide work of
submitted to the University of Mumbai in partial fulfillment of the requirement for the
award of Mini Project 2A (REV- 2019 ‘C’ Scheme) of Third Year, (TE Sem-V) in
Electronics & Telecommunication Engineering as laid down by University of
Mumbai during academic year 2022-23
( )
Examiner/Reviewer-1
2
INDEX
ABSTRACT 4
1 INTRODUCTION 5
1.1 Need of selected topic 5
1.2 Description 5
1.3 Literature Survey
2 Mini Project DESIGN (PRINCIPLE AND WORKING)
2.1 Block Diagram 6
2.2 Circuit Diagram 7
2.3 Circuit Diagram Description with working 7
2.4 Code 8
3 COMPONENTS/TOOL TO BE USED
3.1 STM32 (microcontroller) 18
3.2 Bluetooth module 19
3.3 Servo motor 20
4 Result 22
5 Application 23
6 Conclusion 24
7 References 25
3
ABSTRACT
A smartphone is a device that has been widely used by people as taking photos or selfies in
everyday life. The addition of a gimbal system can reduce the reduction in out-of-focus results
produced by the human handgrip to the smartphone holder. In this study, control was carried out
using an Arduino Uno microcontroller with the help of servo. The result of the research is that the
movement of the servo is proportional to the given input value. There is a significant error value
generated in the roll movement to the left due to low sensor readings and the lack of implementation
of PID control on the system.
4
1. INTRODUCTION
1.2 Description
A smartphone is a device that has been widely used by people as taking photos or selfies in
everyday life. The addition of a gimbal system can reduce the reduction in out-of-focus results
produced by the human handgrip to the smartphone holder. In this study, control was carried out using
an microcontroller with the help of servo. The result of the research is that the movement of the servo
is proportional to the given input value. There is a significant error value generated in the roll
movement to the left due to low sensor readings and the lack of implementation of PID control on the
system.
A smartphone is a mobile phone with advanced features and has functionality beyond the
functionality of previous mobile phones. Smartphones can take pictures or videos, depending on the
user's needs. Taking photographs or videos done via smartphones still depends on the user's expertise
in taking pictures or videos. Seeing the need for a gimbal system to make it easier for users who are
less skilled in taking pictures or videos, a gimbal system can be created that stabilizes the smartphone
when taking pictures or videos by moving the bracket from the smartphone in the opposite direction
of the user's movement so that the smartphone can be stable in the shooting process or video taking
process. The gimbal is a mechanical device that is mounted on a specific axis to maintain the stability
of an object or tool in a certain position. Nowadays, gimbals are widely used in various fields, one of
which is in the process of photography and videography. DSLR cameras have used the help of gimbals
for shooting and video, especially in the realm of film. The main benefit of the gimbal system is that it
reduces the shock that occurs caused by the human hand, holding the weight of the object.
5
2.MINI PROJECT DESIGN
Servo Motor 1
Mobile
Accelerometer
STM32F103C8T6
Microcontroller
HC05
Bluetooth Servo Motor 2
Module
6
2.2 Circuit Diagram
We have a Mobile app which has given access to the Accelerometer sensor of the mobile. The
app records values from the sensor an send them to the STM microcontroller thorough HC05 Bluetooth
module. The microcontroller then processes on that data according to programming.
7
In the program we set the threshold value as 3 degrees. For example, if there is a horizontal
movement and the data coming from sensor is larger than the threshold value which is of 10 degrees,
then the program will minus the 7 from the 10 to make it equal to threshold value. And give signal to
Servo motor 1 to move -7 degrees in the opposite direction.
So like that if there is vertical movement and the data coming from sensor is more than the
threshold value which is of 5 degrees, then the program will minus the 2 from the 5 to make it equal to
threshold value. And give signal to Servo motor 2 to move -2 degrees in opposite direction.
Using this logic we can stabilize the mobile and remove the shake coming while holding the
mobile to record videos.
2.4 Code
#include "main.h"
/* Private variables ---------------------------------------------------------*/
TIM_HandleTypeDef htim2;
TIM_HandleTypeDef htim4;
UART_HandleTypeDef huart2;
8
/* USER CODE BEGIN PFP */
/**
* @brief The application entry point.
int main(void)
{
/* USER CODE BEGIN 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/**
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/**
* @brief TIM2 Initialization Function
* @param None
* @retval None
*/
static void MX_TIM2_Init(void)
{
11
/* USER CODE BEGIN TIM2_Init 0 */
htim2.Instance = TIM2;
htim2.Init.Prescaler = 720;
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
htim2.Init.Period = 1999;
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
{
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
12
/* USER CODE BEGIN TIM2_Init 2 */
/**
* @brief TIM4 Initialization Function
* @param None
* @retval None
*/
static void MX_TIM4_Init(void)
{
14
}
/**
* @brief USART2 Initialization Function
* @param None
* @retval None
*/
static void MX_USART2_UART_Init(void)
{
}
15
/**
* @brief GPIO Initialization Function
* @param None
* @retval None
*/
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */
}
#endif /*USE_FULL_ASSERT*/
17
3. COMPONENTS USED
3.1 STM32
The Blue Pill is a 32-bit Arduino compatible development board that features the STM32F103C8T6,
a member of the STM32 family of ARM Cortex-M3 core microcontrollers. This board aims to bring
the 32-bit ARM Cortex microcontrollers to the hobbyist market with the Arduino style form factor.
There are three ways of powering your Blue Pill development board:
Input/Output:
The Blue Pill has 37 GPIO pins spread across four ports – A and B (16 pins), C (3 pins) and D (2 pins).
Each pin has a current sink/source ability of 6mA. Pull-up and pull-down resistors can be enabled on
each of the pins.
• Serial ports – receive and transmit data via the UART protocol
• I2C ports – two-wire communication via the IIC protocol
• SPI – serial communication
• PWM
• Pin 13 has a built-in LED
18
3.2 HC 05 Bluetooth module:
HC-05 Bluetooth Module is an easy-to-use Bluetooth SPP (Serial Port Protocol) module, designed for
transparent wireless serial connection setup. Its communication is via serial communication which
makes an easy way to interface with controller or PC. HC-05 Bluetooth module provides switching
mode between master and slave mode which means it able to use neither receiving nor transmitting
data.
Specification:
• Model: HC-05
• Input Voltage: DC 5V
• Communication Method: Serial Communication
• Master and slave mode can be switched
19
3.3 Servo motor :
A servo consists of a Motor (DC or AC), a potentiometer, gear assembly, and a controlling circuit.
First of all, we use gear assembly to reduce RPM and to increase torque of the motor. Say at initial
position of servo motor shaft, the position of the potentiometer knob is such that there is no electrical
signal generated at the output port of the potentiometer. Now an electrical signal is given to another
input terminal of the error detector amplifier. Now the difference between these two signals, one comes
from the potentiometer and another comes from other sources, will be processed in a feedback
mechanism and output will be provided in terms of error signal. This error signal acts as the input for
motor and motor starts rotating. Now motor shaft is connected with the potentiometer and as the motor
rotates so the potentiometer and it will generate a signal. So as the potentiometer’s angular position
changes, its output feedback signal changes. After sometime the position of potentiometer reaches at a
position that the output of potentiometer is same as external signal provided. At this condition, there
will be no output signal from the amplifier to the motor input as there is no difference between external
applied signal and the signal generated at potentiometer, and in this situation motor stops rotating.
SG-90 Features:
20
Fig 3.3.2: Servo motor pin description
21
4. RESULT
*EXPECTED RESULT
1. The shake causing due to hand movement is removed.
22
5. APPLICATION
• Gimbal can be used in photography and videography applications for the stabilizing the camera
to capture photos and videos without shake.
• Gimbals are common in aerospace and military applications, especially for tracking and
communication devices.
• In industrial settings, two- and three-axis gimbal stages are used for sensor calibration and
alignment and for precise angular positioning of optics and lasers.
23
6. CONCKUSION
The conclusion obtained from the research is that the addition of a gimbal system on a
smartphone holder stick can help users to take pictures or videos that are more stable and do not cause
blur. However, this research tool still needs more development to reduce the errors generated, because
it can be seen for the roll movement to the left still causes a significant error value. It is necessary to
add a control system to reduce the resulting errors.
24
7. REFERANCES
1. Gimbal System Design for Smartphone Holder, International Journal of Emerging Trends in
Engineering Research.
2. https://github.com/olliw42/storm32bgc
3. https://github.com/viktorvano/Bluetooth-for-STM32-and-Android
4. https://www.st.com/content/st_com/en.html
5. https://www.programiz.com/c-programming
25