直流电机速度PID控制系统设计
摘要:针对现有的直流电机控速难的问题,本文设计了一种基于ATmega16L单片机的直流电机速度控制系统。本系统以ATmega16L单片机为主控制器,搭载了L298n为电机驱动,通过霍尔元件进行测速,通过按键控制电机的转动方向和转动速度,并配以温度传感器DS18B20对温度进行监测,通过PID算法调节PWM进行对速度控制。该系统包括的模块主要有单片机为主体的控制模块、电机的驱动模块、对电机速度进行监测的模块、由LCD1602构成的显示模块、电源模块和按键控制模块等。本系统可以通过PID算法实现可编程脉宽波形对直流电机的速度进行控制,并且可以显示出当前电机的转速。
关键词:单片机;PID算法;直流电机
The design of DC motor speed control system with PID
Abstract: According to the existing DC motor speed control problem, this paper describes the design of a DC motor speed control system based on ATmega16L MCU. To ATMEGA16L microcontroller as the main controller for the system, equipped with a L298n for motor drive, through the hall element of speed, through the buttons to control the motor rotation direction and the rotation speed, and the temperature sensor DS18B20 the temperature monitoring, PID algorithm is used to adjust the PWM control of the speed. The system includes the following modules display microprocessor control module, as the main body of the motor drive module, monitoring module, the speed of motor is composed of LCD1602 module, power supply module and key control module. This system can realize through PID algorithm to control the speed of the programming pulse waveforms of DC motor, and can display the current motor speed.
Keywords: single chip microcomputer, PID algorithm, DC motor
目录
第1章 绪论………………………………………………………………………………………………….. 1
1.1选题背景及意义………………………………………………………………………………… 1
1.2国内外研究现状………………………………………………………………………………… 2
1.3 本文主要研究的内容…………………………………………………………………………. 3
第2章 总体方案论述……………………………………………………………………………………. 4
2.1系统主要传感器介绍…………………………………………………………………………. 4
2.1.1温度传感器……………………………………………………………………………… 4
2.1.2转速检测模块………………………………………………………………………….. 5
2.2系统总体功能及方案选择………………………………………………………………….. 6
2.2.1系统所需模块及功能……………………………………………………………….. 6
2.2.2主控制器选择………………………………………………………………………….. 8
第3章 系统总体硬件设计…………………………………………………………………………… 10
3.1单片机最小系统………………………………………………………………………………. 10
3.1.1ATmega16L单片机的引脚分布…………………………………………………. 10
3.1.2最小系统的硬件电路……………………………………………………………… 13
3.2电机驱动电路………………………………………………………………………………….. 14
3.3温度检测电路………………………………………………………………………………….. 15
3.4光电管提示电路和按键控制电路……………………………………………………… 15
3.5LCD1602显示电路…………………………………………………………………………….. 16
3.6电源电路…………………………………………………………………………………………. 17
3.7本章小节…………………………………………………………………………………………. 18
第4章 系统软件设计………………………………………………………………………………….. 19
4.1系统总体流程图………………………………………………………………………………. 19
4.2 PID算法简介………………………………………………………………………………….. 19
4.2.1PID算法介绍…………………………………………………………………………… 20
4.2.2PID算法结果…………………………………………………………………………… 21
4.3系统调试步骤………………………………………………………………………………….. 21
4.4误差分析即改进方法……………………………………………………………………….. 22
结论…………………………………………………………………………………………………………….. 23
致谢…………………………………………………………………………………………………………….. 24
参考文献……………………………………………………………………………………………………… 25
附录…………………………………………………………………………………………………………….. 26
附录I系统总体硬件电路图…………………………………………………………………… 26
附录II系统中部分程序…………………………………………………………………………. 27