吳明波
摘要:該電路用于公共場(chǎng)所供水控制的一種電路,工作人員可根據(jù)用水人數(shù)的多少來(lái)選擇功能開(kāi)關(guān),合理的控制用水,能達(dá)到節(jié)水的目的。該電路由水位探測(cè)、水深選擇、單片機(jī)、數(shù)字顯示、繼電器控制等5部分組成。四個(gè)常開(kāi)型干簧管H1-H4分別置于水箱里的四個(gè)不同的位置,作為水位探測(cè)電路;三個(gè)開(kāi)關(guān)S1,S2,S3為功能選擇開(kāi)關(guān),進(jìn)行水深的選擇;數(shù)碼管用來(lái)顯示水位的高低;單片機(jī)的一個(gè)端口.做為繼電器控制端,控制水泵的抽水。該電路要求水位為最低時(shí),水泵開(kāi)始抽水,抽到水位為最高為止,水泵才停止工作;當(dāng)水位下降時(shí),水位未到最低點(diǎn)水泵不抽水,直到水位降到最低時(shí)水泵才開(kāi)始抽水,抽到水位為最高為止,如此反復(fù)進(jìn)行。
關(guān)鍵詞:數(shù)顯水位控制器;水位探測(cè)傳感器;干簧管水深選擇;單片機(jī);數(shù)字顯示;繼電器;水泵
中圖分類(lèi)號(hào):TP311文獻(xiàn)標(biāo)識(shí)碼:A文章編號(hào):1009-3044(2012)02-0469-02
AT89C52 Based Digital Water Level Controller
WU Ming-bo
(Changsha City School of Electronics Industry, Changsha 410008, China)
Abstract:This electric circuit is used to control the water supply in public places . Staff workers can choose the functional switches accord? ing to the number of people using the water to control the water using reasonably to save water. This electric circuit consists of five parts : detection of water level, selection of water depth, MCU, digital display and replay control. Four normal-on reed switches H1-H4 are put in four different places in the water tank and used as water lever detection circuit. Three switches S1,S2, S3 are used as functional switches to choose the depth of the water. The nixie tube is used to show the high-low of the water level. One port of the MCU is used as the end of replay control to control the pumping. This circuit requires that when the water level reaches the lowest point, the water pump begin to pump and it wont stop until the water level has reached the highest point. On the contrary, when the water level drops to the lowest point, the pump begins to pump (not when the water level isnt the lowest) till the water level reaches the highest point and the cycle will be repeated continuously .
Key words: digital controller of water level; water level detection sensor; reed switch; single chip microcomputer; digital display depth se? lection; relay; water pump
該電路可用于賓館、酒店、工廠、學(xué)校等單位根據(jù)用水人數(shù)進(jìn)行供水控制,從而達(dá)到節(jié)水的目的。該電路采用的水位探測(cè)傳感器是用紫銅管、常開(kāi)型干簧管和帶磁鐵的塑料浮漂制作而成,經(jīng)久耐用、不腐蝕、不電解水。
1電路結(jié)構(gòu)
該電路由水位探測(cè)、水深選擇、單片機(jī)、數(shù)字顯示、繼電器控制等5部分組成。四個(gè)常開(kāi)型干簧管H1-H4分別置于水箱里的四個(gè)不同的位置,作為水位探測(cè)電路;三個(gè)開(kāi)關(guān)S1,S2,S3為功能選擇開(kāi)關(guān),作為可控水深選擇電路;S1的功能是設(shè)置水位在H1-H4之間進(jìn)行高水位自動(dòng)檢測(cè)控制;S2的功能是設(shè)置水位在H1-H3之間進(jìn)行中水位自動(dòng)檢測(cè)控制;S3的功能是設(shè)置水位在H1-H2之間進(jìn)行低水位自動(dòng)檢測(cè)控制。將AT89C52的p1口通過(guò)限流電阻與一個(gè)共陽(yáng)極數(shù)碼管相連,用來(lái)顯示水位的高低,p3.6.做為繼電器控制端,繼電器的常開(kāi)觸點(diǎn)作水泵的電源控制開(kāi)關(guān),常開(kāi)觸點(diǎn)閉合時(shí),水泵通電給水箱灌水。
2電路的工作原理
上電后,芯片自動(dòng)復(fù)位并從0000H單元開(kāi)始執(zhí)行程序。初始化以后,芯片循環(huán)檢測(cè)P3.4,P3.5,P3.7口,即檢測(cè)功能開(kāi)關(guān)S1-S3的狀態(tài),若哪個(gè)端口被檢測(cè)為低電平,則執(zhí)行相應(yīng)的水位檢測(cè)程序。功能開(kāi)關(guān)S1-S3的閉合和斷開(kāi)會(huì)出現(xiàn)如下幾種情況:
1)當(dāng)用水人數(shù)很多時(shí),閉合S1,程序循環(huán)檢測(cè)水箱里不同高度的四只常開(kāi)型干簧管H1-H4的狀態(tài)。當(dāng)水位降低到最低位置時(shí),H1閉合,數(shù)碼管顯示“1”,P3.6口輸出低電平,三極管導(dǎo)通,繼電器線圈得電,常開(kāi)觸點(diǎn)閉合,水泵得電開(kāi)始抽水;當(dāng)水位上升到H2的位置時(shí),H2閉合,數(shù)碼管顯示“2”,P3.6口保持低電平,繼電器觸點(diǎn)保持閉合,水泵繼續(xù)抽水;當(dāng)水位上升到H3的位置時(shí),H3閉合,數(shù)碼管顯示“3”,P3.6口保持低電平,繼電器觸點(diǎn)保持閉合,水泵繼續(xù)抽水;當(dāng)水位上升到H4的位置時(shí),H4閉合,數(shù)碼管顯示“4”,P3.6口輸出高電平,繼電器觸點(diǎn)斷開(kāi),水泵停止抽水。水箱里的水位下降時(shí)與上述情況相反。即水位下降在H4與H1之間時(shí),P3.6口輸出高電平,水泵不抽水,直到水位下降到H1時(shí),P3.6口才輸出低電平,三極管導(dǎo)通,繼電器線圈得電,常開(kāi)觸點(diǎn)閉合,水泵得電開(kāi)始抽水。
2)當(dāng)用水人數(shù)比較多時(shí),閉合S2,程序循環(huán)檢測(cè)水箱里不同高度的三只常開(kāi)型干簧管H1-H3的狀態(tài)。與S1閉合時(shí)相似,當(dāng)水位降低到最低位置時(shí),H1閉合,數(shù)碼管顯示“1”,P3.6口輸出低電平,水泵得電開(kāi)始抽水;此后水泵繼續(xù)抽水,直到水位上升到H3的位置時(shí),H3閉合,數(shù)碼管顯示“3”,P3.6口輸出高電平,繼電器觸點(diǎn)斷開(kāi),水泵停止抽水。水箱里的水位下降時(shí)與上述情況相反。
3)當(dāng)用水人數(shù)比較少時(shí),閉合S3,程序循環(huán)檢測(cè)水箱里不同高度的兩只常開(kāi)型干簧管H1-H2的狀態(tài)。當(dāng)水位降低到最低位置時(shí),H1閉合,數(shù)碼管顯示“1”,P3.6口輸出低電平,水泵得電開(kāi)始抽水;當(dāng)水位上升到H2的位置時(shí),H2閉合,數(shù)碼管顯示“2”,P3.6口輸出高電平,水泵停止抽水。水箱里的水位下降時(shí)與上述情況相反。
4)當(dāng)S1,S2,S3中有兩個(gè)或三個(gè)閉合,則屬于誤操作,數(shù)碼管顯示“E”,P3.6口輸出高電平,繼電器觸點(diǎn)斷開(kāi),水泵不抽水。
參考程序:#include
sbit H1=P3^0;
sbit H2=P3^1;
sbit H3=P3^2;
sbit H4=P3^3;
sbit S1=P3^4;
sbit S2=P3^5;
sbit S3=P3^7;
sbit shuibeng=P3^6;
void main(void)
{ unsigned char i;
P1=0xff; P3=0xff;
while(1)
{if((S1==0 && S2==0) || (S1==0 && S3==0 )|| (S2==0 && S3==0 ) )
{
shuibeng=1;
P1=0x06;
}
else
{
P1=i;
if(H1==0 && (S1==0 || S2==0 || S3==0))
{shuibeng=0;
i=0xf9;
}
if(H2==0 && (S1==0 || S2==0 || S3==0))
{ i=0xa4;
if(S3==0) shuibeng=1;
}
if(H3==0 && (S1==0 || S2==0 ))
{
i=0xb0;
if(S2==0) shuibeng =1;
} if(H4==0 && S1==0)
{ i=0x99;
shuibeng=1;
} } } }
圖1
圖2水位傳感器
參考文獻(xiàn):
[1]蔡美琴.MCS-51系列單片機(jī)系統(tǒng)及其應(yīng)用[M].北京:高教出版社,2004.
[2]彭偉.單片機(jī)C語(yǔ)言程序設(shè)計(jì)與實(shí)訓(xùn)100例[M].北京:電子工業(yè)出版社,2009.