Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

irrigation control system

Status
Not open for further replies.

frankly

New Member
hi every one
i am doing a finall project
my project consiste of temperature sensor and soil sensor ,lcd and wter valve.
the soil sensor connected to comprater then to the micro 8051.
the temp sensor connected to a non inverting amp and then to the 8051.
the project should work as follows: at a certen time the the water valve will open and it will stay open untel the soil sensor get wet and then it will check for the temp range for example if 45 mintes it will keep the valve open for 5 mintes extra and so on and then it will close the valve and wait for the next time to start watering.

the question is i need to make a circuit to the water valve and program ON and OFF and i added two sitches to set the time by the way i am using assimbly language


sorry for the long story but i thought it is good to understand what is going on and thanks.
 
this is the program that i used in my project






.equ en,p1.5
.equ rs,p1.3
.equ rw,p1.4
.equ lcdport,p2
.equ adport,p0
.equ rd,p1.0
.equ wr,p1.1
.equ intr,p1.2
.equ msec,5fh
.equ sec,5eh
.equ min,5dh
.equ hrs,5ch

ajmp start
.org 0bh
push acc
mov a,msec
inc a
mov msec,a
cjne a,#20,halas
mov msec,#0
mov a,sec
inc a
mov sec,a
cjne a,#60,halas
mov sec,#0
mov a,min
inc a
mov min,a
cjne a,#60,halas
mov min,#0
mov a,hrs
inc a
mov hrs,a
cjne a,#24,halas
mov hrs,#0

halas: mov th0,#3ch
mov tl0,#0b0h
pop acc
reti

start: mov sp,#5fh
mov msec,#0
mov sec,#0
mov min,#0
mov hrs,#0
mov tmod,#00000001b
mov th0,#3ch
mov tl0,#0b0h
mov ie, #10000010b
setb tr0
clr en
clr rw
;init LCD
clr rs
mov dptr,#initxt
init: clr a
movc a,@a+dptr
jz nxt
acall commwrt
inc dptr
acall dlay
sjmp init
nxt: mov dptr,#testtxt
acall txt_LCD
next: clr rs
mov a,#11000000b
acall commwrt
mov dptr,#testtxt2
acall txt_LCD

acall adconv
acall showhex
mov a,#'H'
acall write_LCD
mov a,#' '
acall write_LCD
acall showtime

stop: sjmp next

adconv: clr wr
setb wr
neoc: jb intr,neoc
clr rd
mov a,adport
setb rd
ret

showtime:
mov a,hrs
acall showdec
mov a,#':'
 
acall write_LCD
acall showtime

stop: sjmp next

adconv: clr wr
setb wr
neoc: jb intr,neoc
clr rd
mov a,adport
setb rd
ret

showtime:
mov a,hrs
acall showdec
mov a,#':'
acall write_LCD
mov a,min
acall showdec
mov a,#':'
acall write_LCD
mov a,sec
showdec:
mov b,#10
div ab
add a,#30h
acall write_LCD
mov a,b
add a,#30h
sjmp write_LCD

showhex:
push acc
anl a,#11110000b
rr a
rr a
rr a
rr a
mov dptr,#hextab
movc a,@a+dptr
acall write_LCD
pop acc
anl a,#00001111b
mov dptr,#hextab
movc a,@a+dptr

write_LCD:
setb rs
commwrt:
mov lcdport,A
setb en
clr en
wait_LCD:
clr en
clr rs
setb rw
mov lcdport,#0ffh
setb en
mov a,lcdport
jb acc.7,wait_LCD
clr en
clr rw
ret

txt_LCD:
clr a
movc a,@a+dptr
jz exit
acall write_LCD
inc dptr
sjmp txt_LCD
exit: ret

dlay: mov r5,#5
dd3: mov r6,#100
dd2: mov r7,#100
dd1: djnz r7,dd1
djnz r6,dd2
djnz r5,dd3
ret

