原创 低频数字相位测量仪设计(原创)

2010-3-13 14:57 1370 3 3 分类: 模拟

<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />本文为本人电子设计竞赛的作品,由于图片较多,请下载阅读,给您代来不便.


                                                                    rar


低频数字相位测量仪


 


摘要


该低频数字相位测量仪以SPCE<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />061A最小系统为控制核心,由移相网络,相位测试仪,数字移相信号发生器,键盘/显示等功能模块组成。其中移相网络由阻容网络构成。相位测试仪对移相信号进行处理后进入单片机,由单片机计算显示相位差。数字移相信号发生器由单片机控制实现,通过键盘/显示模块实现参数预置以及数据显示,。本硬件电路用了EDA工具,软件设计采用模块化的编程方法。经过分析实测,该测量仪能够测量的正弦信号的频率范围为20Hz20kHz,,峰~峰值可以分 1v5v范围内变化,而且输入阻抗大于100k。并且可以测量频率,直接数字显示出来,达到了一些基本要求。移相网络输入信号频率范围达到20Hz20k,连续移相范围达到了-4545,输出的正弦信号峰~峰值可以分别在15v范围内变化,实现了题目要求。


关键词:移相    单片机   


方案比较与论证


方案一:将被测量输入信号通过模拟鉴相器鉴相,将模拟鉴相器的输出电压进行A/D转换,由单片机处理后显示数据。


 





鉴相器




单片机




低通滤波 /


A/D转换

 



                                                                                    


 


方案二:将被测量信号输入波形经比较器整形后,利用门电路鉴相,在通过RC电路积分后进行A/D转换。根据相位差与电平成正比的关系,由单片机经过查表或简单的计算处理后得到相位差值。


方案三:鉴相部分与方案二相同。将整形出来的两路数字信号相与后,形成新的数字信号,用单片机测量出其波形宽度,经过简单的换算后,即可以得出要测量的相位差值。


经过比较,方案一中被测信号的输出电压幅值变化比较大,难以满足鉴相器的输入要求。方案二中,积分电路输出波动会很大,相位精度不能保证。方案三的相位精度受频率影响小,容易控制,稳定性高,可以实现较高的精度,因此采用此方案。其系统框图如下:





    




    




      


   SPCE061




  




  




位差


 


  




  


 


  


 


 


 


 


 




Ui

 


 



            


 


 




 


 


 


 


 


基本测量原理与方案实现


1.基本测量原理


所谓移相是指两种同频的信号,以其中的一路为参考,另一路相对于该参考作超前或滞后的移动,即称为是相位的移动。两路信号的相位不同,便存在相位差,简称相差。若我们将一个信号周期看作是360,则相差的范围就在360°两个同频信号之间的移相,是电子行业继电保护领域中模拟、分析事故的一个重要手段,利用移相原理可以制作校验各种有关相位的仪器仪表、继电保护装置的信号源。因此,移相技术有着广泛的实用价值。我们知道,将参考信号整形为方波信号,并以此信号为基准,延时产生另一个同频的方波信号,再通过波形变换电路将方波信号还原成正弦波信号。以延时的长短来决定两信号间的相位值。这种处理方式的实质是将延时的时间映射为信号间的相位值。也就是说,只要能够测量出该延迟时间,我们就可以推算出其相位差值。


2.方案实现



      
本系统由移相网络,相位测量仪,数字移相信号发生器组成。其中相位测量仪由单限


(过零)比较器,逻辑门电路,单片机系统组成。数字式移相信号发生器由单片机软件编程实现,频率可调并可以步进。移相网络由相位超前,滞后网络及放大电路组成。键盘电路与显示电路用来预置初始状态与显示结果。


1)移相网络:                                                                                           


具体电路图如图1。在该电路中相角和电压幅值均可以改变。本电路中第一部分是由741RC网络所构成的超前移相电路和滞后移相电路,第二部分为TL072运算放大器构成的低噪声高增益放大电路。调节RRR4可以改变输出电压幅度,R3为调零相位电。


超前,滞后网络的相关理论:(如下图)



对于超前网络:


           



关于滞后网络:



  根据题目要求,不同情况下具体的参数由上述公式计算。


注意:具体调试电路的时候应根据以上公式,当输入频率改变的时候,应改变超前,滞后网络中RC参数,此时才可以改变相位差。


2相位测量电路  其框图如下





过零


 





数字 逻辑电路




  


 


 


 


 


 



体电路如图2


    将两同频信号移相信号经过过零比较器后整形为方波信号AB。为了能够更加精确地测量相位差,我们将信号AB相与,AB取反后再相与。(如下图所示)输出波形经单片机记数测量出其波形宽度,即可以计算出周期及相位差。


                


 


假设单片机时钟周期为f1,周期    T1=1/f1,   输入信号频率为     f2T2=1/f2


 一个周期对应360度,所以单位时间对应的相位值为T2/360.


如果单片机检测到的波形脉冲宽度为T,则对应的相位差值为:    T*T2/360


T的确定,由单片机产生高频率的时钟信号,,对输入信号进行扫描,即与输入信号进行逻辑与运算。 输入信号为低电平时,没有时钟脉冲输出;为高电平时输出时钟信号,对其进行记数,假设为N,就可以计算出脉宽,为  N*T1 ,即   T=N*T1 


 


从上面的的波形图可以看出,对 AB 信输出信号的脉宽并不是AB信号的相位差值,而是与相位差相加起来为半个周期(T1/2)的值,因此,由此信号计算出AB的相位差为      T1/2T*T2/360


  AB  的输出信号检测的脉宽,则是AB信号相位差的直接反应,此时相位差值为   T*T2/360


