电子科技大学成都学院本科毕业设计论文
P2=0x77; //较快;输出3V/60hz else if(temp>=28&temp<=29) P2=0x8b; //3.5V/70HZ else if(temp>=30&temp<=31)
P2=0x9e; //快;输出4V/80HZ else if(temp>=32&temp<=33)
P2=0xb2; //4.5V/90HZ else if(temp>=34&temp<=35)
P2=0xc5; //最快;输出5V/100HZ else if(temp>=36&temp<=40) P2=0xff;
//由于反馈电压不同所以输出P2=0xc5与0xff电压近似相同; } }
void init_ds18b20(void) {
uint n; DQ=1; delay(8); DQ=0;
delay(80); DQ=1; delay(8); n=DQ; delay(4); }
void write_byte(uchar dat) {
uchar i;
for(i=0;i<8;i++) {
DQ=0;
DQ=dat&0x01; delay(4); DQ=1;
dat=dat>>1; }
delay(4); }
uchar read_byte(void) {
40
附录
uchar i,value; for(i=0;i<8;i++) {
DQ=0;
value=value>>1; DQ=1; if(DQ)
value=value|0x80; delay(4); }
return value; }
uchar readtemperature(void) {
uint a,b;
init_ds18b20();
write_byte(0xcc);//跳过ROM; write_byte(0x44);//启动温度测量; delay(300);
init_ds18b20(); write_byte(0xcc);
write_byte(0xbe);//读DS1820温度暂存器命令写数据; a=read_byte(); b=read_byte(); b<<=4;
b+=(a&0xf0)>>4;
return b;//整数2^7~2^0; }
41
电子科技大学成都学院本科毕业设计论文
外文资料原文
The chapter mainly introduces the principle of PowerSmartTM
Variable
Frequency Speed-Regulating Device
Rated voltage of the inverter 6KV basic principles of :
Drive to 6KV example, discusses: 6KV inverter output voltage, each phase has six power units connected in series. Phase input voltage unit 600V, the output is single-phase 577V, the unit can be superimposed on each other in series with the output voltage of 3464V. When the inverter output frequency is 50HZ, the phase voltage is 13 ladder wave, as shown below. FIG UA1 ... UA6 6 respectively a power unit with an output voltage of the A -phase superposition of the inverter output voltage UA0. The figure shows a PWM control signal is generated using the phase A voltage reference UAr, a good approximation can be seen UA0 UAr. UAF for the A-phase output voltage of the fundamental component.
Since the midpoint of the inverter and the motor neutral point is not connected, the inverter output is actually as line voltage, the A -phase and B -phase output voltage generated UAB output line voltage up to 6000V, 25 staircase. As shown below, the output of the step waveform of the phase voltage and the line voltage, UAB not only the number of steps and having a sinusoidal waveform is multiplied, and thus the harmonic component and the dV/dt are small.
The three-phase inverter output voltage to the motor, the motor generates a current rotation of the motor's rated operating voltage and current as shown below, it is the result of a small amount of the measured waveform after the RC filter can be seen as the output voltage harmonic wave is small, the motor current is also very close to a sine wave .
42
外文资料原文
Due to the multiple overlay approach, the harmonic content of the inverter output voltage is very small, conventional supply voltage has reached the permissible harmonic content, does not cause additional harmonic motor heating. The output voltage dV/dt is small, does not significantly increase the stress to the motor, it can supply to the general standard AC motors, and does not require derating, especially for old equipment . Since the output voltage harmonics and dV/dt is very small, no additional output filter output cable can be very long. Since the harmonic small additional torque ripple is small, thus avoiding the mechanical resonance caused by transmission and bearing wear are greatly reduced.
In the input side , due to the displacement of the drive even multiple secondary windings , such as total output 6KV +250 , +150 , +50 , -50 , -150 , -250 total of six kinds of winding , the primary current drive the corresponding current components are mutually uniform displacement , constitute the equivalent 36 pulse rectifier circuit , inverter results in greatly reduced input current harmonic content , well below the limits specified in the standard , even in the smaller capacity power grid when they can meet harmonic requirements . Inverter power factor up to 0.95 hours of work to meet the requirements of the power supply system. Will not run on the same power line interference occurs when electrical equipment so no additional power supply filters or power factor compensation device , it will not resonate drive to work with an existing compensation capacitor device, which was hailed as \no high-voltage inverter harmonics . \
The basic principle of the control unit:
Two optical fibers are used to connect and control between the control unit and each power unit. It can receive operation from the operation panel, I / O interface or communication channel commands and given signal, post-processing the output voltage, frequency reference signal to the three-phase control unit, where it is converted into a PWM control signal, the electrical/optical conversion convert an optical signal sent from the optical transmitter to the power unit port . Response information via the optical/electrical converter from the power unit into an electrical signal to the main controller centralized evacuation process. According to the host controller control commands, and operating information given signal, the response operation control
43
电子科技大学成都学院本科毕业设计论文
information , state analysis , fault diagnosis , such as computing , fault after fault according to the nature of the fault processing, such as blocking system, high pressure trip, etc., and gives corresponding fault signal, the audio signal is also provided a fault. From the I/O interface can output running state (switch) and operating parameters (analog), the user may need to select output. Debugging interfaces with a PC via the PC running the debugger, you can debug and diagnostics in picture form , and at the same time waveform display and digital systems in five variables, the system debugging and diagnostics on the CPU unit good tools. The CPU unit is also equipped with a communication interface (RS232), communication can take control commands and reference signals to control the operation of the drive from the PC , and returns information about the operating status and operating parameters for centralized monitoring.
Master controller function block diagram shown above , the structure of the main controller for modular units , which is double the DSP CPU core unit via the bus interface board and phased A, B, C plate exchange information . From the interface submodule DI, AI acceptable command, a given signal, the motor current and voltage. CPU board according to the operation command given signal and other input signals, calculates the control information and status information. Phased A, B, C receive the control information from the CPU board plate, to generate a PWM control signal, the electric / optical converter , transmits the optical signal to the power control unit . The response signal from the power unit into an electrical signal in the phase control A, B, C plate , the evacuation process to CPU board handling . Status information can be sent via the interface board and interface sub- templates.
Operation panel, also as people -machine interface , a color touch-screen mode and digital mode two optional configurations. Operator panel control unit mounted on the cabinet front door, but there are lights on the doors and buttons. Operator panel with master controller via the communication interface with the CPU board is connected, you can enter commands for a given signal, the display operating status and operating parameters. You can display fault information, including by failure time has carried all before eight faults and failures are not sorted in the order of failure. CPU board has to communicate with the host computer communication interface, a standard RS232
44
摘 要
电子科技大学成都学院
毕 业 设 计 论 文
论文题目 单相变频电源
学生姓名 余 健 学 号 1040830231 专 业 电气工程及其自动化 系(分院) 电子工程系 指导教师 蒋世奇
I
ABSTRACT
指导单位 电子科技大学成都学院
摘 要
随着科技和现代工业的发展,变频电源在当今社会的发展起着非比寻常的作用。由于世界各国电网指标不统一,出口电器厂商需要电源模拟不同国家的电网状况,为工程师在设计开发、生产线测试及品保的产品检测、寿命、过高压/低压模拟测试等应用中提供纯净可靠的、低谐波失真、高稳定的频率和稳压率的正弦波电力输出;进口原装电器、设备的用户也需要对我国电网进行变压、变频以保证进口电器、设备的正常运转;满足航空电子及军事设备高频的需求。
本篇论文设计的变频电源属于单相正弦波交流电源(AC-DC-AC)。此次电源系统设计包括主电路、控制电路和保护电路。论文首先介绍了变频电源的发展情况;然后阐述了变频电源的工作原理;接着介绍电源系统(EG8010)方案的确定;紧接着详细介绍了系统电路设计,包括变频控制电路、保护电路以及驱动电路;其中变频控制电路采用了芯片EG8010线性可调电路;最后介绍了AT89C51单片机辅助系统的软件和硬件设计,包括设计的具体过程和调试结果,并给出了系统原理图和程序清单。
关键词:变频电源,EG8010,MOSFET,单相正弦波交流电源,逆变控制电路
II
ABSTRACT
ABSTRACT
With the development of modern industry, science and technology, variable frequency power supply in today's society plays an unusual role. Due to the grid index is not uniform around the world, export electronics makers need power simulation grid conditions, in different countries for engineers in design, development, production line testing and quality assurance of product testing, life span, high voltage/low voltage simulation test applications provide clean and reliable, low harmonic distortion, high stable frequency and voltage regulation rate of sine wave power output. Import original electrical appliances, equipment users also need to the power grid variable voltage and frequency to ensure the normal operation of imported equipment in China so as to meet the needs of avionics and high frequency of military equipment.
This paper design frequency conversion power belongs to the single-phase sine wave AC power (AC-DC-AC). The power supply system design including main circuit, control circuit and protection circuit. The development of variable frequency power supply is firstly introduced in the paper. Then the working principle of frequency conversion power is expounded on. The scheme of power supply system (EG8010) is applied in the development. And the system circuit design, including the frequency conversion control circuit, protection circuit and driver circuit are completed. Linear adjustable circuit of The EG8010 chip is adopted to control the frequency conversion. Finally, the software and hardware of introduced the AT89C51MCU auxiliary system are designed, including the specific process of the design and debug results, and the system schematic diagram and the program listing is given.
Key Words: Variable frequency power supply, EG8010, MOSFET, Single-phase sinusoidal ac power supply, inverter control circuit
II
目录
目 录
第1章 概论 ........................................................ 1 1.1 电源的基本概念 .................................................. 1 1.2 变频电源与变频器的区别 .......................................... 1 1.3 变频电源的分类 .................................................. 1 1.4 变频电源的应用 .................................................. 2 1.5 变频电源的发展趋势 .............................................. 3 第2章 变频电源的理论基础 .......................................... 5 2.1 变频电源的基本原理 .............................................. 5 2.2 变频电源的拓扑结构 .............................................. 5 2.3 逆变电源介绍 .................................................... 7 第3章 变频电源系统方案设计 ....................................... 10 3.1 系统方案选择 ................................................... 10 3.2 逆变专用芯片选择方案 ........................................... 10 3.2.1 EG8010芯片的描述 ............................................. 11 3.2.2 EG8010的特点与应用领域 ....................................... 12 3.2.3 EG8010的变频模式 ............................................. 13 3.3 变频电源中逆变电路的方案 ....................................... 14 第4章 系统变频电路设计 ........................................... 17 4.1 整流滤波电路设计 ............................................... 18 4.2 控制模块设计 ................................................... 19 4.3 驱动模块设计 ................................................... 21 4.4 功率主板模块 ................................................... 22 4.5 保护模块设计 ................................................... 25 4.5.1 电流保护 ..................................................... 25 4.5.2 电压保护 ..................................................... 26 4.5.3 温度保护 ..................................................... 28 第5章 微机控制系统设计 ........................................... 30 5.1 硬件设计 ....................................................... 30
III
第5章 微机控制系统设计
当温度在26~27℃时,输出3V/60HZ; 当温度在28~29℃时,输出3.5V/70HZ; 当温度在30~31℃时,输出4V/80HZ; 当温度在32~33℃时,输出4.5V/90HZ; 当温度在34~35℃时,输出5V/100HZ。 微机控制仿真结果验证: 系统仿真结果如图5-5所示。
图5-5 系统仿真结果图
当单片机检测到DS18B20温度为25度时输出电压为2.51V,输出频率为50HZ。
变频电源波形输出如图5-6所示。
35
电子科技大学成都学院本科毕业设计论文
图5-6 变频电源输出波形
通过验证,以上理论基本得以实现,当微机系统正常工作时,能够自动实施反馈到变频控制系统当中。当微机系统反馈电压为2.5V时,变频电源输出频率为50HZ,基本符合电源设计的规律。但在实际生产中变频电源的变频范围一般在40~400HZ,故本设计中的最小20HZ在实际应用中可以略加修改,使得更加符合客观规律。
36
致谢
致谢
首先我要感谢学校给予我的培养,让我能够顺利完成我的学业以及我的毕业论文。本研究及学位论文是在我的导师蒋世奇老师的亲切关怀和悉心指导下完成的。他严肃的科学态度,严谨的治学精神,精益求精的工作作风,深深地感染和激励着我。从课题的选择到项目的最终完成,蒋老师都始终给予我细心的指导和不懈的支持。数月时间以来,蒋老师不仅在学业上给我以精心指导,同时还在思想、生活上给我以无微不至的关怀,在此谨向蒋老师致以诚挚的谢意和崇高的敬意。
在此,我还要感谢在一起度过愉快的大学生活的同学们,正是由于你们的帮助和支持,我才能克服一个一个的困难和疑惑,直至本文的顺利完成。特别感谢我的好友黄威,他对本课题做了不少工作,给予我不少的帮助。
在论文即将完成之际,我的心情无法平静,从开始进入课题到论文的顺利完成,有多少可敬的师长、同学、朋友给了我无言的帮助,在这里请接受我诚挚的谢意!
37
电子科技大学成都学院本科毕业设计论文
参考文献
[1]沈显庆.开关电源原理与设计.东南大学出版社,2012-12-1 [2]张庆达.变频电源装置及应用手册.中国电力出版社,2009-7-1 [3]王廷才.变频器原理及应用(第2版).机械工业出版社,2011-6-1 [4]徐海,施利春.变频器原理及应用.清华大学出版社,2010-9-1 [5]肖朋生.变频器及其控制技术.机械工业出版社,2008-3-1 [6]高凤友.无源逆变电源的原理与应用.化学工业出版社,2011-11-1 [7]王兆安.电力电子技术.机械工业出版社,2009-5
[8]纯正弦波逆变器专用芯片.EG8010 SPWM芯片数据手册V2.1.2010-11-15 [9]TOSHIBA.TLP250功率驱动模块数据手册,2004-06-25
[10]普利斯曼,莫瑞.开关电源设计(第三版).电子工业出版社,2010-6-1 [11]布朗.开关电源设计指南(第2版).机械工业出版社,2004-5-1 [12]周志敏,周纪海,纪爱华.逆变电源实用技术.中国电力出版社,2005-3-1
38
附录
附录
附录一:软件代码
#include
void init_ds18b20(void); void write_byte(uchar dat); uchar read_byte(void);
uchar readtemperature(void); void delay(uint t) {
while(t--); }
/*主函数*/ void main() {
while(1) {
temp=readtemperature();
/*EG8010输出频率可在在0~100HZ变化,1HZ=5V/100hz;此次我们假设输出频率在20~100HZ*/
if(temp<10) //停机;输出0V/0HZ P2=0x00;
if(temp>=10&temp<=19)
P2=0x28; //慢速;输出1V/20HZ else if(temp>=20&temp<=21) P2=0x3b; //1.5V/30hz else if(temp>=22&temp<=23)
P2=0x4f; //中速;输出2V/40hz else if(temp>=24&temp<=25)
P2=0x63; //2.5V/50hz else if(temp>=26&temp<=27)
39
第4章 系统变频电路设计
4.5 保护模块设计
4.5.1 电流保护
1.电流保护的意义
很多电子设备都有个额定电流,不允许超过额定电流,不然会烧坏设备。所以有些设备就做了电流保护模块。当电流超过设定电流时候,设备自动断电,以保护设备。
过电流保护主要包括短路保护和过载保护两种类型。短路保护的特点是整定电流大、瞬时动作。电磁式电流脱扣器(或继电器)、熔断器常用作短路保护元件。过载保护的特点是整定电流较小、反时限动作。热继电器、延时型电磁式电流继电器常用作过载保护元件。
2.电流保护的设计
EG8010 芯片的引脚 IFB是测量逆变器输出负载电流,主要用于过流保护检测,电流采样反馈部分,该引脚内部的基准峰值电压设定为 0.5V 过流检测延时时间 600mS,当某种原因导致负载电流偏高超出逆变器的负载电流, EG8010 根据引脚PWMTYP的设置状态将输出 SPWMOUT1~SPWMOUT4到“0”或“1”电平,关闭所有功率 MOSFET 使输出电压到低电平,该功能是主要保护功率 MOSFET 和负载,一旦进入过流保护后,EG8010 将在 16S 后释放重新打开功率 MOSFET 管再判断负载过流情况,释放打开功率 MOS 管的持续时间为 100mS, 释放的 100mS 时间里再判断过流事件,如果仍存在过流事件,EG8010 再将关闭所有功率MOSFET使输出电压到低电平,重新等待16S的释放,如果释放后正常运行达到 1分钟以上EG8010 将清除过流事件次数,否则连续释放次数累计 5 次后仍存在未正常运行 EG8010 将彻底关断 SPWM模块的输出,需要系统重新上电后释放。
电流保护模块模块如图4-7所示。
25
电子科技大学成都学院本科毕业设计论文
图4-7 电路电流保护模块
通过采用电压比较器LM393比较分压电压和采样电阻得到的电压调节输出信号得以控制SPWMEN,或者控制SPWM输出信号高低得以保护此电路。
具体方法是:保护系统要求该装置负载电流超过2A时关闭SPWM输出,此时采样电阻R29(0.1欧姆)将采集到的电流转换为所获得电压0.2V,所以必须通过R12,R14所分压的接点电压也应该为0.2V,及Vr14=0.2V;所以经过公式Vr14=VCC/(R14+R12)*R14,取R12为10K,则R14就为417R。只有这样LM393比较器才能在输出负载电流大于2A时输出低电平控制SPWMEN,使其关闭SPWM输出,从而使得整个系统得以保护。
电流保护除了这里通过电压比较器外,EG8010 芯片的引脚 IFB是测量逆变器输出负载电流,主要用于过流保护检测,电流采样反馈部分,当某种原因导致负载电流偏高超出逆变器的负载电流, EG8010 根据引脚PWMTYP的设置状态将输出 SPWMOUT1~SPWMOUT4到“0”或“1”电平,关闭所有功率 MOSFET 使输出电压到低电平,该功能是主要保护功率 MOSFET 和负载。 4.5.2 电压保护
为防止过低或过高的输出电压供应到负载,EG8010内部设定了过压和欠压保护功能,使在设计过程中变得相对简单。下面对此次电压保护原理图做简要分析。
26
第4章 系统变频电路设计
电压保护模块如图4-8所示。
图4-8 电压保护模块
EG8010芯片的电压反馈处理是通过引脚VFB测量逆变器输出的交流电压,测量反馈的峰值电压和内部基准正弦波峰值电压 3V 进行误差计算,对输出电压值作出相应调整,当输出电压升高时,该引脚电压也随之升高,经内部电路误差值计算后调整幅度因子乘法器系数,实现降低输出电压达到稳压过程,反之,当该引脚的电压减低时,芯片会作出升高输出电压。
R16,R17,R19作为分压电阻,C25作为滤波电容使反馈输入电压平滑无谐波,通过调节可变电阻的大小可以通过芯片内部电路改变输出电压的幅值。 过压保护和欠压保护:
EG8010内部设定了过压和欠压保护功能,过压保护设定值3.15V延时时间为300mS,欠压保护设定值2.75V 延时时间为3S,当测量反馈的峰值电压大于3.15V或者小于2.75V时,EG8010 根据引脚(9)PWMTYP的设置状态将输出 SPWMOUT1~SPWMOUT4到“0”或“1”电平,关闭所有功率MOSFET使输出电压到低电平,一旦进入过压和欠压保护后,EG8010 将在8S后释放重新打开功率MOSFET管再判断输出电压情况,释放打开功率MOSFET管的持续时间为100mS,释放的100mS时间里再判断过压或欠压事件,如果仍存在过压或欠压事件,EG8010再将关闭所有功率MOSFET使输出电压到低电平,重新等待8S的释放,
27
电子科技大学成都学院本科毕业设计论文
如果释放后正常运行达到1 分钟以上EG8010 将清除过压或欠压事件次数,否则连续释放次数累计 5次后仍未正常运行EG8010将彻底关断 SPWM模块的输出,需要系统重新上电后释放。 4.5.3 温度保护
EG8010 芯片的引脚TFB是测量逆变器的工作温度,主要用于过温保护检测,电路结构如图,NTC 热敏电阻 RT1 和测量电阻 RF1 组成一个简单的分压电路,分压值随着温度值变化而变化数值,这个电压的大小将反映出 NTC 电阻的大小从而得到相应的温度值。
EG8010温度检查电路如图4-9所示[8]。
图4-9 EG8010温度检查电路
下面对此次设计的温度保护电路作如下分析,设计原理图如下。 温度保护电路如图4-10所示。
28
第4章 系统变频电路设计
图4-10 温度保护电路
首先是电源部分,VCC接+5V,VBT接12V铅蓄电池;FANCTR外接风扇控制引脚,TFB接热敏电阻和分压电阻R18以采集电压,电压的大小将反映出 NTC 电阻的大小从而得到相应的温度值。
NTC选用25℃对应阻值10K的热敏电阻,TFB引脚的过温电压设定在 4.3V,当发生过温保护时,EG8010根据引脚(9)PWMTYP的设置状态将输出 SPWMOUT1~SPWMOUT4到“0”或“1”电平,关闭所有功率 MOSFET 使输出电压到低电平,一旦进入过温保护后,EG8010 将重新判断工作温度,如果 TFB引脚的电压低于4.0V,EG8010将退出过温保护,逆变器正常工作。
FANCTR外接风扇控制引脚,当 TFB引脚检测到温度高于 45℃时,输出高电平“1”使风扇运行,运行后温度低于 40℃时,输出低电平“0”使风扇停止工作。
29
电子科技大学成都学院本科毕业设计论文
第5章 微机控制系统设计
微机控制系统中的主要目的是输出0~5V的电压以控制EG8010的16引脚的调频控制电路。输出的电压可通过温度变化自动输出不同的电压值,温度越高输出电压频率越高,通过不同的输出电压可调节EG8010的频率调节器,使之输出不同的频率。
5.1 硬件设计
微机控制系统主要包括单片机最小系统;温度传感器的设计;数模转换器设计。
下面是微机控制结构原理图和对各个部分做的简要分析。
微机控制结构如图5-1所示。
图5-1 微机控制结构图
5.1.1 单片机最小系统
单片机最小系统主要包括复位电路和晶体振荡器电路。单片机复位电路就好比电脑的重启部分,当电脑在使用中出现死机,按下重启按钮电脑内部的程序从头开始执行。单片机也一样,当单片机系统在运行中,受到环境干扰出现程序跑飞的时候,按下复位按钮内部的程序自动从头开始执行。
单片机最小系统晶振Y1也可以采用6MHz或者11.0592MHz,在正常工作的
30
第5章 微机控制系统设计
情况下可以采用更高频率的晶振,51单片机最小系统晶振的振荡频率直接影响单片机的处理速度,频率越大处理速度越快。
单片机最小系统如图5-2所示。
图5-2 单片机最小系统电路
5.1.2 温度传感器的设计
温度传感器选择DS18B20,其主要特性是适应电压范围更宽,电压范围:3.0~5.5V,在寄生电源方式下可由数据线供电。测量结果直接输出数字温度信号,以\一线总线\串行传送给CPU,同时可传送CRC校验码,具有极强的抗干扰纠错能力。DS18B20数字温度计提供9位(二进制)温度读数指示器件的温度信息,经过单线接口送 入DS18B20或从DS18B20送出。温度敏感器件DS18B20的测量范围从-55到+125增量值为0.5可在l s(典型值)内把温度变换成数字。下面是温度传感器的设计原理图和对温度传感器电路作的简要分析。
温度传感器电路如图5-3所示。
31
电子科技大学成都学院本科毕业设计论文
图5-3 温度传感器电路
温度传感器电路分析:
DS18B20共三个引脚,Vcc接+5V电源,GND接地,DQ接C51单片机的P0.0口。Protues仿真软件可仿真此芯片,按下图中的上下箭头即可改变其温度的大小。当温度发生变化时,单片机可以采集到此信息,通过设置不同温度的范围输出与之相对应的数字信号,就可以通过数模转换即可输出相应大小的电压(例如当温度为32度时,输出电压则为4.5V)以达到变频的效果。 5.1.3 数模转换器设计
此次数模转换器选择DAC0832,采样频率为8位的D/A转换芯片,1位可精确到19.5mV(5V/256)。此次电路选用直通方式,即WR1,WR2,XFER,CS均接地,ILE接高电平,此方式适用于连续反馈控制线路。
D/A转换结果采用电流形式输出,需输出相应的模拟电压,可通过一个高输入阻抗的线性运算放大器实现这个供功能。运放的反馈电阻可通过RFB端引用片内固有电阻,还可以外接。下面是电路设计的原理图和对原理图的简要分析。
数模转换器电路如图5-4所示。
32
第5章 微机控制系统设计
图5-4 数模转换器电路
数模转换器电路分析:
数模转换器的数据输入端D0~D7分别接单片机P20~P27口;WR1、WR2、XFER、CS均接地,ILE接高电平;当数据输入端D0~D7全部为“1”时,输出Iout1最大,当D0~D7全部为“0”时,Iout1为零;而P2口输出的数据,都是通过运算放大器应该输出的电压值而通过仿真测试得到的。
具体计算方法举例:假设温度传感器采集到温度为32度时,单片机控制引脚P2口输出数据0xb2;此时数模转换器输入数据换算成二进制10110010,换算成十进制数字为178,由于反馈电压为6.49V,电压精度=反馈电压/256=2.535mV,及输出电压可计算Vout=178*2.535mV=4.5V,而EG8010频率调节是与该频率调节引脚的电压成线性关系的,所以此时输出电压的频率应为90HZ。
5.2 软件设计
软件系统有以下几个部分组成:DS18B20的初始化、写数据到DS18B20、读数据、读温度、通过从DS18B20读到的数据自动控制P2口的数据输出。
首先是初始化。包括调用头文件#include
33
电子科技大学成都学院本科毕业设计论文
DS1820是否存在或损坏,可加声音告警提示DS1820故障。
然后是写数据到DS18B20。定义函数void write_byte(uchar dat)采用8位循环移位处理,先拉低总线,产生写信号;紧接着发送1位数据DQ=dat&0x01并产生延时;释放总线,等待总线恢复;准备下一位数据的传送。
从DS18B20读出数据。定义函数uchar read_byte(void)同样采用8位循环移位处理,先拉低总线,产生读信号;紧接着释放总线,准备读数据;if(DQ) value=value|0x80(从低位开始读);延时;返回读到的数据。
读温度。定义函数uchar readtemperature(void),首先是初始化DS18B20;跳过ROM写数据0xcc;启动温度测量写数据0x44;延时300us;初始化DS18B20;跳过ROM写数据0xcc;读DS1820温度暂存器命令写数据0xbe;然后读数据;最后采集温度。
通过从DS18B20读到的数据自动控制P2口的数据输出。当读到温度小于10度时,P2口输出0x00;当读到温度在10~19度时,P2口输出0x28;当读到温度在20~21度时,P2口输出0x3b;当读到温度在22~23度时,P2口输出0x4f;当读到温度在24~25度时,P2口输出0x63;当读到温度在26~27度时,P2口输出0x77;当读到温度在28~29度时,P2口输出0x8b;当读到温度在30~31度时,P2口输出0x9e;当读到温度在32~33度时,P2口输出0xb2;当读到温度在34~35度时,P2口输出0xc5。由于反馈电压不同所以输出P2=0xc5与0xff电压近似相同。
软件设计应用集成开发环境keil uvision 4,详细代码见附录1。
5.3 微机控制系统仿真与调试
运行状态分析如下:
当单机片检测传感器温度在9℃以下,停机不输出;
当温度在10~19℃时,输出1V/20HZ; 当温度在20~21℃时,输出1.5V/30HZ; 当温度在22~23℃时,输出2V/40HZ; 当温度在24~25℃时,输出2.5V/50HZ;
34
百度搜索“70edu”或“70教育网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,70教育网,提供经典综合文库单相变频电源设计_原版在线全文阅读。
相关推荐: