Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Water Level Detector Using Ultrasound sensor.

Status
Not open for further replies.

Prosenjit101

Newbie level 5
Joined
Apr 18, 2013
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Dhaka, Bangladesh
Activity points
1,349
I want to design a Water Level Detector for the water Tank i have in the roof of my building.
I plan on using an ultrasound device.
I will use a PIC16f877A microcontroller.
And connect it with three 7bit segment display.
I expect that i will recieve some kind of an analog input in the input pin of the micro controller.
Furthurmore, i wish to simulate it using Proteus, and generate the HEX file using MPLAB and assembly language.
However, i am not so proficient at this.
What i could do, i will post in the following lines.
Code:
list  p=16f877
include <p16f877.inc>

__CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _LVP_OFF


c1 	equ 0x21;
c2	equ 0x22;
c3  equ 0x23;
c4	equ 0x24;

s1 	equ 0x25;
s2	equ 0x26;
s3  equ 0x27;

    org   0x00;
    goto  start; skip over interrupt vector
    org   0x04;
    goto  serviceinterrupts;

start
    call  clearall; 
    call  initports;
    call  inittimer;
    call  ini_adc;
    bsf   INTCON, GIE;
    bsf   INTCON, T0IE;
	
loop 

	call ADC;
	call B_BCD;

	movf s1,0;
    call sevensegment;
	movwf PORTB;   

	movf s2,0;
	call sevensegment;
	movwf PORTC;
	
	movf s3,0;
	call sevensegment;
	movwf PORTD;


;	call delay;

   	goto loop;

sevensegment

	addwf   PCL, 1;   Add the value of 'W' with PCL(Program Counter Logic) itself & keep result in PCL...
	retlw   .63;	  when the value of 'W' is  0
	retlw   .6; 	  when the value of 'W' is  1
	retlw   .91;	  when the value of 'W' is  2
	retlw   .79;	  when the value of 'W' is  3
	retlw   .102;     when the value of 'W' is  4
	retlw   .109;     when the value of 'W' is  5
	retlw   .125;     when the value of 'W' is  6
	retlw   .7; 	  when the value of 'W' is  7
	retlw   .127;     when the value of 'W' is  8
	retlw   .111;     when the value of 'W' is  9
retfie

ADC
	bsf ADCON0, 0; ADON: A/D On bit. 1 = 0n, 0 = OFF
	bsf ADCON0, 2; GO/DONE: A/D Conversion Status bit. 1 = conversion in progress, 0 = conversion not in progress

	; CHS2:CHS0: Analog Channel Select bits [111 = Channel 7 (AN7)]
	bsf ADCON0, 3; CHS0 = 1
	bsf ADCON0, 4; CHS1 = 1
;	bsf ADCON0, 5; CHS2 = 1

polling 
	btfsc ADCON0,2; Checking for A/D Conversion Status bit. If ADCON0 = 1, loop continues. If ADCON0 = 0, skips "goto polling"
goto polling;
	
	movf ADRESH,0;
	movwf c3;
	return;

B_BCD
	clrf s1;
	clrf s2;
	clrf s3;
	
loop1
	movlw .100;
	subwf c3,0;
	btfss STATUS,C;
	goto loop2;
	incf s3,1;
	movwf c3;
	goto loop1;

loop2
	movlw .10;
	subwf c3,0;
	btfss STATUS,C;
	goto last;
	incf s2,1;
	movwf c3;
	goto loop2;
last
	movf c3,0;
	movwf s1;
	return;   
	

clearall
	clrf ADCON0;
	clrf STATUS; 	
	clrf c1;
	clrf c2;
	clrf c3;
  	return;

initports
 
 	bsf     STATUS, RP0; 
 	movlw   b'00000000'; 
 	movwf   TRISB ; 
 	movwf   TRISC;
	movwf   TRISD;       
 	bcf     STATUS, RP0;   
	return;
 
inittimer
    clrf    TMR0;
    bsf     STATUS, RP0;
    movlw   b'00000011';
    movwf   OPTION_REG;
    bcf     STATUS, RP0;
    return;

ini_adc;

	bsf STATUS,RP0;
	movlw 0x00;
	movwf ADCON1;
	bcf STATUS,RP0;
    return;

serviceinterrupts
  	bcf INTCON, T0IF;
  	movlw  .5;
 	movwf  TMR0;
  	incf c1,1;
  	retfie; return from subroutine
 
delay
	clrf c1	;for delay
repeat
	movf c1,0;
	xorlw .25;
	btfss STATUS,Z;
goto repeat
	return;
	
end
Untitled.jpg

Now it will be very helpful if some can guide me,
to what i should do next.
 

I had asked about using US sensor for water (liquid) level detecting but the US sensor manufacturer said it can't be used for level sensing. May be the liquid doesn't reflect the US waves.
 

**broken link removed**
The above website sells a device which will reflect ultrasound from the surface of the water.
I know this because, upon commenting on a particular post, the admin replied.
Check the comments in the following link.
**broken link removed**
 

Prosenjit101,


What is the distance range you intend to measure ?


+++
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top