为什么要分开两种测量方法呢?这主要是考虑到减少误差的问题。当AB信号相位差值很小的时候,测量 AB 输出信号的误差大,不适宜直接测量,此时应测量 AB 后的信号。当AB相位差很大时,此时测  AB 的输出信号误差比较小,不适宜测量


AB 的信号。


 


3)数字移相信号发生器


此部分电路完全由单片机编程来控制实现。其具体过程如下:将正弦波信号数字化成,并形一张数据表存入ROM芯片中,此后在单片机的控制下连续地循环输出该数据表,就可获得两路正弦波信号,当数据序列完全相同时,则转换所得到的两路正弦波信号无相位差,称为同相。当数据序列不同时,则转换所得到的两路正弦波信号就存在着相位差。相位差的值与数据表中数据的总个数及数据地址的偏移量有关。这种处理方式的实质是将数据地址的偏移量映射为信号间的相位值。正弦信号数据表见程序。                        数据表


 


4显示电路    采用串行数据输入,本系统采用六位数码管显示。 F


                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           


显示部分应用软件技术,仅使用三根线,即数据线.时钟线及控制线,通过对单片机串口的编程,实现了数码显示与单片机之间的串行接口技术,外部硬件使用六片4094和六个LED实现六位数据显示,还可以继续扩展。


三线串行显示原理:三线为SDAIOB1)—— 串行输入数据线,CLKIOB0)——移位时钟线,STRIOB6)——输入控制线。


STR为高电平时,SDA串行移位输入六组数据,一组包括八个元素来控制一个LED的八段发光管,从而实现了六组数据对六个LED的控制。数据传输完毕,STR为低电平,SDA停止传输,此时为显示模式,六个LED显示传输进来的六组数据。


 


 


 


 


 


5)键盘功能    本系统采用4*4键盘并行输入,每个按键的功能由单片机编程定义


                                  


6)单片机系统   采用凌阳16位单片机SPCE061 061系统,为整个硬件系统的核心。它既协调整机工作,又是数据处理器。它硬件电路包括有:


核心芯片SPCE061A,音频电路(含MIC输入部分和DAC音频输出部分),电源电路,


接口电路,复位电路等。电路简单,功能强大,而且体积小,采用电池供电。


 


电路图如图3


7)直流电源部分  将市电降压整流后再加以稳压,获得稳定的12V5V直流电供使用,分别有两路输出。电路原理图如下:(  7812换成7805输出即为DC5V  )


    


 



 


系统的软件部分


           编程流程图如下:


 





关中断




检到下降沿

 


 






初始化




关中断

          





第一路上升沿


 


 


 


 


 


 


上升沿




开定时器




检到N个上升沿




关中断




时间 频率




继续检测上升沿




开中断




计算时间




I路上升沿




开中断




检下降沿




关中断




   




显示

 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 



 程序见最后。


 


 


系统测试及结果


1.  调试方法和过程  采用先分别调试各个单元模块,调通后再进行整机调试的方法,提高调试效率。各个单元均调通后,进行整机调试。调试成功后再将程序写入单片机中进行调试。调试结果显示,整个系统能够工作。


2.  测试仪器  函数发生器(INSTEK FUNCTION GENERATOOR


万用表(M9803 TRUE RMS MUL TIMETER


 


毫伏表(YB2172 MILIVOL TIMETER


示波器(OSCILLOSOPE GOS-620 20M


相位检测仪TDS3012B


3.  测试数据


(1)    移相网络的测量


移相测量结果:Vi=5v;f0=10k;c1=c2=103;



 


相位差⊿


R1=10k;R2=0K10K


500


R2=10K;R1=10K0


0-90


             Vi=5v;  f=1k;   c1=c2=104



R1=10k, R2=0K10K


500


R2=10K,R1=10K0


0-90


Vi=5v;  f=100Hz;  c1=c2=1u



R1=10K;R2=010K


500


R2=10K;R1=010K


0-90


        幅度测量结果:vi=5v; c1=c2=103; f0=10k



 


幅度变化⊿


Rr=10k0k;


5v0


R4=10k0


7v0


                      Vi=5v;c1=c2=1u;  f0=1k



Rr=10k0k


5.6v0


R4=10k0


7.2v0


                       Vi=5v;c1=c2=1u; f0=100Hz



Rr=10k0k


6v0


R4=10k0k


7.6v0


扩展:对于超前,滞后网络,当参数vi=5v


A     c1=c2=105, 保证相位差在-9050变化时候,频率可以在


20 Hz500 Hz之间变化,而不仅仅为100Hz


B    同理,当  c1=c2=104, 保证相位差在-7550变化时候,频率可以在


500 Hz5k Hz之间变化,而不仅仅为1k


C    同理,当  c1=c2=153103, 保证相位差在-5550变化时候,频率可以


 


5kHz13k Hz之间变化,而不仅仅为10k


 


 以上的参数都是经过上面的理论公式计算出来的,相位差.幅度是用相位检测仪


TDS3012B测量出来的数据。


(2)    相位差测量


各个模块单独调试时均能够正常工作,但级连起来时候测试误差较大,不能很好的进行测量。


 


  测试误差及分析


1.理论分析误差        用时钟信号扫描输入信号时,当时钟信号为高电平时,刚好处于输入信号的上升沿或下降沿,,此时输出电平不知道是低电平还是高电平,就会丢失记数脉冲的个数。做最坏的情况分析,即上升沿和下降沿的脉冲都丢失,损失了二个记数值记数,此时即为最大的误差值。


根据方案实现中的定义,可以计算出对应的最大相位差误差


值。        =2*T1*T2/360


此误差不能消除。


 

PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
3
关闭 站长推荐上一条 /3 下一条