【正文】
電源VCC為+9V,H型驅(qū)動(dòng)電路中晶體管功率放大器6的發(fā)射極所加的電源為9V。 圖7 電機(jī)驅(qū)動(dòng)電路總電路圖: 總控制模塊用VHDL語言對(duì)FPGA編程實(shí)現(xiàn)。系統(tǒng)啟動(dòng)時(shí),首先運(yùn)行系統(tǒng)初始化程序,程序先轉(zhuǎn)到步進(jìn)電機(jī)控制模塊,送復(fù)位信號(hào)使步進(jìn)電機(jī)處于初始狀態(tài),再轉(zhuǎn)到伺服電機(jī)控制模塊,送復(fù)位信號(hào)使伺服電機(jī)處于初始狀態(tài)。其間主控程序不斷檢測(cè)按鍵,只要有鍵被按下則啟動(dòng)相應(yīng)的子模塊實(shí)現(xiàn)實(shí)時(shí)控制。 :控制模塊的程序流程圖如圖8所示。模塊一接收到按鍵信號(hào),則按鍵去抖部分先對(duì)按鍵信號(hào)進(jìn)行處理,得到穩(wěn)定的控制信號(hào);如果是變頻信號(hào)則變頻部分動(dòng)作,通過相位累加模型,改變步進(jìn)電機(jī)脈沖頻率,并送給步進(jìn)部分;如果是換向信號(hào),則換向部分動(dòng)作,為了使電機(jī)降速停止或降到突跳頻率范圍之內(nèi)再換向,先停送驅(qū)動(dòng)脈沖一秒,再送反向脈沖給步進(jìn)部分,驅(qū)動(dòng)電機(jī)換向;步進(jìn)部分則是按照送來的脈沖頻率和步進(jìn)順序信號(hào)驅(qū)動(dòng)電機(jī)按預(yù)定的轉(zhuǎn)速和轉(zhuǎn)向轉(zhuǎn)動(dòng);測(cè)頻部分通過測(cè)定所送脈沖頻率,再利用四相電機(jī)八拍運(yùn)行時(shí)步距角為θ=360度/(50*8)=,再送給顯示模塊顯示。按鍵檢測(cè)部分檢測(cè)到按鍵信號(hào),則送至按鍵去抖部分處理后得到穩(wěn)定的控制信號(hào);在沒有收到控制信號(hào)時(shí),PWM波產(chǎn)生部分則按默認(rèn)的設(shè)置產(chǎn)生PWM波,一旦收到控制信號(hào),波形產(chǎn)生部分則根據(jù)按鍵為累加或遞減信號(hào)來產(chǎn)生相應(yīng)的PWM波脈沖,相應(yīng)的,占空比計(jì)數(shù)部分則開始對(duì)輸出脈沖計(jì)數(shù), PWM信號(hào)占空比的初始值為50%,通過對(duì)時(shí)鐘進(jìn)行計(jì)數(shù),每計(jì)50個(gè)脈沖輸出一個(gè)高電平,再過50個(gè)脈沖輸出一個(gè)低電平。: 直流穩(wěn)壓電源: DC POWER SUPPLY DF1731SL2A,Zhong Ce Electronics CO., LTD; 數(shù)字萬用表:UT101 MULTIMETER 金創(chuàng)電子儀器廠;FPGA實(shí)驗(yàn)儀:DPFPGA, 廣州致遠(yuǎn)電子有限公司; 電機(jī)實(shí)驗(yàn)儀:DP51MOTOR,廣州致遠(yuǎn)電子有限公司;: 問題1:電機(jī)不轉(zhuǎn),正反轉(zhuǎn)指示燈不亮。原因:分壓電阻過大,導(dǎo)致電機(jī)驅(qū)動(dòng)電流過??;解決辦法:根據(jù)電機(jī)驅(qū)動(dòng)電流大小換分壓電阻。 原因:電路設(shè)計(jì)與實(shí)踐數(shù)據(jù)出現(xiàn)偏差,導(dǎo)致流過三極管的電流偏高. 解決辦法:根據(jù)實(shí)測(cè)電路數(shù)據(jù),修改電路原件. 經(jīng)反復(fù)調(diào)試,現(xiàn)電路可按照按鍵輸入準(zhǔn)確控制電機(jī)運(yùn)行.:對(duì)直流伺服電機(jī)采用PWM脈沖方式控制,其功率損耗小,運(yùn)行效率高,加減速性能好,尤其是在要求低速大轉(zhuǎn)矩下連續(xù)運(yùn)行的場(chǎng)合。:, 技術(shù)實(shí)用教程[m].北京:。5. 【M】.北京:。use 。use 。use 。 系統(tǒng)時(shí)時(shí)鐘/換向按鍵/復(fù)位信號(hào) y:out std_logic 。end ztsd。beginprocess(key,clk,rst) 產(chǎn)生換向延時(shí)秒脈沖variable t:integer range 0 to 32000000。039。 elsif key=39。 then t:=0。y=39。 else t:=32000000。139。 end if。 end process。039。139。 end if。 end process。/**/步進(jìn)電機(jī)控制脈沖產(chǎn)生模塊library IEEE。use 。entity step_motor is Port ( clk,rst : in std_logic。 正反轉(zhuǎn)切換鍵 clkkk:out std_logic。 步機(jī)電機(jī)四相輸出end step_motor。type step is array (0 to 7) of std_logic_vector(3 downto 0)。beginprocess(clk,rst) 電機(jī)運(yùn)轉(zhuǎn)脈沖分頻模塊variable t:integer range 0 to 1499999。039。 elsif clk39。139。t:=0。 end if。end process。process(clkk,sel,rst) 控制脈沖產(chǎn)生模塊variable index:integer range 0 to 7:=0。039。 elsif rising_edge(clkk) then if sel=39。 then if index=6 then index:=index+1。 end if。 else index:=7。 end if。 end if。end Behavioral。use 。use 。use 。 系統(tǒng)時(shí)鐘/輸入被測(cè)脈沖/復(fù)位信號(hào) shift:out std_logic_vector(3 downto 0)。 七段數(shù)碼管end cepin。039。signal clkkk:std_logic。039。begincepin:block 測(cè)頻模塊beginprocess(clk,rst)variable t:integer range 1 to 32000000。039。 elsif rising_edge(clk) then if t=32000000 then clkk=not clkk。 else t:=t+1。 end if。process(clkk,clk1,rst) variable t:std_logic_vector(15 downto 0):=(others=39。)。begin if rst=39。 then t:=(others=39。)。 elsif rising_edge(clk1) then if clkk=39。 then if t1399 then t1:=t1+1。 if t(3 downto 0)9 then t(3 downto 0):=t(3 downto 0)+1。 if t(7 downto 4)9 then t(7 downto 4):=t(7 downto 4)+1。 if t(11 downto 8)9 then t(11 downto 8):=t(11 downto 8)+1。 if t(15 downto 12)9 then t(15 downto 12):=t(15 downto 12)+1。 end if。 end if。 end if。039。 end if。count=t。end block。event and clkk=39。 then d2=count。end process。begin if rst=39。 then t:=0。t:=0。 end if。end process。 begin if rst=39。 then t:=00。data_ledin=1111。 data_ledin=d2(3 downto 0)。 when 01=shift=1101。 t:=t+1。 data_ledin=d2(11 downto 8)。 when 11=shift=0111。 t:=00。t:=00。 end if。end block。0 when0001=data_led=11111001。2 when0011=data_led=10110000。4 when0101=data_led=10010010。6 when0111=data_led=11111000。8 when1001=data_led=10010000。No signal。end process。end Behavioral。use 。use 。use 。 復(fù)位信號(hào)/系統(tǒng)時(shí)鐘/減速輸入/加速輸入 count:out std_logic )。architecture Behavioral of bianpin issignal con:integer range 1 to 100:=50。039。beginprocess(clkk,add,sub,rst) 加減鍵處理模塊variable con1:integer range 1 to 100:=50。039。 elsif clkk39。139。039。 end if。039。 end if。 end if。end process。begin if rst=39。 then t:=0。event and clk=39。 then if t=1499999 then clkk=not clkk。 else t:=t+1。 end if。process(clk,con,t1,rst) 變頻模塊begin if rst=39。 then t1=0。count=39。 elsif t1=con then count=39。t1=t1+con。039。 end if。end process。/**/按鍵去抖模塊(同下,略去)/*/步進(jìn)電機(jī)控制模塊library IEEE。use 。 Unment the following lines to use the declarations that are provided for instantiating Xilinx primitive ponents.library UNISIM。entity step_top is Port (clk,add,sub,sel,rst,startstop:in std_logic。 步進(jìn)電機(jī)四相輸出 shift:out std_logic_vector(3 downto 0)。七段數(shù)碼管end step_top。 keyo:out std_logic )。ponent bianpin is Port (clk,sub,add,rst:in std_logic。end ponent bianpin。 sel : in std_logic。 control:out std_logic_vector(3 downto 0))。ponent ztsd is Port (clk,key,rst:in std_logic。 sel:out std_logic)。ponent cepin is Port (clk,clk1,rst:std_logic。 data_led:out std_logic_vector(7 downto 0) )。signal sel1,ss,sel2,count1,y1,y2,startstop1:std_logic。beginu1:anjianqd port map (clk=clk,key=sel,keyo=sel1)。u3:step_motor port map (clk=count1,sel=sel2,clkkk=y2,control=step1,rst=rst)。u5:cepin port map (clk=clk,clk1=y2,shift=shift,data_led=data_led,rst=rst)。step2(3)=step1(3) and y1。step2(1)=step1(1) and y1。step(3)=step2(3) and ss。step(1)=step2(1) and ss。proces