基于FPGA的電機測速顯示設計_第1頁
基于FPGA的電機測速顯示設計_第2頁
基于FPGA的電機測速顯示設計_第3頁
基于FPGA的電機測速顯示設計_第4頁
基于FPGA的電機測速顯示設計_第5頁
已閱讀5頁,還剩23頁未讀 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

1、基于fpga的電機測速顯示設計摘要利用eda技術和vhdl語言,設計了基于fpga的電機測速顯示系統(tǒng),使系統(tǒng)能夠完成對電動機轉(zhuǎn)速參數(shù)和數(shù)據(jù)的采集,實時記錄、處理、分析、顯示、的功能,通過軟件設計省去了大量硬件電路設計,具有一定的電路設計集成化,經(jīng)實際應用證實,該系統(tǒng)運行穩(wěn)定、安全可靠、抗干擾能力強、操做靈活、使用方便。以往主要是用單片機來做為中央處理控制芯片,然后加入外圍電路,fpga的eda等器件及其對應描述語言的出現(xiàn)打破了單片機作為控制器的歷史,可以說fpga等器件及其對應描述語言是人類的創(chuàng)舉。關鍵詞:fpga; vhdl;電動機;傳感器;quartusabstract the use o

2、f eda technologies and vhdl language, design of fpga-based measurement of the electrical speed display system, enabling the system to speed completion of the motor parameters and data collection, real-time recording, processing, analysis, display, function, through the software design saved a lot of

3、 hardware circuit design, has some integrated circuit design, with the actual application confirmed that the system is running stable, safe and reliable, anti-interference ability, to do gymnastics flexible and easy to use. the past, mainly to do with single-chip microcomputer for control of central

4、 processing chips, and then adding the external circuit, fpga devices, such as the eda and its corresponding description of the emergence of language to break the single-chip microcomputer as the controller of history, it can be said of fpga devices description language corresponding to the creation

5、 of mankind.key words: fpga; vhdl; motor; sensor; quartus 1引言:在現(xiàn)代社會中,電資源成為人們生活當中不可缺少的一部分,電動機在電力系統(tǒng)中扮演著非常重要的角色。在很多場合,需要對電機轉(zhuǎn)速或頻率進行測量。目前,頻率測量的電路系統(tǒng)很多,這里介紹一種數(shù)字電路測頻:基于fpga的電機的轉(zhuǎn)速測量計。隨著電子技術的不斷發(fā)展和進步,以eda為代表的數(shù)字電路設計發(fā)生很大變化。在設計方法上,已經(jīng)從“電路設計硬件搭試焊接”的傳統(tǒng)設計方式到“功能設計軟件模擬下載調(diào)試”的電子自動化設計模式。在這種狀況下,以硬件描述語(hardware description

6、language)和邏輯綜合為基礎的自頂向下的電子設計方法得到迅速發(fā)展。 vhdl語言是目前應用最廣泛的硬件描述語言,它是在c語言的基礎上發(fā)展起來的,語法較為嚴謹、擁有廣泛的學習群體、資源比較豐富,且容易學簡單易懂。本文電動機轉(zhuǎn)速測量計的設計是在vhdl語言的基礎上展開的,源程序經(jīng)過altera 公司的quartus軟件完成了綜合、仿真(功能仿真和時序仿真),fpga(field programmable gate array,現(xiàn)場可編程門陣列) 選用的是cyclone系列的ep1c3t144c6器件。工作原理:在被測旋轉(zhuǎn)盤的邊緣上貼一片鋁箔為反光體,當反光體轉(zhuǎn)到光電傳感器的正前方時,電傳感器

7、發(fā)出的紅外光束被反射回來,同時被光傳感器上的紅外接收管接收,產(chǎn)生一個脈沖信號,們利用這個信號的邊沿觸發(fā)單片機內(nèi)部的高精度時器進行計時(精度可達 1 s),當反光體再轉(zhuǎn)到光電傳感器的正前方時,利用光反射信的邊沿停止單片機計時 這樣轉(zhuǎn)軸的旋轉(zhuǎn)周主要性能:測速范圍為 34000r/min,取樣為 0.1 0.5s,分辨率為 0.1 1 轉(zhuǎn),精度0.01prm,距離為 30 200mm特點:非接觸 數(shù)碼顯示 工作穩(wěn)定 測速準確反射式光電傳感器和整形電路由反射式紅外光電傳感器 三極管 9012 和帶施密特觸發(fā)器的非門74ls14 組成,如圖3 所示 工作原理是:接通 5v電源后,紅外發(fā)光二極管發(fā)出的紅外

