【正文】
= 0。 SCK = 0。 for(j=15。j0。j) { SCK = 0。 if(j == 15) { SDI = 1。 } if(j == 14) { SDI = 0。 } if(SDO==1) { voltage_data = voltage_data + 1。 } voltage_data=voltage_data1。 SCK =1。 } CONV = 1。 SCK = 1。 ADC_V_display(voltage_data*6)。 } //***********************采集到的電壓顯示 *************************** void ADC_V_display(long voltage ) { int ADC_V_1,ADC_V_2。 int ADC_V_3,ADC_V_4,ADC_V_5。 voltage = (voltage*5000)/65535。 // AD采樣值處理,例如猜到的數(shù)位: mon_V=voltage。 //做一下處理 ADC_V_1=voltage/10000。 //1 ADC_V_1=ADC_V_1+0x30。 ADC_V_2=voltage%10000/1000。 //3 ADC_V_2=ADC_V_2+0x30。 ADC_V_3=voltage%10000%1000/100。 //1 ADC_V_3=ADC_V_3+0x30。 ADC_V_4=voltage%10000%1000/10%10。 //2 ADC_V_4=ADC_V_4+0x30。 ADC_V_5=voltage%10000%1000%10。 //7 ADC_V_5=ADC_V_5+0x30。 a=0x82。 write()。 a= ADC_V_1。 indata()。 a= ADC_V_2。 indata()。 a=0x85。 write()。 a= ADC_V_3。 indata()。 a= ADC_V_4。 indata()。 a= ADC_V_5。 indata()。 } //*********************LTC1655 16位 DAC轉(zhuǎn)換器 ************************ void DAC_start() { double k,f。 int m。 clk=0。 cs =0。 k=bfdot*1000+afdot。 //小數(shù)點前面得數(shù) +小數(shù)點后面的數(shù) = f=k/。 f= f*65535/。 m=f。 SendD(m)。 } void SendD(int dat) { uchar p=0。 cs = 1。 cs = 0。 for(p=0。p16。p++) { din = dat amp。 0x8000。 clk= 1。 dat=dat1。 clk= 0。 } cs = 1。 cs = 0。 } //********************電流采集并顯示 ************************* void I_DISPLAY() { int ADC_I_1,ADC_I_2。 int ADC_I_3,ADC_I_4。 long I_voltage。 I_voltage=mon_V/10。 //例如采集到的數(shù)為: 3127,做下面處理 mon_I=I_voltage。 ADC_I_2=I_voltage%1000/100。 //1 ADC_I_2=ADC_I_2+0x30。 ADC_I_3=I_voltage%1000%100/10。 //2 ADC_I_3=ADC_I_3+0x30。 ADC_I_4=I_voltage%1000%100%10。 //7 ADC_I_4=ADC_I_4+0x30。 a=0x8b。 write()。 a= ADC_I_1。 indata()。 a=0x8d。 write()。 a= ADC_I_2。 indata()。 a= ADC_I_3。 indata()。 a= ADC_I_4。 indata()。 } //**************************功率顯示 ********************************* void W_display() { long W,W_1,W_2,W_3,W_4,W_5。 W_1=W/10000。 //1 W_1=W_1+0x30。 W_2=W%10000/1000。 //3 W_2=W_2+0x30。 W_3=W%10000%1000/100。 //1 W_3=W_3+0x30。 W_4=W%10000%1000/10%10。 //2 W_4=W_4+0x30。 W_5=W%10000%1000%10。 //7 W_5=W_5+0x30。 a=0xC2。 write()。 a= W_1。 indata()。 a= W_2。 indata()。 a=0xC5。 write()。 a= W_3。 indata()。 a= W_4。 indata()。 a= W_5。 indata()。 } //*************液晶系統(tǒng)初始化 ******************** void inti_mcu() { P0=0XFF。 P1=0XFF。 P2=0XFF。 P3=0XFF。 } void inti_clm() //液晶初始化 { a=0x38。 write()。 //兩行, 5*7 a=0x08。 //關(guān)閉顯示器 write()。 a=0x01。 //清楚顯示器 write()。 a=0x0c。 //開啟顯示屏 write()。 a=0x06。 //ac+1, 字符不動光標(biāo)右移 write()。 inti_face()。 } void inti_face() { int i。 a=0x80。 write()。 for( i=0。i16。i++) { a=tab1[i]。 indata()。 } a=0xc0。 write()。 for( i=0。i16。i++) { a=tab2[i]。 indata()。 } } void write() //寫子程序,寫地址 { checkbusy()。 RS=0。 RW=0。 E=1。 P0=a。 E=0。 } void checkbusy() //檢查是否處于繁忙狀態(tài) { RS=0。 RW=1。 E=1。 while((ACCamp。0x80)==1)。 E=0。 delay()。 } void indata() //寫數(shù)據(jù)子程序 { checkbusy()。 RS=1。 RW=0。 E=1。 P0=a。 E=0。 } Based on the 51 microcontroller numerical DC power supply design LI Wanming Chongqing Three Ges College Institute of Technology Electronics and Information Engineering 2020 Wanzhou, Chongqing 404000 Abstract: The method of this paper based on the 51 microcontroller core of the numerical controller DC power supply design theory and realization. The power supply has some functions such as presetting voltage, stepping adjustment, displaying the output voltage signals and current signals at the same time. This paper introduces a general designing plan of the system, which is mainly consisted of microcontroller module, D/A change module, A/D change module,voltagecontroller output module ,display module, keyboard module, MCU short circuit’s protect module. The system is based on the principle of singlechip microputer to control the unit AT89C52 to LTC1655 digitaltoanalog converter chip reference voltage to control the output voltage TIP122 output voltage conversion module size, while the output voltage regulator, current use of analogtodigital converter LTC1865 chip sampling of voltage and current converted to digital signals, and then through the singlechip control to achieve. Keywords microcontroller (MCU) the Digital to Analog (DAC) the Analog to Digital (ADC) control