yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
2DOF PTZ📖
0.About 2DOF PTZ
  • About 2DOF PTZ
1.PTZ Installation tutorial
  • PTZ Installation tutorial
2.Drive servo
180° Servo
  • Arduino Tutorials
  • microbit Tutorials
  • MSPM0G3507 turtorials
  • MSPM0G3519 turtorials
  • Raspberry Pi tutorials
  • Raspberry pico tutorials
270° Servo
  • Arduino Tutorials
  • Microbit Tutorials
  • MSPM0G3507 Tutorials
  • MSPM0G3519 Tutorials
  • Raspberry Pi Pico Tutorials
  • Raspberry Pi Tutorials
3.K230 module on PTZ
  • 1. PTZ face tracking
  • 2. PTZ color tracking
  • 3. Fruit sorting
  • 4. Rock-paper-scissors game
  • 5. Gesture control
  • 6. Human tracking alarm
  • 7. Moving target control and tracking
4.K210 module on PTZ
  • 1.2DOF PTZ Color Tracking
  • 2.2DOF Face Tracking
  • 3.2DOF Fruit sorting
Download ZIP

Welcome to 2DOF PTZ repository

MSPM0G3507 turtorials

2-DOF gimbal

1. Learning objectives

Drive 2-DOF gimbal.

2. Hardware connection

The servos used in this case are 180 and 270

MSPM0G3507 connected to servo pins

PA17 connected to 180-degree servo

PA18 connected to 270-degree servo

All modules connected together must share a common ground

3. Program description

  • bsp_servo.h
xxxxxxxxxx
#ifndef __BSP_SERVO_H_
#define __BSP_SERVO_H_
​
#include "ti_msp_dl_config.h"
​
​
​
void Set_Servo270_Angle(unsigned int angle);
void Set_Servo_Angle(unsigned int angle);
unsigned int Get_Servo_Angle(void);
unsigned int Get_Servo_Angle270(void);
​
#endif

Define four servo control functions.

  • bsp_servo.c
x
/******************************************************************
 * Function name: Set_Servo270_Angle
 * Function description: Set 270 degree servo
 * Function parameter: angle = angle to be set, range 0-270
 * Function return: None
 * 函数名称:Set_Servo270_Angle
 * 函数说明:设置270度舵机
 * 函数形参:angle=要设置的角度,范围0-270
 * 函数返回:无
******************************************************************/
void Set_Servo270_Angle(unsigned int angle)
{
      uint32_t period = 400;
​
      if(angle > 270)
      { 
            angle = 270; // 限制角度在0到270度之间 Limit the angle to between 0 and 270 degrees
      }
            
      Servo_Angle270 = angle;
            
      // 计算pwm占空比 Calculate pwm duty cycle
      // 0.5ms对应的计数 = 10   0.5ms corresponding count = 10
      // 2.5ms对应的计数 = 50   Count corresponding to 2.5ms = 50
      float min_count = 10.0f;
      float max_count = 50.0f;
      float range = max_count - min_count;
      float ServoAngle = min_count + (((float)angle / 270.0f) * range);
​
      DL_TimerG_setCaptureCompareValue(PWM_Servo_INST, (unsigned int)(ServoAngle + 0.5f), GPIO_PWM_Servo_C1_IDX);
}
​
unsigned int Get_Servo_Angle270(void)
{
      return Servo_Angle270;

Set_Servo270_Angle is used to set the angle of the servo motor, and Get_Servo_Angle270 is used to obtain the current angle of the servo motor.

Note: The project source code must be placed in the SDK path for compilation,

For example, the path: D:\TI\M0_SDK\mspm0_sdk_1_30_00_03\1.TB6612

4

 

 

microbit Tutorials
MSPM0G3519 turtorials

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文