8、光束遇到貼在旋轉(zhuǎn)盤上的反光體時,反射回來的光束被紅外光敏三極管接收并轉(zhuǎn)換為電信號,該信號經(jīng)三極管 bg 放大,再經(jīng) 74ls14 整形及反相后,輸出與輸入相同周期的矩形波,作為旋轉(zhuǎn)軸的轉(zhuǎn)速計數(shù)信號 工作波形如圖4 所示圖 轉(zhuǎn)速表外形反射式光電傳感器和整形電路整形波形示意圖2轉(zhuǎn)速測量電路21轉(zhuǎn)速測量的總體電路在電動機轉(zhuǎn)軸上套一帶洞的紙做圓盤,用光電傳感器使洞與傳感器處于同一條水平線上,每當電機轉(zhuǎn)動一周光電傳感器及其整理電路都會輸出一脈沖cp,cp的輸出信號與fpga的sm接口進行相連接收信號。fpga數(shù)字系統(tǒng)對輸入的脈沖個數(shù)進行計數(shù),得到信號的在一分鐘內(nèi)頻率數(shù),即一分鐘內(nèi)的轉(zhuǎn)速,該頻率數(shù)經(jīng)數(shù)碼管

9、顯示。從系統(tǒng)總體框圖來看,cp電路帶有光電耦合器,fpga數(shù)字系統(tǒng)與輸入通道隔離,因而大大提高了系統(tǒng)硬件的抗干擾能力。2.2轉(zhuǎn)速測量的基本原理轉(zhuǎn)速測量的原理是計算每分鐘待測信號的脈沖個數(shù),也就是利用標準的1hz (周期為1s) 脈寬信號在60個單位內(nèi)對輸入的待測信號的脈沖進行計數(shù),60秒計數(shù)結束后對采集到脈沖個數(shù)送到數(shù)碼管顯示。本文設計的數(shù)字轉(zhuǎn)速計有六個模塊組成:轉(zhuǎn)速控制模塊,計數(shù)模塊(十進制和三十進制),7段顯示譯碼器模塊,分頻器模塊(1hz與30.5hz分頻),寄存器模塊,掃描模塊2.系統(tǒng)的組成結構及工作原理: 本系統(tǒng)由光電傳感器及其調(diào)理電路、數(shù)碼顯示電路、fpga控制模塊組成。其中fpg

10、a控制模塊是本系統(tǒng)的核心。設計思路:11hz的時鐘信號與計數(shù)為30的計數(shù)器共同產(chǎn)生周期為一分鐘的時鐘信號與控制器的clk相連。具有定時的作用,同時產(chǎn)生脈沖進行觸發(fā),在這里兩個基本電路保證了在分鐘為單位時間內(nèi)電機的轉(zhuǎn)速測量。-1hz分頻器與30計數(shù)器組成60s定時期,即半周期為三十秒的時鐘脈沖library ieee; -4mhz use ieee.std_logic_1164.all;-已調(diào)試entity count isport(reset,ena,clk:in std_logic;clkout:out std_logic);end entity;architecture art of co

11、unt issignal q:std_logic_vector(21 downto 0);beginprocess(clk,ena,reset)beginif reset=1 then q=000000000000000000000;elsif ena=1 thenif clkevent and clk=1 -上升沿觸發(fā)then q=q+1;end if;end if;end process;clkout=q(21);-將21位的值送給輸出口end architecture;-30進制計數(shù)器如下圖所示,當計夠三十個數(shù)時,輸出反轉(zhuǎn),從而產(chǎn)生相應的周期脈沖。library ieee; use ie

12、ee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity jsq isport(reset,clk,ena:in std_logic;clkin:out std_logic);end jsq;architecture art of jsq issignal temp:integer range 0 to 30;signal q:std_logic;beginprocess(clk)beginif reset=1 then temp=0;elsif ena=1 then if

13、 temp=30 then temp=0;-計夠30翻轉(zhuǎn)q=not q;elsif clkevent and clk=1 thentemp=temp+1;end if;end if;end process;clkin=q;end architecture;2.轉(zhuǎn)速控制器做為fpga的控制單元,reset是復位控制信號,start是開始測量信號;三輸入兩輸出,clk做為接收周期為60s的脈沖信號,當未滿一個周期時gate為1,允許10進制計數(shù)器計數(shù),endmeasure清零當滿一個周期時gate清零endmeasure置1,禁止計數(shù),計數(shù)器復位,為下一次計數(shù)做好準備.其波形仿真及生成的器件如下圖

