摘 要本系统以 atmega16 为平台,主要由机械倒立装置与单片机自动控制组成,将装在摆杆的角度传感器 GY-61 得到的数据进行处理,利用摆杆倒立摆动过程中受力的分析和实验数据总结对摆杆板调节一定的角度,提高了倒立摆装置自动控制的稳定性。通过 PWM 技术动态控制电机的转速、方向和 PID 控制调节,实现装置设计的各种要求,达到了设计目的,完成了设计功能。关键词:角度传器;电动机;倒立摆;反馈;倒立控制;PID 控制Abstract The system taking ATmega16 as the platform, mainly composed of a mechanical device and microcomputer automatic control system, for processing will be installed in the GY-61 pendulum angle sensor data, summarize the pendulum plate adjusting certain angle by analysis and experiment data force pendulum inverted the oscillating process, improves the stability of inverted swing device for automatic control. By adjusting the speed, control the direction and PID dynamic PWM technology to control the motor, to achieve a variety of device design requirements, achieve the design purpose, completed the design function.Keywords:Angle sensor ; Motor ; Inverted pendulum ; inverted control; Feedback; PID control目 录1 方案论证 11.1 电机的选择.....................................................................................32 总体方案 33 电路设计 43.1 Atmega16 与其 AD 电路.................................................................43.2 部 PWM 发生模式............................................................................53.3 直流电机驱动电路...........................................................................73.4 PID 控制.........................................................................................84 软件设计 95 系统测试 96 误差分析与改进方法 107 小结 10参考文献 11附录一:元件明细表............................................................................11附录二:仪器设备清单........................................