![]() |
會編程的都是老大 |
先收藏![]() |
好東西,正需要,感謝開源。 |
有點講解就完美了 這么看真是一頭漿糊啊 |
樓主的數(shù)控電源太好了,謝謝分享 |
我沒有黑幣,能否把穩(wěn)壓電源資料發(fā)我郵箱,謝謝!773414324@qq.com |
參與人數(shù) 1 | 黑幣 +9 | 收起 理由 |
---|---|---|
![]() | + 9 | 多回技術(shù)貼子,積分就多了,下載就沒問題 |
學(xué)習(xí)了 |
在礦石論壇上電源版上學(xué)習(xí)到呂老師此作品,!原諒我來51HEI壇晚,資歷不夠,不能為老師評分,但鼓勵是一直的謝謝老師再分享~ |
有沒朋友驗證過? |
新手學(xué)習(xí) |
![]() |
感謝分享,謝謝 ![]() |
感謝分享 支持樓主 ![]() |
感謝分享 支持樓主 |
感謝樓主分享~ |
有原理圖就更好了 |
放個實物圖片就完美了 |
先支持一下,等待樓主上圖講解。 |
'/////////////////////////////////////////////////////////////////////////////// '/ / '/ 這是一個M8控制LM317的直流穩(wěn)壓電源 / '/ 輸出電壓 0-20V 連續(xù)調(diào)節(jié) / '/ 最大輸出電流 1.5A / '/ 截止型過電流保護 0-1.5A 連續(xù)調(diào)節(jié) / '/ 呂軍省 junsheng427@126.com 200712 于天津大港 / '/ / '/////////////////////////////////////////////////////////////////////////////// $regfile = "m8def.dat" $crystal = 8000000 $baud = 9600 Config Lcdpin = Pin , Db4 = Portb.2 , Db5 = Portb.3 , Db6 = Portb.4 , Db7 = Portb.5 , E = Portb.0 , Rs = Portd.2 Config Lcd = 16 * 2 '定義LED是16字符,2行 Config Adc = Single , Prescaler = Auto , Reference = Internal '定義ADC為單次運行模式,轉(zhuǎn)換時鐘-自動,內(nèi)部參考電壓 Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Prescale = 1 'PWM1A配置,用于數(shù)模轉(zhuǎn)換, Ddrb.1 = 1 'PWM1A輸出端子 '定義所需要變量 //////////////////////////////////////////////////////////////// Dim V_dc As Long , A_dc As Long , W As Long Dim V1_dc As Word , A1_dc As Word , A As Word , C As Word , A1 As Word Dim V1 As String * 5 Dim V2 As String * 5 Dim C1 As String * 5 Dim N As Byte , B2 As Byte , B3 As Byte , B4 As Byte , B5 As Byte '初始化設(shè)置///////////////////////////////////////////////////////////////////// Ddrd.3 = 0 '按鍵初始化 Ddrd.4 = 0 Ddrd.5 = 0 Ddrd.6 = 0 Ddrd.7 = 0 Portd.3 = 1 Portd.4 = 1 Portd.5 = 1 Portd.6 = 1 Portd.7 = 1 Start Timer1 Start Adc Cls Cursor Off A = 0 C = 1500 W = 0 Ddrc.4 = 1 '初始化風(fēng)扇控制 Portc.4 = 0 Ddrc.3 = 1 '初始化繼電器控制 Portc.3 = 0 Ddrc.2 = 1 Portc.2 = 0 '主程序///////////////////////////////////////////////////////////////////////// Do Pwm1a = A N = 1 V1_dc = 0 A1_dc = 0 V_dc = 0 A_dc = 0 For N = 1 To 30 'ADC采樣30次 V1_dc = Getadc(0) V_dc = V_dc + V1_dc 'ADC的原始值累加 A1_dc = Getadc(1) A_dc = A_dc + A1_dc Next V_dc = V_dc / 30 A_dc = A_dc / 30 V_dc = 2560 * V_dc V_dc = V_dc / 1023 A_dc = 2560 * A_dc A_dc = A_dc / 1430 If A >= 451 Then Portc.3 = 1 Else Portc.3 = 0 '繼電器控制 If A < 451 Then W = 1400 Else W = 2800 W = W - V_dc W = W * A_dc If W > 400000 Then Portc.4 = 1 Else Portc.4 = 0 '風(fēng)扇控制 Gosub Lp_lcd Gosub Lp_key If A_dc >= C Then '截止型電流保護 Waitms 500 If A_dc >= C Then A1 = A A = 0 Locate 1 , 12 Lcd "OC " Gosub Mu End If End If Loop End '顯示處理/////////////////////////////////////////////////////////////////////// Lp_lcd: V1 = Str(v_dc) V1 = Format(v1 , " 0.00") '數(shù)字轉(zhuǎn)換為字符串,確定小數(shù)點 V2 = Str(a_dc) V2 = Format(v2 , "0.000") C1 = Str(c) C1 = Format(c1 , "0.000") Locate 1 , 1 Lcd "U=" ; V1 ; "V" Lowerline Lcd "I=" ; V2 ; "A <" Locate 2 , 11 Lcd C1 ; "A" Return '按鍵處理////////////////////////////////////////////////////////////////////// Lp_key: If Pind.3 = 0 Then '啟動 Waitms 20 If Pind.3 = 0 And A = 0 Then A = A1 Locate 1 , 12 Lcd "ON " Waitms 250 End If End If If Pind.3 = 0 Then '停止 Waitms 20 If Pind.3 = 0 And A > 1 Then A1 = A A = 0 Locate 1 , 12 Lcd "OFF" End If End If If Pind.4 = 1 Then B2 = 0 '電壓+ If Pind.4 = 0 Then Waitms 20 If Pind.4 = 0 Then If A < 1023 Then A = A + 1 B2 = B2 + 1 If B2 > 20 And A < 1013 Then A = A + 10 End If End If End If End If If Pind.5 = 1 Then B3 = 0 '電壓- If Pind.5 = 0 Then Waitms 20 If Pind.5 = 0 Then If A > 1 Then A = A - 1 B3 = B3 + 1 If B3 > 20 And A > 10 Then A = A - 10 End If End If End If End If If Pind.6 = 1 Then B4 = 0 '電流+ If Pind.6 = 0 Then Waitms 20 If Pind.6 = 0 Then If C < 1500 Then C = C + 1 B4 = B4 + 1 If B4 > 20 And C < 1480 Then C = C + 20 End If End If End If End If If Pind.7 = 1 Then B5 = 0 '電流- If Pind.7 = 0 Then Waitms 20 If Pind.7 = 0 Then If C > 1 Then C = C - 1 B5 = B5 + 1 If B5 > 20 And C > 20 Then C = C - 20 End If End If End If End If Return '報警聲音/////////////////////////////////////////////////////////////////////// Mu: Sound Portc.5 , 100 , 1000 Waitms 20 Sound Portc.5 , 100 , 1000 Waitms 20 Sound Portc.5 , 100 , 1000 Return '/////////////////////////////////////////////////////////////////////////////// |
'/////////////////////////////////////////////////////////////////////////////// '/ / '/ 這是一個M8控制LM317的直流穩(wěn)壓電源 / '/ 輸出電壓 0-20V 連續(xù)調(diào)節(jié) / '/ 最大輸出電流 1.5A / '/ 截止型過電流保護 0-1.5A 連續(xù)調(diào)節(jié) / '/ 呂軍省 junsheng427@126.com 200712 于天津大港 / '/ / '/////////////////////////////////////////////////////////////////////////////// $regfile = "m8def.dat" $crystal = 8000000 $baud = 9600 Config Lcdpin = Pin , Db4 = Portb.2 , Db5 = Portb.3 , Db6 = Portb.4 , Db7 = Portb.5 , E = Portb.0 , Rs = Portd.2 Config Lcd = 16 * 2 '定義LED是16字符,2行 Config Adc = Single , Prescaler = Auto , Reference = Internal '定義ADC為單次運行模式,轉(zhuǎn)換時鐘-自動,內(nèi)部參考電壓 Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Prescale = 1 'PWM1A配置,用于數(shù)模轉(zhuǎn)換, Ddrb.1 = 1 'PWM1A輸出端子 '定義所需要變量 //////////////////////////////////////////////////////////////// Dim V_dc As Long , A_dc As Long , W As Long Dim V1_dc As Word , A1_dc As Word , A As Word , C As Word , A1 As Word Dim V1 As String * 5 Dim V2 As String * 5 Dim C1 As String * 5 Dim N As Byte , B2 As Byte , B3 As Byte , B4 As Byte , B5 As Byte '初始化設(shè)置///////////////////////////////////////////////////////////////////// Ddrd.3 = 0 '按鍵初始化 Ddrd.4 = 0 Ddrd.5 = 0 Ddrd.6 = 0 Ddrd.7 = 0 Portd.3 = 1 Portd.4 = 1 Portd.5 = 1 Portd.6 = 1 Portd.7 = 1 Start Timer1 Start Adc Cls Cursor Off A = 0 C = 1500 W = 0 Ddrc.4 = 1 '初始化風(fēng)扇控制 Portc.4 = 0 Ddrc.3 = 1 '初始化繼電器控制 Portc.3 = 0 Ddrc.2 = 1 Portc.2 = 0 '主程序///////////////////////////////////////////////////////////////////////// Do Pwm1a = A N = 1 V1_dc = 0 A1_dc = 0 V_dc = 0 A_dc = 0 For N = 1 To 30 'ADC采樣30次 V1_dc = Getadc(0) V_dc = V_dc + V1_dc 'ADC的原始值累加 A1_dc = Getadc(1) A_dc = A_dc + A1_dc Next V_dc = V_dc / 30 A_dc = A_dc / 30 V_dc = 2560 * V_dc V_dc = V_dc / 1023 A_dc = 2560 * A_dc A_dc = A_dc / 1430 If A >= 451 Then Portc.3 = 1 Else Portc.3 = 0 '繼電器控制 If A < 451 Then W = 1400 Else W = 2800 W = W - V_dc W = W * A_dc If W > 400000 Then Portc.4 = 1 Else Portc.4 = 0 '風(fēng)扇控制 Gosub Lp_lcd Gosub Lp_key If A_dc >= C Then '截止型電流保護 Waitms 500 If A_dc >= C Then A1 = A A = 0 Locate 1 , 12 Lcd "OC " Gosub Mu End If End If Loop End '顯示處理/////////////////////////////////////////////////////////////////////// Lp_lcd: V1 = Str(v_dc) V1 = Format(v1 , " 0.00") '數(shù)字轉(zhuǎn)換為字符串,確定小數(shù)點 V2 = Str(a_dc) V2 = Format(v2 , "0.000") C1 = Str(c) C1 = Format(c1 , "0.000") Locate 1 , 1 Lcd "U=" ; V1 ; "V" Lowerline Lcd "I=" ; V2 ; "A <" Locate 2 , 11 Lcd C1 ; "A" Return '按鍵處理////////////////////////////////////////////////////////////////////// Lp_key: If Pind.3 = 0 Then '啟動 Waitms 20 If Pind.3 = 0 And A = 0 Then A = A1 Locate 1 , 12 Lcd "ON " Waitms 250 End If End If If Pind.3 = 0 Then '停止 Waitms 20 If Pind.3 = 0 And A > 1 Then A1 = A A = 0 Locate 1 , 12 Lcd "OFF" End If End If If Pind.4 = 1 Then B2 = 0 '電壓+ If Pind.4 = 0 Then Waitms 20 If Pind.4 = 0 Then If A < 1023 Then A = A + 1 B2 = B2 + 1 If B2 > 20 And A < 1013 Then A = A + 10 End If End If End If End If If Pind.5 = 1 Then B3 = 0 '電壓- If Pind.5 = 0 Then Waitms 20 If Pind.5 = 0 Then If A > 1 Then A = A - 1 B3 = B3 + 1 If B3 > 20 And A > 10 Then A = A - 10 End If End If End If End If If Pind.6 = 1 Then B4 = 0 '電流+ If Pind.6 = 0 Then Waitms 20 If Pind.6 = 0 Then If C < 1500 Then C = C + 1 B4 = B4 + 1 If B4 > 20 And C < 1480 Then C = C + 20 End If End If End If End If If Pind.7 = 1 Then B5 = 0 '電流- If Pind.7 = 0 Then Waitms 20 If Pind.7 = 0 Then If C > 1 Then C = C - 1 B5 = B5 + 1 If B5 > 20 And C > 20 Then C = C - 20 End If End If End If End If Return '報警聲音/////////////////////////////////////////////////////////////////////// Mu: Sound Portc.5 , 100 , 1000 Waitms 20 Sound Portc.5 , 100 , 1000 Waitms 20 Sound Portc.5 , 100 , 1000 Return '/////////////////////////////////////////////////////////////////////////////// |
Powered by 單片機教程網(wǎng)