|
Liquid level controller circuit

The figure given below shows complete schematic diagram of the system.
Connections:-
the port P1 is connected with digital outputs D0-D7 of ADC. The RC
components R2 and C1 forms basic clock circuit for ADC. R3 & R4 forms voltage
divider network to generate reference voltage for ADC. The analog output from
tank system is directly fed to +Ve input of ADC. Chip select signal CS is tied to gnd. Three control signals RD, WR and INTR of ADC are connected with P3.7, P3.6 and P3.3 respectively. The data pins of LCD are connected with P0 through latch 74LS373. Three control signals RS, RW & En are connected with P2.0, P2.1 and P2.2 respectively. Five LEDs D1 - D5 are connected with P2 pins as shown. Three inputs Fwd, Rev and Stop of tank system are connected to P3.4, P3.5 and P3.0 through buffer IC 74LS07. Tank empty output and set level output are connected with P3.1 and P3.2 through inverter 74LS04. Two LEDs (red and green) are connected for indication of tank empty and set level reached.
Operation: -
-
Initially controller displays the set water level on LCD and then applies fwd pulse to pump control
-
So the liquid will start flowing inside tank. This is indicated by LED D2.
-
Then after every 2 seconds controller will read the liquid level in tank through ADC and displays it as current water level
-
Now as the liquid is filling in tank, when it reaches the set level it sends signal to controller on P3.1 and immediately controller will apply stop pulse
-
No more liquid is pumped into tank. This is indicated by D3
-
This level is maintained for 10 seconds. Then controller sends rev pulse. So liquid will start flowing outside from the tank. This is indicated by D1.
-
As tank is completely flushed, the tank empty output is given to controller generates an interrupt. And immediately controller will apply fwd pulse
-
So again the pump will again start filling tank. And this cycle continuous.
-
LEDs D4 and D5 indicates sensing of current liquid level in tank through ADC.
Software
program: -
the program written in C language for this application. entire program is divided into 10 different functions along with one main function. so let us understand them one by one
-
- writecmd function sends command byte to LCD. It takes one argument byte and sends it to P0
-
writedata function sends data byte to be displayed on LCD. It also takes one argument byte and sends it to P0
-
writestr function writes whole string (message) on LCD. It takes pointer as an argument that points address of first character of string. then through pointer it sends all the character one by one to P0
-
lcddly function provides delay before sending data or command to LCD so that LCD becomes ready to accept it.
-
dely function is small delay (around 100 ms) for applying pulse and for LED indications
-
bigdly function is a variable delay. it takes one
integer argument and provides delay in seconds depending upon the value passed to it.
-
display function takes any hex value as an argument and first convert it into decimal. then this decimal value is
further converted into 3 ASCII characters and displays them onto LCD
-
int0 function is actually interrupt subroutine. so it is called automatically when interrupt is generated. this function is called when external interrupt is generated that means when tank is completely flushed. so this function just gives fwd pulse and indicates on LED
-
int1 function is also interrupt subroutine. it is called automatically when external interrupt 1 is generated that means when ADC finishes conversion and provides INTR signal. so it reads the data from ADC and display the value as ' current water level '
-
timer function is also interrupt subroutine and it is called when timer overflows from all 1's to all 0's. timer overflows after every 50 ms due to the loaded count. this
function counts 40 such overflows. so finely it generates 40*50 = 2000 ms = 2 s
the main function performs following tasks
-
initializes port (as i/p or o/p), LCD, timer and enables all interrupts
-
loads the count in timer registers
-
displays set value as ' set water level '
-
applies fwd pulse and indicates on LED
-
applies WR pulse to ADC to read ' cur water lever '
-
then waits for set limit is reached. when it is reached sends stop pulse and indicates on LED
-
then after waiting for 10 sec it sends rev pulse and indicates on LED
-
as when tank is flushed it
automatically sends fwd pulse the main function again waits for set limit reached
-
so this is continuous cycle.
click here for complete program in C with comments |