14、所示-轉(zhuǎn)速控制器library ieee;-已調(diào)試use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity control isport(reset,start,clk:in std_logic;endmeasure,gate:out std_logic);end control;architecture art of control issignal q:integer range 0 to 1;beginprocess(clk,reset,start)beg

15、inif reset=1 then gate=0;-不允許計數(shù)endmeasure=0;-計數(shù)器復位elsif start=1 then if clkevent and clk=1 thenif q=1 then gate=0;-達到一分鐘不允許再計數(shù)q=0;endmeasure=1; -計數(shù)器復位else gate=1;q=q+1;endmeasure=0;-計數(shù)器不復位end if;end if;end if;end process;end architecture;3.十進制計數(shù)器三輸入兩輸出,其中clr與endmeasure相連ena與gate相連,第一個sm傳感器信號與產(chǎn)生的cp脈沖

16、信號相連,第一、二、三carryout與sm相連,第四carryout置空,顯示信號xs分別與下一單元寄存器d相連,clr為零,ena為1,sm接到上升沿脈沖時計數(shù)-十進制計時器library ieee;-已調(diào)試use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity cnt10 isport(clr,ena,sm:in std_logic;carryout:out std_logic;xs:out std_logic_vector(0 to 3);end cn

17、t10;architecture art of cnt10 issignal temp:std_logic_vector(0 to 3);beginc1:process(clr,sm,ena)beginif clr=1 then temp=0000;-計數(shù)器清零elsif ena=1 then -計數(shù)使能if sm=1then-開始計數(shù)if temp=1001then temp=0000;-達到9清零else temp=temp+1;end if;end if;end if;end process c1;c2:process(temp)-temp做為觸發(fā)信號beginif temp=0000t

18、hen carryout=1;-向高位進位end if;end process c2;xs=temp;end art;4.四位寄存器兩輸入三輸出,當60s時間到時,四位寄存器ena使能,將寄存器中的數(shù)據(jù)輸出,其中ena與endmeasure相連,作用為將數(shù)據(jù)存儲。-四位寄存器生成的器件如圖所示library ieee;-已調(diào)試 use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity shortage4 isport(ena:in std_logic;-接end

19、measure,當為1時允許輸出d:in std_logic_vector(0 to 7);q:out std_logic_vector(0 to 7);end entity shortage4;architecture art of shortage4 issignal temp: std_logic_vector(0 to 7);beginprocess(ena)beginif ena=1 thentemp=d;end if;end process;qtemptemptemptemptemptemptemptemptemptemptemp=0000000;-當為其它時置0end case;

20、end process;bout724 hz)library ieee; -已調(diào)試 use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity div_17 is port(clk,ena,clr:in std_logic;div_out:out std_logic);end entity div_17;architecture result of div_17 issignal q:std_logic_vector(0 to 16);beginprocess(c

21、lk,ena,clr)beginif clr=1 then q=00000000000000000;elsif clkevent and clk=1 thenif ena=1 then if q=11111111111111111then q=00000000000000000;else q=q+1;end if;end if;end if;end process;div_out=q(16);-將第17位送給輸出產(chǎn)生分頻end architecture result;5. 3至8掃描器,只用到其中的四位,掃描器接的是led的位碼,依次送入數(shù)據(jù),從高位到低位依次掃描,使led數(shù)碼管依次點亮掃描頻

22、率大于24hz,生成器件如下圖。-掃描電路library ieee;-已調(diào)試 use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity decoder isport(clk:in std_logic;y:out std_logic_vector(0 to 7); end decoder;architecture art2 of decoder issignal a:std_logic_vector(2 downto 0);beginprocess(clk)beg

23、inif clkevent and clk=1 then if a=011 then a=000;else a=a+1;end if;end if;end process;with a select yclkout);u2:jsq port map(s1=clk,reset,ena,s14=clkin); u3:control port map(reset,ena,s14=clk,s16,s15);u4:cnt10 port map(s16,s15,cp,s2,s5);u5:cnt10 port map(s16,s15,s2=sm,s3,s6);u6:cnt10 port map(s16,s15,s3=sm,s4,s7);u7:cnt10 port map(s16,s15,s4=sm,1,s8);u8: shortage4 port map(s16,s5,s9);u9: shortage4 port map(s16,s6,s10);u10: shortage4 port map(s16,s7,s11);u11: shortage4 port map(s16,s8,s12);u12:ymq port map(s9,y1);u13:ymq

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論