0% found this document useful (0 votes)
513 views25 pages

Project Report On Gimbal Controller Using STM32

The document describes the design of a gimbal controller system using an STM32 microcontroller. The system uses accelerometer data from a mobile phone sent over Bluetooth to control servo motors and stabilize the phone during video recording by moving mounts in the opposite direction of phone movement.

Uploaded by

Avadhoot
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
513 views25 pages

Project Report On Gimbal Controller Using STM32

The document describes the design of a gimbal controller system using an STM32 microcontroller. The system uses accelerometer data from a mobile phone sent over Bluetooth to control servo motors and stabilize the phone during video recording by moving mounts in the opposite direction of phone movement.

Uploaded by

Avadhoot
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

A Project Report On

GIMBLE CONTROLLER USING STM32


for
Mini Project 2A (REV- 2019 ‘C’ Scheme) of Third Year, (TE Sem-V)

Course code: ECM 501


in

Electronics & Telecommunication Engineering

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

Under the guidance of

PROF. G.S. KULKARNI

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

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

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

PROF. G.S. KUKARNI DR. S.V CHAUGULE


Guide Head of Department

2
INDEX

Sr. Name of Topic Page


No. Number

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.

Key words: Smartphone, Gimbal, Focus, Roll, Holder.

4
1. INTRODUCTION

1.1 Need of selected topic


Gimbal system can reduce the reduction in out-of-focus results produced by the human handgrip
to the smartphone holder. 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.

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.

1.3 Literature Survey

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

2.1 Block Diagram

INPUT SECTION OUTPUT SECTION

Servo Motor 1
Mobile
Accelerometer

STM32F103C8T6

Microcontroller
HC05
Bluetooth Servo Motor 2
Module

6
2.2 Circuit Diagram

Fig 2.1.1: Circuit Diagram

2.3 Circuit Diagram Description with working

In our project we use STM32F103C8T6 as a microcontroller. HC05 Bluetooth Module is used


to receive data from mobile app. The mobile app has given access of Accelerometer sensor which takes
sends the data according mobile movement (Level). Servo motors are used to balance the shake while
recording the video using mobile. Servo motor 1is used for controlling Horizontal movement and Servo
motor 2 is used for controlling vertical movement.

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;

/* USER CODE BEGIN PV */

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/


void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_TIM2_Init(void);
static void MX_TIM4_Init(void);
static void MX_USART2_UART_Init(void);

8
/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/


/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

/**
* @brief The application entry point.
int main(void)
{
/* USER CODE BEGIN 1 */

/* USER CODE END 1 */

/* MCU Configuration--------------------------------------------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();

/* USER CODE BEGIN Init */

/* USER CODE END Init */

/* Configure the system clock */


SystemClock_Config();

/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */

/* Initialize all configured peripherals */


9
MX_GPIO_Init();
MX_TIM2_Init();
MX_TIM4_Init();
MX_USART2_UART_Init();
/* USER CODE BEGIN 2 */

/* USER CODE END 2 */

/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */


}
/* USER CODE END 3 */
}

/**
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

/** Initializes the RCC Oscillators according to the specified parameters


* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
10
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}

/** Initializes the CPU, AHB and APB buses clocks


*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;

if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)


{
Error_Handler();
}
}

/**
* @brief TIM2 Initialization Function
* @param None
* @retval None
*/
static void MX_TIM2_Init(void)
{
11
/* USER CODE BEGIN TIM2_Init 0 */

/* USER CODE END TIM2_Init 0 */

TIM_ClockConfigTypeDef sClockSourceConfig = {0};


TIM_MasterConfigTypeDef sMasterConfig = {0};

/* USER CODE BEGIN TIM2_Init 1 */

/* USER CODE END TIM2_Init 1 */

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 */

/* USER CODE END TIM2_Init 2 */

/**
* @brief TIM4 Initialization Function
* @param None
* @retval None
*/
static void MX_TIM4_Init(void)
{

/* USER CODE BEGIN TIM4_Init 0 */

/* USER CODE END TIM4_Init 0 */

TIM_ClockConfigTypeDef sClockSourceConfig = {0};


TIM_MasterConfigTypeDef sMasterConfig = {0};
TIM_OC_InitTypeDef sConfigOC = {0};

/* USER CODE BEGIN TIM4_Init 1 */

/* USER CODE END TIM4_Init 1 */


htim4.Instance = TIM4;
htim4.Init.Prescaler = 1440;
htim4.Init.CounterMode = TIM_COUNTERMODE_UP;
htim4.Init.Period = 999;
htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim4) != HAL_OK)
{
13
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim4, &sClockSourceConfig) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIM_PWM_Init(&htim4) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 75;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_3) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_4) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM4_Init 2 */

/* USER CODE END TIM4_Init 2 */


HAL_TIM_MspPostInit(&htim4);

14
}

/**
* @brief USART2 Initialization Function
* @param None
* @retval None
*/
static void MX_USART2_UART_Init(void)
{

/* USER CODE BEGIN USART2_Init 0 */

/* USER CODE END USART2_Init 0 */

/* USER CODE BEGIN USART2_Init 1 */

/* USER CODE END USART2_Init 1 */


huart2.Instance = USART2;
huart2.Init.BaudRate = 9600;
huart2.Init.WordLength = UART_WORDLENGTH_8B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_NONE;
huart2.Init.Mode = UART_MODE_TX_RX;
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
if (HAL_UART_Init(&huart2) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART2_Init 2 */

/* USER CODE END USART2_Init 2 */

}
15
/**
* @brief GPIO Initialization Function
* @param None
* @retval None
*/
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};

/* GPIO Ports Clock Enable */


__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();

/*Configure GPIO pin Output Level */


HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET);

/*Configure GPIO pin Output Level */


HAL_GPIO_WritePin(BluetoothReset_GPIO_Port, BluetoothReset_Pin, GPIO_PIN_RESET);

/*Configure GPIO pins : LED_Pin BluetoothReset_Pin */


GPIO_InitStruct.Pin = LED_Pin|BluetoothReset_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

/* USER CODE BEGIN 4 */

/* USER CODE END 4 */


16
/**
* @brief This function is executed in case of error occurrence.
* @retval None
*/
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
__disable_irq();
while (1)
{
}
/* USER CODE END Error_Handler_Debug */
}

#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

Fig 3.1.1: STM 32F103C8T6

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:

• Using the built-in USB micro connector.


• Supplying 5V to the 5V pin as external supply.
• Supplying 3.3V directly to the 3.3V pin.

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.

Most pins have extra functionality as well:

• 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:

Fig 3.2.1: 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

Fig3.2.2: HC 05 pin description

19
3.3 Servo motor :

Fig 3.3.1: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:

• Operating Voltage is +5V typically


• Torque: 2.5kg/cm
• Operating speed is 0.1s/60°
• Gear Type: Plastic
• Rotation: 0°-180°
• Weight of motor: 9gm
• Package includes gear horns and screws

20
Fig 3.3.2: Servo motor pin description

21
4. RESULT

*EXPECTED RESULT
1. The shake causing due to hand movement is removed.

2. It improves the stabilization of handheld footage.

3. Also the quality of recorded video will increase.

22
5. APPLICATION

• Gimbal can be used in photography and videography applications for the stabilizing the camera
to capture photos and videos without shake.

• Gimbal can be used in navigation systems for ships.

• 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

You might also like