【正文】
//低電平 else //改變PWM口的電平,獲得PWM波形 PWM1=1。//X軸 (A)10 display(6,u21)。 //調用鍵盤掃描函數(shù) if((!XZHOU)||(!YZHOU)) //向XY軸分別輸入數(shù)字 { if(!XZHOU) //如果電機X軸按鈕,鍵入數(shù)值 { //將數(shù)值分別存入u31,u41 delay(1)。 if(t!=0xf0) //第四行閉合的情況下 { t=P2。 break。//f=15 break。 } } }//第二行閉合,4,5,6,X軸反轉四個位置 P2=0xfd。 if(t!=0xf0) { delay()。 //定時器初值設定 TL0=(2561)。//共陰極數(shù)碼管,位選編碼 uchar code seg[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe}。模擬開始之后,屏幕居然顯示了筆者的生日,當時成就感立刻就來了。PROTEUS安裝以后,主要由兩個程序組成:ARES和ISIS。單片機是將微處理器(計算機的中央處理單元CPU)CentralproeessingUnit)、一定容量的RAM和ROM以及I/O接口、定時等電路集成在一片芯片上。這使得熟用上述軟件之人可以自行開發(fā)出自己用著順手的應用程序。也可以對各種買來的家用電子元件進行個性化的魔改。關鍵詞:數(shù)控加工;單片機;SolidWorks;ProteusDesign of 3D servo numerical control platformAbstractThe technology of controlling the mechanical movement and working process by the digital information oriented control program is the socalled numerical control technology of this technology is summarized in the application of puter technology, microelectronics technology, servo drive, active control and precision mapping and other subjects.The core of the CNC milling machine lies in the control system, control system to realize the digital parts of the input program, plete the input information storage, data transform and interpolation operation, in order to achieve a variety of control functions.The design of the control system for milling machine must consider the matching of the hardware and software, and it must be considered from the aspects of economy, practicality and feasibility.. The plete set of AT89C51 as the main control system. In the hardware design easy to achieve effective control function, structure is relatively simple。用Proteus進行仿真模擬。顯然傳統(tǒng)的設計與制造步驟根本無法滿足以上要求。在筆者看來數(shù)字技術必然如上文所說一樣,逐漸簡單化,平民化,全民有興趣之人都可以參與進來,都可以按照自己的個性加工出自己的零件,編寫調試出帶有個人特點的程序,組裝自己心儀的產(chǎn)品,實現(xiàn)每個人不同的要求。 正視圖 側視圖 二維工程圖單片機的介紹及程序說明 單片機的概述自1946年美國軍方定制的第一臺計算機現(xiàn)世以來,計算機的微型化便從未停止過其腳步,最開始的計算機機箱需要幾間屋子盛放,后來變成火車頭大小,再到八九十年代的臺式機,筆記本,平板電腦。: 編程流程圖在編程中,最為重要的便是鍵盤掃描函數(shù),在鍵盤掃描函數(shù)中使用switch函數(shù),分別對矩陣鍵盤的每一行進行詢問,待相應之后分別對每一個回應,對應的每一個鍵位進行定義,以實現(xiàn)矩陣鍵盤的各種功能。,生日截圖這里邊還有一個小插曲,為了連線方便,筆者將數(shù)碼管的數(shù)字接口接到了AT89C51單片機的P0口,將位選接口接到了單片機的P2口,可是屏幕根本不亮。終于,筆者帶著將近一個月的積累,開始合成大程序,筆者將更改之后的三個子程序嵌入到大程序中,并用主函數(shù)分別調用初始化函數(shù),鍵盤掃描函數(shù),顯示函數(shù),筆者以為準備工作做得充足,主函數(shù)只要區(qū)區(qū)數(shù)行就可以完成這次畢設,結果仿真出來的結果讓筆者哭笑不得。i++)。 //第一行閉合,1,2,3,X軸正轉四個位置 t=P2。 } while(t!=0xf0) //松手檢測 { t=P2。 case 0xbd ://第三列閉合(鍵盤6位置) key1=6。 switch(t) { case 0xeb ://第一列閉合(鍵盤7位置) key1=7。 t=P2。 } } delay()。 delay(1)。 if(u22=0) DutyCycle2=43。 if(dida2=DutyCycle2) PWM2=0。 display(3,u12)。 if(u31=u41) u31=a。 case 0xd7 ://第二列閉合(鍵盤0位置) key1=0。 case 0x7b ://第四列閉合(y軸正轉) u22=14。0xf0。0xf0。0xf0。 //開啟定時器 EA=1。//X軸電機控制sbit PWM2=P3^5。很快筆者就改用if循環(huán),在if循環(huán)中嵌套switch語句,雖然不如for循環(huán)簡單明了,需要對矩陣鍵盤的四個橫行詢問,并對每一個縱行代碼進行編譯,但恰好滿足筆者對每個鍵值的定義。這次畢設一開始雖然在心底構思了一些方案,有簡單的流程設計,但一動