How to use Analog interrupt in 16f72


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2008
    Posts
    22

    Default How to use Analog interrupt in 16f72

    Hi,



    I am interested to connect main power supply to RA0(16f72),for that i have plan to set analog interrupt to know the main present ,Can anyone help me how to enable analog interrupt.



    I thought PIE1 is used for that.Plz explain me how to use intr.



    waiting for reply.



    -Raja.

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    Raja,

    You're not being very clear on why you need the mains to connect to the PIC. Is it to just detect presence of mains, or is it for timing the zero crossing?

    In the first case, you simply convert the mains to a low voltage DC and read it digitally or via the ADC.

    In the second case, a simple half wave rectifier followed by a voltage divider will let you catch the zero crossings.

    Good luck

  3. #3
    Join Date
    Aug 2008
    Posts
    22


    Did you find this post helpful? Yes | No

    Default

    Hi jerson,

    Thanks for ur response.I am designin UPS control operation using 16f72.my confusion is how to know whether main is present or not.

    1.If main is present,operation continues with main power
    2.if not inverter should continue the task.

    here power failure indication is one i/p to PIC.so,i am thinkin to connect it to RB0/INT.so that i can start inverter.in case of power resumption,i should start the main with some delay,
    i used the intr routine like,

    ;power failure condition
    ;RB0/INT vector
    org 0x04
    btfsc INTCON,INTF ;in case power failure i/p is 0,start main.
    goto inverter_start
    goto start_main

    Plz give ur suggestion.

    I have another doubt.I used LCD display to display the character,
    i used the code like

    movlw "U"
    call disp
    movlw "P"
    call disp
    movlw "S"
    call disp


    If i use like this will increase the memory.i want to save the memory,so instead of these,can i use DB or DT

    like
    dt "UPS"
    call disp


    -Regards,
    Raja.
    Last edited by kvrajasekar; - 2nd September 2008 at 06:46.

  4. #4
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    The first technique of providing a DC level to the PIC to indicate mains present should suffice in your case. However, I do not see the need for it to interrupt the code.

    Secondly, you seem to be coding totally in assembler. So, I think this thread should be in the Off Topic section of the forum.

    The technique of declaring the string in a readable fashion makes more programming sense as it is easier to spot while modifying your code later and will be more compact in flash and execution time too.

    Good luck

  5. #5
    Join Date
    Aug 2008
    Posts
    22


    Did you find this post helpful? Yes | No

    Default

    Thanks,
    I am using ASM code.

    but while passing the string like

    dt "UPS"

    needs any change in the program?
    or
    it is just the substitute of seperate character.plz clear me.
    lcd_init

    movlw 0x28 ; 4 bit, 2 Line, 5x7 font
    call disp_cmd
    call delay
    movlw 0x10 ; display shift off
    call disp_cmd
    call delay
    movlw 0x01 ; Clear the Display RAM
    call disp_cmd
    call delay ; Note, Can take up to 4.1 msecs
    movlw 0x06 ; increment cursor
    call disp_cmd
    call delay
    movlw 0x02 ; move the cursor to begining
    call disp_cmd
    call delay
    movlw 0x0C ; display on cursor off
    call disp_cmd
    call delay
    return

    ;Display command for 4 bit LCD

    disp_cmd ; Send the Instruction to the LCD
    movwf Temp ; Save the Temporary Value
    swapf Temp, w ; Send the High Nybble
    bcf LCD_RS ; RS = 0
    call nibbleout
    movf Temp, w ; Send the Low Nybble
    bcf LCD_RS
    call nibbleout
    return
    ;------------------------------------------------------------------------------------
    ;sending ASCII character to LCD
    disp_write
    addlw '0' ; Send nbr as ASCII character ; Send the Character to the LCD
    movwf Temp ; Save the Temporary Value
    swapf Temp, w ; Send the High Nybble
    bsf LCD_RS ; RS = 1
    call nibbleout
    movf Temp, w ; Send the Low Nybble
    bsf LCD_RS
    call nibbleout
    return
    ;sending lower and upper nibble
    nibbleout
    movwf PORTB
    bsf LCD_E
    bcf LCD_E
    nop
    nop
    return
    movlw 'UPS' ;displayin the string on LCD
    call disp_write

    can i write like this?plz reply me.

    -Raja.
    Last edited by kvrajasekar; - 2nd September 2008 at 13:09.

Similar Threads

  1. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  2. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  3. Help with Analog Interrupt
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 18:14
  4. NEWBIE: Some basic questions using interrupts
    By JackPollack in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2006, 02:59
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts