Abhi Mup Final

35
  Prepared by- Group No:76 Abhijith Asok   2010B4A3562G Sunit Singh   2010B4A3585G Jill Atul Sh ah  2010B4A3597G Akshay Prakash Kadam   2010B1A8673G

description

microprocessor project on ram tester

Transcript of Abhi Mup Final

  • Prepared by-

    Group No:76

    Abhijith Asok 2010B4A3562G

    Sunit Singh 2010B4A3585G

    Jill Atul Shah 2010B4A3597G

    Akshay Prakash Kadam 2010B1A8673G

  • ACKNOWLEDGEMENT S

    We would like to thank Dr. K.R.Anupama, our Instructor-in-charge for this course, ESC263-

    Microprocessor Programming and Interfacing for giving us this opportunity to do this design

    assignment which has helped us in making our concepts clearer. We would also like to thank

    the faculty under this course for guiding us along always. Finally we would also like to thank

    our seniors and friends who have helped us in this endeavour.

  • The System Design-Lawn Sprinkler P 26: System to be designed- Lawn Sprinkler System An average sized garden has 8 sprinklers that have to be turned on and off. A series of 16 moisture sensors are placed at different placed at different parts of the garden. The sprinkler system works twice a day. Once at 11:00 am and then at 6:00 PM. The sprinkler is turned on and off based on the time of the day and the soil moisture. The time of the day and the soil of the moisture . The time for which the sprinkler remains on depends upon the difference between required soil moisture and actual soil moisture level. Garden Setup The garden is divided into 8 circular or partially-circular regions, with the sprinkler at the centre of each(depicted by black solid circles). Each region also has 2 moisture sensors, depicted by grey boxes. The circular regions in light gray, are the regions covered by each sprinkler. The sensors are connected to 8255s as input; one sensor from each patch per 8255. The input values are averaged and compared against a fixed moisture value(assumed to be 25%). If the average goes below this standard value, the particular sprinkler is switched on, till the average rises above 25%.

  • Assumptions:

    1. The process is initiated at 11:00 a.m. for the first time.

    2. There exists an uninterrupted supply of water, without the application of any external power for the purpose.

    3. The power supply for the entire circuitry is not subject to any failure or blackout.

    4. The overlapping between the two patches does not cause over-watering.

    5. The white patches, not covered by any sprinkler, are either ignored or subjected to manual watering as per requirement.

    6. In case, the average comes above the standard moisture level, with the reading of one sensor very high and

    that of the other sensor very low, the sprinkler wont be started, but it is assumed that the dry patch is not subject to any harm, for the next 7 or 17 hours, as per the time of the day.

  • Hardware under use

    Microprocessor chip set

    1. 8086

    2. 8255

  • 3. 8253

    4. 8259

  • Other Main Circuitry Hardware

    5. Analog to Digital Converter : ADC0808

    6. Octal Bidirectional Buffer LS245

  • 7. Octal Latch LS373

    8. 3 to 8 Decoder LS138

  • 9. RAM chips SRAM 6116: SRAM 6116 is a 2kb RAM chip. 2 such chips are used one for even and odd memory.

    Memory map: 01000 -01FFFH

    10. ROM chips

    EPROM 2716: EPROM 2716 is a 2kb ROM chip 2 such chips are used,one for even and one for odd memory . Memory map : 00000 00FFFH (foldback )FF000 FFFFFH

    External Circuitry

    11. SM150 Sceintific soil moisture sensor

  • 12. Garden irrigation valve Manufacturer:XIANGJUN Model no: FSK-2

    Rated voltage: AC220V, AC110V, AC24V, AC12V, DC110V, DC24V, DC12V, DC9V; Low pressure valve

    13. Sprinkler system (Jain Irrigation Systems)

    POP2QC- 4 nozzles, POP2HC- 2 nozzles, POP2FC-2 Nozzles 1.5kg per square cm for the first 6 nozzles and 1kg per square cm for the full circle nozzles. The area of the plot=[2x8.2]x[4x8.2]= 537.92ft2 {Calculated on the basis of available sprinklers}

  • Algorithm Initializations: 8255 no:1

    Connect 1 sensor from each patch to respective input channel

    Assign addresses to port A, port B, Port C and Control Register.

    Set Group A as the input and Group B as the output.

    8255 no:2

    Connect the other sensor from each patch to respective input channel

    Assign addresses to port A and Control Register(Port B is not used in this 8255 for output because of the less

    number of outputs,i.e. sprinklers, compared to the number of lines available in both 8255s combined)

    Set Group A as the input.

    8253s

    Address assigning is done to the chip.

    The mode of each counter is set by selecting A0A1 as 11.

    At each address of count for the counter, the 3 counts are loaded.

    Mode 2 is selected for each clock (rate generator)

    Gates are enabled at 11:00 AM to begin the clock

    Global Variables

    Hour keep track of the number of hours passed.(initially 0)

    Eoc1 keep track of the end of conversion from analog to digital signal at the first ADC0808(initially 1)

    Eoc2 keep track of the end of conversion from analog to digital signal at the second ADC0808(initially 1) Run choose between 11:00 a.m. and 6:00 p.m.(initially 0)

    Spr keeps track of the on and off positions of all 8 sprinklers(initially 00000000b) Condition checking If run=0, Check for 6:00 p.m. If yes, make run=1, hour=0, call the procedure Sprinkle. If run=1, Check for 11:00 a.m. If yes, make run=0, hour=0, call the procedure Sprinkle. SPRINKLE

    Give creg byte to read from which sensor. (check here for EOC1 )Read the value from port A and store to an array at 1P(n).

    (check here for EOC2)Do this to read from the other 8255 and store to 2P(n).

    Take average of the two values and compare it against a fixed value corresponding to 25% humidity. As per the value and sensor no, change spr

    Do this for all the sensors, changing AD0,AD1 and AD2 of the ADC by using bit set reset of the 8255s

    Load the value of spr into the output B port of 8255 no:1 Do while spr!=00000000b Call the procedure WATER till the above condition( This waters the lawn till it reaches the required moisture level)

  • Interrupt creation and handling

    As per the generated vector no.s find the addresses in the IVT

    Make the Interrupt service routines for the 3 interrupts

    For INT hour wise coming from the clk increment the value of hour till =7(if run =0) OR till hour=17 (if run =1)

    For ADC 1 taking EOC as interrupt set EOC1 as zero

    For ADC 2 taking EOC as interrupt set EOC2 as zero

  • ALP Org ffff0h mov ax, 0 mov ds, ax mov ss, ax mov ax, 0fff mov sp, ax

    Jmp 20000h Org 20000h ;Set of Initializations ;Viable and port Initializations count0 equ 18h count1 equ 1ah count2 equ 1ch porta1 equ 00h portb equ 02h porta2 equ 08h creg equ 1eh creg1 equ 06h creg2 equ 0eh creg3 equ 10h count001 equ 12h hour equ 7 mov si,20000h mov dl,hour mov [si],dl run equ 0 mov si,20001h mov dl,run mov [si],dl eoc1 equ 1h mov si,20002h mov dl,eoc1 mov [si],dl eoc2 equ 1h mov si,20003h mov dl,eoc2 mov [si],dl spr equ 00000000b mov si,20004h mov dl,spr mov [si],dl mov cx,8 1p equ ?

  • mov si,20005h x1:mov dx,1p mov [si],dl inc si loop x1 2p equ ? mov si,2000Dh x2:mov dl,2p mov [si],dl inc si loop x2 v1 equ ? mov si,20016h mov dl,v1 mov [si],dl v2 equ ? mov si,20017h mov dl,v2 mov [si],dl result equ 1h mov si,20018h mov dl,result mov [si],dl src equ 2 mov si,20019h mov dl,src mov [si],dl ;Microprocessor chip Initializations ;Counter Initializations and count values for 8253 no:1 mov al,00110100b out creg,al mov al,01110100b out creg,al mov al,10010100b out creg,al mov al,b4h out count0,al mov al,5fh out count0,al

  • mov al,a0h out count1,al mov al,8ch out count1,al mov al,0ah out count2,al ; Counter Initializations and count values for 8253 no:2 mov al,00010100b out creg3,al mov al,03h out count001,al ;Initialization of 8255 no:1 mov al,10010000b out creg1,al ;Initialization of 8255 no:2 mov al,10010000b out creg2,al ;Core logic Runsix:cmp run,0 jnz Runeleven Six: cmp hour,7 ;Identifying 6:00 p.m.(We assumed the process starts at 11:00 a.m.) jne Eleven mov run,1 ;Setting the viable to identify the next 11:00 a.m. mov hour,0 call Sprinkle Runeleven:cmp run,1 Jnz Runsix Eleven: cmp hour,17 ;Identifying 11:00 a.m. jne Over mov run,0 ;Setting the viable to identify the next 6:00 a.m. mov hour,0 call Sprinkle Over: jmp Runsix ;End of core logic ; Finding the average of the moisture levels AVERAGE PROC NEAR add v1,v2 mov al,v1 mov ah,00 div src mov result,al ret AVERAGE PROC ENDP ;The procedure for the entire working of all the sprinklers SPRINKLE PROC NEAR

  • mov hour,0 ;Sprinkler 1 ;Bit Set Reset(BIT SET RESET(BSR)) for ale',soc',oe',ad0,ad1,ad2 for 8255 no:1 Delay1: mov al,0ch out creg1,al ;Reseting PC6 mov al,0ah out creg1,al ;Reseting PC5 mov al,08h out creg1,al ;Reseting PC4 ;Sensor 1 mov al,0h out creg1,al ;Reseting PC0 mov al,02h out creg1,al ;Reseting PC1 mov al,04h

  • out creg1,al ;Reseting PC2 cmp eoc1,0 ; Checking for End of Conversion of Analog Input to Digital at ADC 1 jnz Delay1 in al,porta1 ;Input reading from Sensor 1 lea si,1p mov [si],al ;Storing the input in memory ;Bit Set Reset(BSR) for ale',soc',oe',ad0,ad1,ad2 for 8255 no:2 Delay2: mov al,0ch out creg2,al ;Reseting PC6 mov al,0ah out creg2,al ;Reseting PC5 mov al,08h out creg2,al ;Reseting PC4 ;Sensor 2 mov al,0h out creg2,al ;Reseting PC0 mov al,02h out creg2,al ;Reseting PC1 mov al,04h out creg2,al ;Reseting PC2 cmp eoc2,0 ; Checking for End of Conversion of Analog Input to Digital at ADC 2 jnz Delay2 in al,porta2 ;Input reading from Sensor 2 lea di,2p mov [di],al ;Storing the input in memory mov v1,[si] mov v2,[di] inc di inc si call avg ;Computing average of the two sensors cmp result,19h ;Comparing resultult with the standard humidity jb Sprion1 jge Sprioff1 Sprion1: or spr,00000001b ;Switching on sprinkler 1 Jmp Over1 Sprioff1: and spr,1111110b ;Switching off sprinkler 1 Over1: ;Sprinkler 2 ;Bit Set Reset(BIT SET RESET(BSR)) for ale',soc',oe',ad0,ad1,ad2 for 8255 no:1 Delay3: mov al,0ch out creg1,al ;Reseting PC6 mov al,0ah

  • out creg1,al ;Reseting PC5 mov al,08h out creg1,al ;Reseting PC4 ;Sensor 1 mov al,0h out creg1,al ;Reseting PC0 mov al,02h out creg1,al ;Reseting PC1 mov al,04h

  • out creg1,al ;Reseting PC2 cmp eoc1,0 ; Checking for End of Conversion of Analog Input to Digital at ADC 1 jnz Delay3 in al,porta1 ;Input reading from Sensor 1 lea si,1p mov [si],al ;Storing the input in memory ;Bit Set Reset(BSR) for ale',soc',oe',ad0,ad1,ad2 for 8255 no:2 Delay4: mov al,0ch out creg2,al ;Reseting PC6 mov al,0ah out creg2,al ;Reseting PC5 mov al,08h out creg2,al ;Reseting PC4 ;Sensor 2 mov al,0h out creg2,al ;Reseting PC0 mov al,02h out creg2,al ;Reseting PC1 mov al,04h out creg2,al ;Reseting PC2 cmp eoc2,0 ; Checking for End of Conversion of Analog Input to Digital at ADC 2 jnz Delay4 in al,porta2 ;Input reading from Sensor 2 lea di,2p mov [di],al ;Storing the input in memory mov v1,[si] mov v2,[di] inc di inc si call avg ;Computing average of the two sensors cmp result,19h ;Comparing resultult with the standard humidity jb Sprion2 jge Sprioff2 Sprion2: or spr,00000010b ;Switching on sprinkler 2 Jmp Over2 Sprioff2: and spr,1111101b ;Switching off sprinkler 2 Over2: ;Sprinkler 3 ;Bit Set Reset(BIT SET RESET(BSR)) for ale',soc',oe',ad0,ad1,ad2 for 8255 no:1 Delay5: mov al,0ch out creg1,al ;Reseting PC6 mov al,0ah

  • out creg1,al ;Reseting PC5 mov al,08h out creg1,al ;Reseting PC4 ;Sensor 1 mov al,0h out creg1,al ;Reseting PC0 mov al,02h out creg1,al ;Reseting PC1 mov al,04h

  • out creg1,al ;Reseting PC2 cmp eoc1,0 ; Checking for End of Conversion of Analog Input to Digital at ADC 1 jnz Delay5 in al,porta1 ;Input reading from Sensor 1 lea si,1p mov [si],al ;Storing the input in memory ;Bit Set Reset(BSR) for ale',soc',oe',ad0,ad1,ad2 for 8255 no:2 Delay6: mov al,0ch out creg2,al ;Reseting PC6 mov al,0ah out creg2,al ;Reseting PC5 mov al,08h out creg2,al ;Reseting PC4 ;Sensor 2 mov al,0h out creg2,al ;Reseting PC0 mov al,02h out creg2,al ;Reseting PC1 mov al,04h out creg2,al ;Reseting PC2 cmp eoc2,0 ; Checking for End of Conversion of Analog Input to Digital at ADC 2 jnz Delay6 in al,porta2 ;Input reading from Sensor 2 lea di,2p mov [di],al ;Storing the input in memory mov v1,[si] mov v2,[di] inc di inc si call avg ;Computing average of the two sensors cmp result,19h ;Comparing resultult with the standard humidity jb Sprion3 jge Sprioff3 Sprion3: or spr,00000100b ;Switching on sprinkler 3 Jmp Over3 Sprioff3: and spr,11111011b ;Switching off sprinkler 3 Over3: ;Sprinkler 4 ;Bit Set Reset(BIT SET RESET(BSR)) for ale',soc',oe',ad0,ad1,ad2 for 8255 no:1 Delay7: mov al,0ch out creg1,al ;Reseting PC6 mov al,0ah

  • out creg1,al ;Reseting PC5 mov al,08h out creg1,al ;Reseting PC4 ;Sensor 1 mov al,0h out creg1,al ;Reseting PC0 mov al,02h out creg1,al ;Reseting PC1 mov al,04h

  • out creg1,al ;Reseting PC2 cmp eoc1,0 ; Checking for End of Conversion of Analog Input to Digital at ADC 1 jnz Delay7 in al,porta1 ;Input reading from Sensor 1 lea si,1p mov [si],al ;Storing the input in memory ;Bit Set Reset(BSR) for ale',soc',oe',ad0,ad1,ad2 for 8255 no:2 Delay8: mov al,0ch out creg2,al ;Reseting PC6 mov al,0ah out creg2,al ;Reseting PC5 mov al,08h out creg2,al ;Reseting PC4 ;Sensor 2 mov al,0h out creg2,al ;Reseting PC0 mov al,02h out creg2,al ;Reseting PC1 mov al,04h out creg2,al ;Reseting PC2 cmp eoc2,0 ; Checking for End of Conversion of Analog Input to Digital at ADC 2 jnz Delay8 in al,porta2 ;Input reading from Sensor 2 lea di,2p mov [di],al ;Storing the input in memory mov v1,[si] mov v2,[di] inc di inc si call avg ;Computing average of the two sensors cmp result,19h ;Comparing resultult with the standard humidity jb Sprion4 jge Sprioff4 Sprion4: or spr,00001000b ;Switching on sprinkler 4 Jmp Over4 Sprioff4: and spr,11110111b ;Switching off sprinkler 4 Over4: ;Sprinkler 3 ;Bit Set Reset(BIT SET RESET(BSR)) for ale',soc',oe',ad0,ad1,ad2 for 8255 no:1 Delay9: mov al,0ch out creg1,al ;Reseting PC6 mov al,0ah

  • out creg1,al ;Reseting PC5 mov al,08h out creg1,al ;Reseting PC4 ;Sensor 1 mov al,0h out creg1,al ;Reseting PC0 mov al,02h out creg1,al ;Reseting PC1 mov al,04h

  • out creg1,al ;Reseting PC2 cmp eoc1,0 ; Checking for End of Conversion of Analog Input to Digital at ADC 1 jnz Delay9 in al,porta1 ;Input reading from Sensor 1 lea si,1p mov [si],al ;Storing the input in memory ;Bit Set Reset(BSR) for ale',soc',oe',ad0,ad1,ad2 for 8255 no:2 Delay10: mov al,0ch out creg2,al ;Reseting PC6 mov al,0ah out creg2,al ;Reseting PC5 mov al,08h out creg2,al ;Reseting PC4 ;Sensor 2 mov al,0h out creg2,al ;Reseting PC0 mov al,02h out creg2,al ;Reseting PC1 mov al,04h out creg2,al ;Reseting PC2 cmp eoc2,0 ; Checking for End of Conversion of Analog Input to Digital at ADC 2 jnz Delay10 in al,porta2 ;Input reading from Sensor 2 lea di,2p mov [di],al ;Storing the input in memory mov v1,[si] mov v2,[di] inc di inc si call avg ;Computing average of the two sensors cmp result,19h ;Comparing resultult with the standard humidity jb Sprion5 jge Sprioff5 Sprion5: or spr,00010000b ;Switching on sprinkler 5 Jmp Over5 Sprioff5: and spr,11101111b ;Switching off sprinkler 5 Over5: ;Sprinkler 6 ;Bit Set Reset(BIT SET RESET(BSR)) for ale',soc',oe',ad0,ad1,ad2 for 8255 no:1 Delay11: mov al,0ch out creg1,al ;Reseting PC6 mov al,0ah

  • out creg1,al ;Reseting PC5 mov al,08h out creg1,al ;Reseting PC4 ;Sensor 1 mov al,0h out creg1,al ;Reseting PC0 mov al,02h out creg1,al ;Reseting PC1 mov al,04h

  • out creg1,al ;Reseting PC2 cmp eoc1,0 ; Checking for End of Conversion of Analog Input to Digital at ADC 1 jnz Delay11 in al,porta1 ;Input reading from Sensor 1 lea si,1p mov [si],al ;Storing the input in memory ;Bit Set Reset(BSR) for ale',soc',oe',ad0,ad1,ad2 for 8255 no:2 Delay12: mov al,0ch out creg2,al ;Reseting PC6 mov al,0ah out creg2,al ;Reseting PC5 mov al,08h out creg2,al ;Reseting PC4 ;Sensor 2 mov al,0h out creg2,al ;Reseting PC0 mov al,02h out creg2,al ;Reseting PC1 mov al,04h out creg2,al ;Reseting PC2 cmp eoc2,0 ; Checking for End of Conversion of Analog Input to Digital at ADC 2 jnz Delay12 in al,porta2 ;Input reading from Sensor 2 lea di,2p mov [di],al ;Storing the input in memory mov v1,[si] mov v2,[di] inc di inc si call avg ;Computing average of the two sensors cmp result,19h ;Comparing resultult with the standard humidity jb Sprion6 jge Sprioff6 Sprion6: or spr,00100000b ;Switching on sprinkler 6 Jmp Over6 Sprioff6: and spr,11011111b ;Switching off sprinkler 6 Over6: ;Sprinkler 7 ;Bit Set Reset(BIT SET RESET(BSR)) for ale',soc',oe',ad0,ad1,ad2 for 8255 no:1 Delay13: mov al,0ch out creg1,al ;Reseting PC6 mov al,0ah

  • out creg1,al ;Reseting PC5 mov al,08h out creg1,al ;Reseting PC4 ;Sensor 1 mov al,0h out creg1,al ;Reseting PC0 mov al,02h out creg1,al ;Reseting PC1 mov al,04h

  • out creg1,al ;Reseting PC2 cmp eoc1,0 ; Checking for End of Conversion of Analog Input to Digital at ADC 1 jnz Delay13 in al,porta1 ;Input reading from Sensor 1 lea si,1p mov [si],al ;Storing the input in memory ;Bit Set Reset(BSR) for ale',soc',oe',ad0,ad1,ad2 for 8255 no:2 Delay14: mov al,0ch out creg2,al ;Reseting PC6 mov al,0ah out creg2,al ;Reseting PC5 mov al,08h out creg2,al ;Reseting PC4 ;Sensor 2 mov al,0h out creg2,al ;Reseting PC0 mov al,02h out creg2,al ;Reseting PC1 mov al,04h out creg2,al ;Reseting PC2 cmp eoc2,0 ; Checking for End of Conversion of Analog Input to Digital at ADC 2 jnz Delay14 in al,porta2 ;Input reading from Sensor 2 lea di,2p mov [di],al ;Storing the input in memory mov v1,[si] mov v2,[di] inc di inc si call avg ;Computing average of the two sensors cmp result,19h ;Comparing resultult with the standard humidity jb Sprion7 jge Sprioff7 Sprion7: or spr,01000000b ;Switching on sprinkler 7 Jmp Over7 Sprioff7: and spr,10111111b ;Switching off sprinkler 7 Over7: ;Sprinkler 8 ;Bit Set Reset(BIT SET RESET(BSR)) for ale',soc',oe',ad0,ad1,ad2 for 8255 no:1 Delay15: mov al,0ch out creg1,al ;Reseting PC6 mov al,0ah

  • out creg1,al ;Reseting PC5 mov al,08h out creg1,al ;Reseting PC4 ;Sensor 1 mov al,0h out creg1,al ;Reseting PC0 mov al,02h out creg1,al ;Reseting PC1 mov al,04h

  • out creg1,al ;Reseting PC2 cmp eoc1,0 ; Checking for End of Conversion of Analog Input to Digital at ADC 1 jnz Delay15 in al,porta1 ;Input reading from Sensor 1 lea si,1p mov [si],al ;Storing the input in memory ;Bit Set Reset(BSR) for ale',soc',oe',ad0,ad1,ad2 for 8255 no:2 Delay16: mov al,0ch out creg2,al ;Reseting PC6 mov al,0ah out creg2,al ;Reseting PC5 mov al,08h out creg2,al ;Reseting PC4 ;Sensor 2 mov al,0h out creg2,al ;Reseting PC0 mov al,02h out creg2,al ;Reseting PC1 mov al,04h out creg2,al ;Reseting PC2 cmp eoc2,0 ; Checking for End of Conversion of Analog Input to Digital at ADC 2 jnz Delay16 in al,porta2 ;Input reading from Sensor 2 lea di,2p mov [di],al ;Storing the input in memory mov v1,[si] mov v2,[di] inc di inc si call avg ;Computing average of the two sensors cmp result,19h ;Comparing resultult with the standard humidity jb Sprion8 jge Sprioff8 Sprion8: or spr,10000000b ;Switching on sprinkler 8 Jmp Over8 Sprioff8: and spr,01111111b ;Switching off sprinkler 8 Over8: ;All sprinklers set and reset according to moisture levels mov al,spr out portb,al ;Output of spr to output port B of an 8255 cmp spr,00000000b jnz again jmp finish

  • again: call Sprinkle finish: RET SPRINKLE PROC ENDP ;INTERRUPT HANDLING ;Interrupt Vector Table(IVT) Org 3f8h ; feh *4= 3f8h mov si,3f8h mov dl,00h mov [si],dl inc si mov [si],dl inc si mov [si],dl inc si mov dl,10h mov [si],dl Org 3f4h ; fdh *4= 3f4h mov si,3f4h mov dl,20h mov [si],dl inc si mov dl,00h mov [si],dl inc si mov [si],dl inc si mov dl,10h mov [si],dl Org 3ech ; fbh *4= 3ech mov si,3ech mov dl,40h mov [si],dl inc si mov dl,00h mov [si],dl inc si mov [si],dl inc si mov dl,10h mov [si],dl ;Interrupt Handling Codes Org 10000h Inc hour iret Org 10020h Mov eoc1,0 iret Org 10040h Mov eoc2,0 iret