877A & 16 Inputs to be monitored


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2009
    Location
    London
    Posts
    251

    Default 877A & 16 Inputs to be monitored

    I have one 877A and I would like to monitor 16 inputs (or more if possible) which I cannot do it by continues monitoring the inputs to go low/high as PIC has to do some other stuff in the main routine.
    Although I can use some PortB pins as they have interrupt on change BUT I do not want to use programming pins as inputs as I want to leave them for ICSP which leaves me with very few pins with 'change on interrupt'.

    So, is there any other IC/technique which I can implement in this case which can help me to monitor many inputs using 1 interrupt or something like that.

  2. #2
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: 877A & 16 Inputs to be monitored

    I never had the opportunity to use this device but saved the info for future use: MCP23017 16 bit I/O expander
    May work for you.
    Louie

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: 877A & 16 Inputs to be monitored

    You can use ON DEBUG to "Poll" every pin on the chip, which acts a lot like ON INTERRUPT.
    Between each line of PBP code, it will jump to the debug routine which checks all the pins to see if anything has changed.

    This demo program monitors the 16-pins on PORTB and PORTC, and transfers them to PORTD, PORTA and PORTE.
    The main loop continues blinking PORTE.2 (green LED) while it "Polls" the pins.

    Click image for larger version

    Click image for larger version

    Code:
    DEBUG_ADDRESS   var     word bank0 system       ' Program address
    ThisPORTB  VAR BYTE
    ThisPORTC  VAR BYTE
    LastPORTB  VAR BYTE
    LastPORTC  VAR BYTE
    PauseCount VAR WORD
    IOCW       VAR WORD
    
    ADCON1 = 7
    CMCON = 7
    PORTD = 0       
    TRISD = 0
    PORTA = 0
    TRISA = 0
    PORTE = 0
    TRISE = 0
    
    ;--------------------------------------------------------------------------------------------
    ON DEBUG GOTO Monitor16
    
    Main:
        HIGH PORTE.2
        GOSUB PAUSE500
        LOW  PORTE.2
        GOSUB PAUSE500
    GOTO Main
    
    PAUSE500:
        FOR PauseCount = 1 to 500
            PAUSEUS 980
        NEXT PauseCount
    RETURN
    
    DISABLE DEBUG
    ;--------------------------------------------------------------------------------------------
    
    Monitor16:
        ThisPORTB = PORTB
        ThisPORTC = PORTC
        IF ThisPORTB != LastPORTB THEN
            LastPORTB = ThisPORTB
            PORTD = ~ThisPORTB
        ENDIF
        IF ThisPORTC != LastPORTc THEN
            LastPORTC = ThisPORTC
            PORTA = ~ThisPORTC
            PORTE = ~(ThisPORTC >> 6)
        ENDIF
    
    exitdebug:
    ' End of debug routine - go back to main program
      asm
            movf    DEBUG_ADDRESS + 1, W    ; Set PCLATH with top byte of return address
            movwf   PCLATH
            movf    DEBUG_ADDRESS, W        ; Go back to main program
            movwf   PCL
      endasm
    DT

  4. #4
    Join Date
    Nov 2009
    Location
    London
    Posts
    251


    Did you find this post helpful? Yes | No

    Default Re: 877A & 16 Inputs to be monitored

    Thanks for the info. The On DEBUG seems very useful but will it work if I am DEBUGIN for 5 seconds in the main loop. I am trying to make a security system SMS based in which the 877A keeps checking the arrival of a text message in the main loop by polling the GSM module every few seconds and waits for an "OK" or other message from the module and does allow 5 second for the GSM module to respond.

    Code:
    				
    main: 
    DEBUG "AT+CMGR=",DEC c,13,10
    DEBUGIN 5000,main,[WAIT("+"),STR code\5\13, SKIP 15,STR num\13\13, SKIP 27,STR sms\25\13]
    .
    .
    .
    .
    .

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: 877A & 16 Inputs to be monitored

    No, of course not.
    But your request didn't say anything about 5 second SERIN commands.

    If you use the 16F877a's USART, then it doesn't have to sit there twiddling it's thumbs waiting for data to come in.
    And can continue on monitoring the inputs.

    Answers can only be as complete as the request made for it.
    DT

Similar Threads

  1. 877a and SPI
    By tico in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 14th April 2007, 02:57
  2. 877A AtoD config problem?
    By ttease in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st April 2007, 16:57
  3. Use the PIC 16f877 or 877A instead of shift registers.
    By tsanders in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th October 2006, 17:23
  4. dip switchs & inputs
    By grounded in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 19th September 2006, 13:37
  5. PicBasic Pro Compiler for 877A
    By iwill920ya in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 31st May 2004, 04:10

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