testtxt:
.db "Hello frankly!",0

testtxt2:
.db "A/D:",0

initxt: .db 30h,30h,30h,38h,0ch,1,06h,0

hextab: .db "01234567"
.db "89ABCDEF"
 
Hi,
Which soil sensor did you use? i am a 3rd year student and have taken up 'irrigation control' as my project.
which water control valve did you use? please help.
 
Why don't you post your code like this all it take is
Code:
[code] with / in front of last /code [/QUOTE]
[code] LIST p=16F876 ; pic your using
#include "P16F876.INC" ;  include

__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_OFF & _HS_OSC & _WRT_ENABLE_OFF & _LVP_OFF & _DEBUG_OFF & _CPD_OFF 


;************************************************* ****************************;
; RESET ;
;************************************************* ****************************

 org 0x00 ;  reset
 goto init ; goto initialization


;************************************************* ****************************;
; INITIALIZATION ;
;************************************************* ****************************;
init
	 banksel ADCON1			;disable analogue inputs
	 movlw 	0x06            ;load value to be put it trisa
	 movwf 	ADCON1
	 banksel TRISA        ; change to trisa
	 movlw b'11111111'    ;load value to be put it trisa
	 movwf TRISA          ; move to trisa
	 clrf PORTA           ; clear porta
	 banksel TRISB        ;change to trisb
	 movlw b'00000000'    ;load value to be put it trisb
	 movwf TRISB          ; move to trisb 
	 CLRF PORTB           ;clear portb
   goto main              ; goto start of program
;;;;;;;;;;;;;;;;;;;;;;;; turn on leds some portb ;;;;;;;;;;;;

main                 ; start of program
	bsf PORTB,0		 ;turn on some leds
	bsf PORTB,1
	bsf PORTB,2
	bsf PORTB,3
 goto sw
sw
	btfsc PORTA,0     ; check some switches if pressed
	bcf PORTB,0       ; turn off a led 
	btfsc PORTA,1
	bcf PORTB,1
	btfsc PORTA,2
	bcf PORTB,2
  goto backon
backon
    btfsc PORTA,3      ; if set goto next line if not set goto sw
	goto main          ; if you get here the leds turn back on
	goto sw            ; go back to sw and keep checking the switches


 end
 
Last edited:
Why don't you post your code like this all it take is
What be80be is trying to say is this:

If you click on the # icon before pasting your code, or type [code] ahead of your code and [/code] after it, your code will look nice and properly formatted (provided it was that way to begin with) like this:

Code:
#include <system.h>
#pragma	CLOCK_FREQ	8000000
#pragma DATA    _CONFIG1H, _INTIO2_OSC_1H
#pragma DATA    _CONFIG2H, _WDT_OFF_2H
#pragma DATA    _CONFIG3H, _MCLRE_ON_3H
#pragma DATA    _CONFIG4L, _LVP_OFF_4L

void main()
{
    osccon = 0x72;          //set int osc to 8MHz
    adcon1 = 0b01111111;    //all digital
    trisa = 0;              //set data directions
    trisb = 0b00010000;

    while(1){
        latb.RB1 = 1;
        delay_s(1);
        latb.RB1 = 0;
        delay_s(1);
    }
}

instead of looking like this unreadable mess:

#include <system.h>
#pragma CLOCK_FREQ 8000000
#pragma DATA _CONFIG1H, _INTIO2_OSC_1H
#pragma DATA _CONFIG2H, _WDT_OFF_2H
#pragma DATA _CONFIG3H, _MCLRE_ON_3H
#pragma DATA _CONFIG4L, _LVP_OFF_4L

void main()
{
osccon = 0x72; //set int osc to 8MHz
adcon1 = 0b01111111; //all digital
trisa = 0; //set data directions
trisb = 0b00010000;

while(1){
latb.RB1 = 1;
delay_s(1);
latb.RB1 = 0;
delay_s(1);
}
}
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top