|
一個(gè)不錯(cuò)的數(shù)控電源.就是成本有點(diǎn)高!兩路輸出:1:0-30V/4A 2: 5V/1.5A(固定輸出)
電壓分辨率0.458mV,電流分辨率0.076mA
電壓步進(jìn)0.0073V,實(shí)際用的是0.1V步進(jìn)調(diào)節(jié)
在制作中發(fā)現(xiàn);C37極性畫(huà)反了!還有就是復(fù)位電路是51和AVR都兼容的,不能把四個(gè)原件都焊接上去,用什么芯片就焊接什么樣的復(fù)位電路 !特此告知!
單片機(jī)源程序:
- /***********************************************************************
- 名字: main.c
- 作者: 春風(fēng)
- 工程: 數(shù)控穩(wěn)壓電源
- ***********************************************************************/
- #include"reg52.h"
- //#include"math.h"
- #include"stdlib.h"
- #include"function.h"
- sbit RS = P1^4;
- sbit RW = P1^5;
- sbit E = P1^6;
- #define DBUS P0
- sbit clk_574_1 = P2^3;
- //sbit clk_574_2 = P1^3;
- //sbit lcd_rs = P1^4;
- uint idac;
-
- idata uchar GOUT[7];
- idata float temp1;
- idata float dac_temp;
- idata float sheding_temp;
- idata float sheding_temp1;
- char code dx516[3] _at_ 0x003b;//這是為了仿真設(shè)置的(大蝦仿真器)
- /************************************************************************************
- 把浮點(diǎn)數(shù)拆開(kāi)存儲(chǔ)指針型數(shù)據(jù)
- 輸入浮點(diǎn)數(shù),方式0:設(shè)定值,1:檢測(cè)值
- ************************************************************************************/
- void chai(float x,bit y)
- {
- uint i;
- for(i = 0;i < 7;i ++)
- GOUT[i] = 0;
- if(y == 0)
- {
- i = x / 10;
- if(i == 0)
- GOUT[0] = ' ';
- else
- GOUT[0] = i + '0';
- GOUT[1] = (int)x % 10 + '0';
- x = x * 10;
- GOUT[3] = (int)x % 10 + '0';
- x = x * 10;
- if(((int)x % 10) >= 5 )// 防止后面大于4的數(shù)被舍去
- {GOUT[3] = GOUT[3] + 1;}
- else
- {;}
- GOUT[4] = ' ';
- GOUT[5] = ' ';
- }
- else
- {
- i = x / 10;
- if(i == 0)
- GOUT[0] = ' ';
- else
- GOUT[0] = i + '0';
- GOUT[1] = (int)x % 10 + '0';
- x = x * 10;
- GOUT[3] = (int)x % 10 + '0';
- x = x * 10;
- GOUT[4] = (int)x % 10 + '0';
- x = (x * 10);
- GOUT[5] = (unsigned int)x % 10 + '0';
- }
- GOUT[2] = '.';
- GOUT[6] = '\0';
- }
- /************************************************************************************
- //向LCM發(fā)送一個(gè)字符串,長(zhǎng)度64字符之內(nèi)。
- ************************************************************************************/
- void lcm_w_word(uchar x,uchar y,uchar *str)
- {
- x = x+y;
- w_code(x);
- while(*str != '\0')
- {
- w_data(*str++);
- }
- *str = 0;
- }
- /************************************************************************************
- 顯示設(shè)定電壓
- ************************************************************************************/
- void disp_sheding()
- {
- lcm_w_word(0x90,0x00,"設(shè)定:");
- sheding_temp1 = sheding_temp + 0.0005;//------加0.0005修正有時(shí)顯示.0999
- chai(sheding_temp1,1);
- lcm_w_word(0x90,3,GOUT);
- w_code(0x96);
- w_data('V');
- }
- /************************************************************************************
- AD的16位整形數(shù)轉(zhuǎn)換成浮點(diǎn)電壓或電流值
- ************************************************************************************/
- float adjisuan_U(uint x)
- {
- temp1 = 11.990 / 0x5e1f;
- temp1 = x * temp1;
- return temp1;
- }
- float adjisuan_I(uint x) //
- {
- temp1 = 0.899 / 0x253d;
- temp1 = (x * temp1)-0.005;
- return temp1;
- }
- /************************************************************************************
- *
- *函數(shù)功能:輸入浮點(diǎn)數(shù)
- *
- ************************************************************************************/
- float scanf_float(void)
- {
- static uchar i = 0;
- static uchar x[5] = {'0','0','0','0','0'};
- static bit k = 1;
- uchar temp1,temp2;
- temp1 = key_sm();
- temp2 = key_sm();
- if((temp2 == 0xff) || (temp1 != temp2))
- {
- k = 1;
- return(atof(x));
- }
- else if(k)
- {
- k = 0;
- x[i] = temp1;
- i ++;
- if((temp1 == key_esc) || (i == 4))
- {
- x[0] = '0';
- x[1] = '0';
- x[2] = '0';
- x[3] = '0';
- x[4] = '0';
- i = 0;
- }
- return(atof(x));
- }
- }
- /************************************************************************************
- 掃描按鍵,并根據(jù)鍵值修改DAC的電壓
- ************************************************************************************/
- void key_dac()
- {
- uchar key_qiao;
- key_qiao = key_sm();
- switch(key_sm())
- {
- case key_shang:dac_temp = dac_temp + 1.0;break;//---按下上鍵電壓加1V
- case key_xia :dac_temp = dac_temp - 1.0;break;//---按下下鍵電壓減1
- case key_zuo :dac_temp = dac_temp - 0.1;break;//---按下左鍵電壓減0.1
- case key_you :dac_temp = dac_temp + 0.1;break;//---按下右鍵電壓加0.1
- case key_0 :dac_temp = 0; break;//---按下0鍵電壓歸0
- default: key_qiao = 0xff;
- }
- if(key_qiao != 0xff) // 10月1日 這里原來(lái)是0x00就讀AD不正常
- {
- RS = 1;
- RW = 0; //--------避免液晶屏干擾數(shù)據(jù)總線
- if(dac_temp < 0){dac_temp = 0;} //----判斷電壓低于0大于30時(shí)把數(shù)據(jù)歸0
- if(dac_temp >= 30.10){dac_temp = 0;}
- sheding_temp = dac_temp ;
- disp_sheding();
- idac = conver(dac_temp);
- dac(idac);
- delay(50000);
- }
- }
- /************************************************************************************
- 主函數(shù)
- ************************************************************************************/
- main()
- {
-
- lcd_rst(0);
- rst_ad();
- dac_temp = 0 ;
- RS = 1;
- RW = 0; //--------避免液晶屏干擾數(shù)據(jù)總線
- dac(conver(dac_temp)); //吸合低壓繼電器并輸出0V
- LED_ONOFF(1);// 打開(kāi)背光源
- set_7705_ch(0);
- read_AD_data(0x38);
- set_7705_ch(1);
- read_AD_data(0x39);
- disp_sheding();//顯示設(shè)定電壓
- while(1)
- {
- lcm_w_word(0x80,0x02,"穩(wěn)壓電源");
- lcm_w_word(0x90,0x00,"設(shè)定:");
- lcm_w_word(0x88,0x00,"電壓:");
- lcm_w_word(0x98,0x00,"電流:");
-
- write_ad(0x10);
- write_ad(0x04);
- adjisuan_U(read_AD_data(0x38));
- chai(temp1,1);
- lcm_w_word(0x88,3,GOUT);
- key_dac();
- …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼
下載:
0-30V 4A數(shù)控穩(wěn)壓電源資料.zip
(3.21 MB, 下載次數(shù): 161)
2017-5-6 13:12 上傳
點(diǎn)擊文件名下載附件
|
|