计算机工程应用技术
本栏目责任编辑:梁 书
Computer Knowledge and Technology
电脑知识与技术
第 14 卷第 36 期 (2018 年 12 月)
第 14 卷第 36 期 (2018 年 12 月)
E-mail:kfyj@dnzs.net.cn
http://www.dnzs.net.cn
Tel:+86-551-65690963 65690964
ISSN 1009-3044
Computer Knowledge and Technology
电脑知识与技术
Vol.14, No.36, December. 2018
基于 STM32 的倒立摆控制系统设计
刘拓晟
(国网湖南省电力有限公司,湖南 长沙 410010)
摘要:倒立摆是开展各种控制实验及进行控制理论的理想实验平台,是一个不稳定的、非线性的复杂控制系统,其控制方
法在军工、航天、机器人和一般工业过程领域中都有着广泛的用途。该系统采用 stm32f103rct6 单片机为控制器,以角位移
传感器为反馈装置,以直流减速电机作为执行装置,采用 PID 控制算法,设计了一个简易的旋转倒立摆控制系统。能够完
成倒立摆的稳定倒立、起摆倒立、旋转倒立等动作。
关键词:stm32f103rct6;角位移传感器;直流减速电机;PID算法;倒立摆
中图分类号:TP302 文献标识码:A 文章编号:1009-3044(2018)36-0213-03
The Design of Inverted Pendulum System Based on STM32
LIU Tuo-sheng
(State Grid Hunan Electric Power Company Limited, Changsha 410100,China)
Abstract:Inverted pendulum is an ideal experimental platform for carrying out various control experiments and control theory
teaching. It is an unstable and nonlinear complex control system. Its control methods are widely used in military, aerospace, robot⁃
ics and general industrial processes. use. In this paper, the stm32f103rct6 micro-controller is used as the controller, the angular dis⁃
placement sensor is used as the feedback device, the DC geared motor is used as the actuator, and the PID control algorithm is
used to design a simple rotary inverted pendulum control system. The final test results show that the design of this program is basi⁃
cally feasible, and it can complete the actions of the inverted pendulum, such as a stable inverted handstand, a pendulum upside
down, and an inverted handstand.
Key words:stm32f103rct6; Angular displacement sensor; DC geared motor; PID algorithm; Inverted pendulum
1 背景
倒立摆控制系统是一种经典的研究自动化控制的实验装
置,其应用已经广泛分布于机器人控制、工业自动化控制、航空
航天及人工智能等领域,在自动化控制领域占据着非常重要的
地位。同时,倒立摆因为结构简单、成本低廉等特点,许多学校
和相关研究机构都将其作为教学、实验平台,进行控制理论教
学和开展各种控制实验
[1]
。近年来,倒立摆控制系统的运用越
来越广泛,控制技术与方法也愈加成熟。人们通过对倒立摆控
制系统的研究,处理各种多变量问题、非线性问题及不稳定系
统问题,进而延伸到各类工控领域,与工业应用相结合,对解决
实际问题有着显著的帮助
[2]
。
2 总体方案设计
倒立摆硬件系统包括 STM32主控模块、角位移传感器模
块、电机驱动模块、稳压模块、直流减速电机等。系统的电源采
用 3 节 18650 电池供电,利用稳压模块为电机驱动模块提供 8V
的电压,给单片机提供 5V 的电压。将角位移传感器传回的实
时角度和直流减速电机传回的速度传入主控制器,主控制器通
过 PID 控制器计算并输出电机下一步运行所需的 PWM 值,驱
动电机运行,最终实现摆杆的动态平衡。系统运行期间,利用
Nokia 5110 进行实时数据显示与模式调节显示,方便整个系统
的运行。在机械结构方面,采用不锈钢制成的支架,提高了整
体结构的稳定性;采用导线环与电机相连,解决了系统运行时
的绕线问题。系统整个结构图如图 1所示。
图 1 系统结构框图
3 系统硬件设计
3.1 主控最小系统设计
该设计选用 STM32F103RCT6 作为控制核心,需要调用几
收稿日期:2018-10-29
作者简介:刘拓晟(1982—),高级工程师,硕士,研究方向为输配电及用电工程。
213
DOI:10.14004/j.cnki.ckt.2018.4289