Site hosted by Angelfire.com: Build your free website today!

Power Line Appliance Controller

Software

      Program     

The program, written in Assembly Language, is a menu (interactive) driven program, executed on the computer, which allows the user to choose between three (3) appliances, to turn them on/off. The user has the option to be in this program or use his/her computer for other application programs at the same time i.e. the application program (s) can be running in the background while the user turns on/off an appliance (s) or the program can be running in the background whilst the user is using word processor or excel etc.

The user chooses an appliance at a time by pressing a specific key. One key is used to turn the appliance both on and off. When the key is pressed a sub-program tests for a key press. Once a key has been pressed, the program now compares the specific key pressed to the key options for the menu. If an option key is pressed, the signal is then transferred to the extended parallel port of the computer. After this, the menu screen is displayed again, so that the user can further turn on/off more appliances or the same appliance.

 

 However, it is advised to give a delay time between options, so that signals would not be corrupted and may lead to the toggling of appliances on/off.

 

See Figure 3 - Flow Chart for the Menu Driven Program.

See the Assembly Language Menu Driven Program attached.

Figure 3 - Flow Chart for Menu Driven Program

 

Assembly Language Menu Driven Program

 PAGE 46,132 

TITLE  Program.asm

;This program is used to controll the multiplexer in the Power Line Appliance Controller

sseg      SEGMENT                  STACK  ;establish a stack segment

                        DW  256 DUP (?)        ;this will create a 256 word stack

sseg      ENDS

 dseg     SEGMENT                              ;establish data segment

                menu db "Power Line Appliance Controller",0Ah,0Dh,"$"

                menu1 db "Press 1 --> Fan on<>off",0Ah,0Dh,"$"

                menu2 db "Press 2 --> CD Player on<>off",0Ah,0Dh,"$"

                menu3 db "Press 3 --> Kitchen Lights on<>off",0Ah,0Dh,"$"

                menu4 db "Press Esc --> Exit from this menu",0Ah,0Dh,"$"

                messfan db "Fan",0Ah,0Dh,"$"

                messcd db "CD Player",0Ah,0Dh,"$"

                messlights db "Kitchen Lights",0Ah,0Dh,"$"

                message1 db "No Key Pressed",0Ah,0Dh, "$"

dseg     ENDS

 cseg     SEGMENT

                        ASSUME  ss:sseg,ds:dseg,cs:cseg

             start:     mov ax,dseg                        ;initialize data segment

                        mov ds,ax           

              top:    call clrscn                             ;clears the screen

                        lea dx, menu                        ;the following lines of code

                        call display                           ;displays the

                        lea dx, menu1                      ;lines of the menu

                        call display

                        lea dx, menu2

                        call display

                        lea dx, menu3

                        call display

                        lea dx, menu4

                        call display

        delay1:    call delay

                        call if_key                            ;checks to see if a key was pressed

                        mov bl, al                             ;save a copy of the key pressed

                        mov al, bl                             ;retrieves the copy of key pressed

                        cmp al, 31h                          ;test to see if key pressed was 1

                        je fan                                    ;if key was 1 go to fan

                        mov al, bl                              ;retrieves the copy of key pressed

                        cmp al, 32h                          ;test to see if key pressed was 2

                        je cd                                 ;if key was 2 go to cd

                        mov al, bl                         ;retrieves the copy of key pressed

                        cmp al, 33h                      ;test to see if key pressed was 3

                        je lights                             ;if key was 3 go to lights

                        mov al, bl                         ;retrieves the copy of key pressed

                        cmp al, 1bh                      ;test to see if key pressed was Esc

                        je exit                               ;if key was Esc go to exit

                        mov al, bl

                        cmp al, 0h                        ;if al=0, no key was pressed

                        jmp top

              fan:    lea dx, messfan    

                        call display                    ;sends out a message to say that the fan was selected

                        mov al, 1h                    ;sets pins A=0, B=1, G'=lo

                        call out                          ;sends 01 out via the parallel port

                        call delay                       ;gives a small delay

                        mov al, 0h

                        call out

            call delay

                        jmp top

              cd:     lea dx, messcd

            call display                    ;sends out a message to say that the CD Player was selected

                        mov al, 2h                        ;sets pins A=1, B=0, G'=lo

                        call out                             ;sends 10 out via the parallel port

                        call delay                          ;gives a small delay

                        mov al, 0h

                        call out

            call delay

                        jmp top

          lights:    lea dx, messlights

                        call display        ;sends out a message to say that the Kitchen Lights were selected

                         mov al, 3h                    ;sets pins A=1, B=1, G'=lo

                        call out                         ;sends 11 out via the parallel port

                        call delay     

                        mov al, 0h

                        call out

            call delay

                        jmp top

              exit:   mov ax,4c00h            ;return to DOS! (bye-bye)

                        int 21h

  

;clears the screen

        clrscn          proc

                mov ax, 02h                  ;option 2 for bios int 10

                int 10h

                ret

        clrscn          end

  

 ;display a string to screen

        display         proc               ;dx holds beginning offset of string

                mov ah, 09h              ;option 9 of bios service int 21

                int 21h                       ;invoke int 21

                ret

        display         endp

  

 ;tests to see if a key was pressed

        if_key          proc

                mov ah, 01h

                int 16h

                jz no_char

                mov ah, 0h

                int 16h

                ret

         no_char: mov ax, 0h

                  ret

        if_key          endp

 

        ;gives a three seconds delay

        delay            proc

                mov ah, 86h              ;function for delay

                mov cx, 002dh           ;delay for 3 seconds or 3000000us

                mov dx, 0c6c0h

                int 15h                         ;invoke int 15

                ret

        delay           endp

 

            out                   proc

                        mov dx, 378h

                        out dx, al

           out                   endp

             cseg     ENDS

                        END start

Progress Report                            Proposal

PROJ - 379; PROJ - 350

                      

Back        Home        Next