電路圖.jpg (1.36 MB, 下載次數(shù): 75)
下載附件
2018-9-17 10:02 上傳
4.jpg (295.3 KB, 下載次數(shù): 77)
下載附件
2018-9-17 10:00 上傳
3.jpg (295.32 KB, 下載次數(shù): 66)
下載附件
2018-9-17 10:00 上傳
2.jpg (327.09 KB, 下載次數(shù): 73)
下載附件
2018-9-17 10:00 上傳
1.jpg (419.77 KB, 下載次數(shù): 84)
下載附件
2018-9-17 10:00 上傳
0-30V 4A數(shù)控穩(wěn)壓電源資料.JPG (26.53 KB, 下載次數(shù): 81)
下載附件
2018-9-17 10:00 上傳
單片機源程序如下:
- /***********************************************************************
- 名字: main.c
- 作者: 春風
- 創(chuàng)建日:2008-8-15
- 工程: 數(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ù)拆開存儲指針型數(shù)據(jù)
- 輸入浮點數(shù),方式0:設定值,1:檢測值
- ************************************************************************************/
- 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ā)送一個字符串,長度64字符之內。
- ************************************************************************************/
- void lcm_w_word(uchar x,uchar y,uchar *str)
- {
- x = x+y;
- w_code(x);
- while(*str != '\0')
- {
- w_data(*str++);
- }
- *str = 0;
- }
- /************************************************************************************
- 顯示設定電壓
- ************************************************************************************/
- void disp_sheding()
- {
- lcm_w_word(0x90,0x00,"設定:");
- sheding_temp1 = sheding_temp + 0.0005;//------加0.0005修正有時顯示.0999
- chai(sheding_temp1,1);
- lcm_w_word(0x90,3,GOUT);
- w_code(0x96);
- w_data('V');
- }
- /************************************************************************************
- AD的16位整形數(shù)轉換成浮點電壓或電流值
- ************************************************************************************/
- 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ù)功能:輸入浮點數(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日 這里原來是0x00就讀AD不正常
- {
- RS = 1;
- RW = 0; //--------避免液晶屏干擾數(shù)據(jù)總線
- if(dac_temp < 0){dac_temp = 0;} //----判斷電壓低于0大于30時把數(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);// 打開背光源
- set_7705_ch(0);
- read_AD_data(0x38);
- set_7705_ch(1);
- read_AD_data(0x39);
- disp_sheding();//顯示設定電壓
- while(1)
- {
- lcm_w_word(0x80,0x02,"穩(wěn)壓電源");
- lcm_w_word(0x90,0x00,"設定:");
- 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();
- ……………………
- …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
所有資料51hei提供下載:
數(shù)控穩(wěn)壓電源程序.rar
(86.33 KB, 下載次數(shù): 241)
2018-9-17 10:01 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
0-30V 4A數(shù)控穩(wěn)壓電源圖.pdf
(68.11 KB, 下載次數(shù): 301)
2018-9-17 10:00 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|