problem RB4-7 on a 18F876A


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Posts
    72

    Default problem RB4-7 on a 18F876A

    hello all

    last year i had a problem on these inputs also. i had a keypad matrix with RB0-3 as outputs (with diode) and RB4-7 as inputs (external pull downs, no interrupts!). with a keypad with a cable of 20cm it ever works fine. later in the installation with a keypad cable of about 150cm, after a while the pic ever seems frozen in a state where he never came back. because i hadn't much time then i solved the problem when i changed the inputs RB4-7 to RC0-3 where the longer cabel never was a problem.
    some idea what that could be then?

    now, RB5-7 are inputs with internal pull up and interrupt. the pic-board is powered by a power supply. i have an old soldering iron. when i turn it out, i get some short noise over 230V back to the 5V of my pic. then an interrupt is initialised over my RB5-7 inputs. i solved it now with a 10ms delay in the begin of the interrput servide routine and asking RB5-7 back again before execute the code.
    but what could be the reason for this? that the pull up of RB5-7 are connected to 5V....

    sorry for this mystified characterisation and thanks for any ideas

  2. #2
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default If your VDD is not well decoupled

    Hi,

    It is a good practice to have the PIC powered by a separate regulator and the rest with another one. When the internal pull-ups are enabled and there is a glitch in the PS then interrupts can occur without possibly resetting the chip through brown-out detect. I have found that in noisy environments with tens of MOCB and contactors switching in an out there are false interrupts due to interference. I revised my PCBs and redesigned the PS. It did improve but was never totally fool proof. Normally the PICs are very stable from EMI standpoint. So the only way out was software. I introduced a short delay just entering the interrupts and checked that if the PIN was still high (or low). Since the interrupt is predictable you can detect if it was a glitch. Then simply clear the flags and quit from the interrupt. BTW I use asm interrupts.

    Hope this helps.

    Regards

    Sougata

  3. #3
    Join Date
    Jan 2005
    Posts
    72


    Did you find this post helpful? Yes | No

    Default EMI point of view

    hi

    thanks for your answer. i thinked about it first, so my late reply now...

    i've also played with the brown out (disabled it), but no effect.

    can you explain me please some details to separate regulation for the pic? i didn't really understood it...

    in general, for EMI, are there some other hot tips? i've readed once from mister_e a 0.1uF condensator as well a 10uF Tantal over power supply helps a lot. so for EMI more things should be necessary

    thanks

  4. #4
    Join Date
    Jan 2005
    Posts
    72


    Did you find this post helpful? Yes | No

    Default new aspect

    hello all

    i got a new problem around portb4:7. because i have a device out with this inputs interruptable where allways some problems occur (pic seems like frozen, must be repowered again) i start to try something.

    a simple code like below stops to run when i connect RB6 (only this one makes problems it seems) to a long cable (about 30m) with no connection at the other end!!! no charm!
    the led goes out and nothing happens again. test it on the lab-x2 and it must be made a reset.
    when i uncomment te additional three lines in the main loop, sometimes it is possible to restart the code again with some connect rb6 and reconnect.

    anyone an idea why this could be? works it like an antena? ways to try further on?

    thanks a lot for any hint

    Code:
    include "modedefs.bas"                    ' include serial modes
    
    '-- FUSE CONFIGURATIONS -----------------------------------------
    
    @ device  pic16F876a, hs_osc               ' oscillator selection 
    @ device  pic16F876a, wdt_off              ' watchdog timer
    @ device  pic16F876a, pwrt_on              ' power-up timer
    @ device  pic16F876a, bod_on               ' brown-out reset
    @ device  pic16F876a, lvp_off              ' low-voltage programming
    @ device  pic16F876a, cpd_on               ' data eeprom protection _on
    @ device  pic16F876a, wrt_off              ' flash program memory write
    @ device  pic16F876a, protect_on           ' program code protection _on
    
    '-- DEFINITIONS -------------------------------------------------
    
    DEFINE        OSC           20            ' oscillator speed
    
    
    '-- PORTS -------------------------------------------------------
    
    led1          var           portb.0
    led2          var           portb.1
    led3          var           portb.2
    but1 	VAR	portb.4  
    but2 	VAR	portb.5
    but3 	VAR	portb.6  
    
    '-- CONSTANTS ---------------------------------------------------
    
    '-- VARIABLES ---------------------------------------------------
    
    inp           var           byte          ' inputs portb4:7
    
    '-- INITIALIZATION ----------------------------------------------
    
    init:         clear                       ' set all ram registers to 0
                  
                  TRISA = %00000000           ' input : an4
                  TRISB = %11110000           ' input : buttons 1 - 3          
                  TRISC = %10000000           ' input : rx 
                  
                  ADCON1 = 7                  ' a/d und comp off; ra = d
                  OPTION_REG.7 = 0	' enable portb pull-ups
                  
                  lcdout $fe,1                ' clear lcd
                  pause 50                    ' wait for start up lcd
                  portb = 0                   ' clear all outputs on portb
    
                  
    '-- MAIN LOOP ---------------------------------------------------
    
    main:         
                  led1 = led1 ^ 1             ' toggle led                 
                  'lcdout $fe,$80,"status = ", dec led1, "   " ' write led status
    
                  'inp = Portb >> 4            ' shift portb inputs
                  'lcdout $fe,$c0,"b4:7 = ", dec2 inp        ' write input value
    
                  pause 500
                                
                  GOTO main
                   
    '-- INTERRUPT SERVICE ROUTINE ----------------------------------      
    
    '-- SUB -------------------------------------------------------- 
                        
    '-- END ---------------------------------------------------------                
                  END                                        
    '----------------------------------------------------------------
    i know it's only microcontrolling, but i like it!

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    The problem is certainely the internal pull-ups. too weak to be good. try lower value let's say 1K.

    BTW it's always agood practice to pca something betwen a PIC and the exterior world if you plan to use long distance cables. Opto coupler are still a good choice.

    RB6:rB7 are still programming pins... look at the programming sequence of your pic... it make me think it could be something around it or not.

    How about your MCLR pin?

    How about the whole setup.

    Bad ground screening, bad proto-board may give you some serious headache... worst @20MHZ. You may try to remove (for testing purpose only) those capacitor around your crystal.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Knowing your entire setup would help

    Hi,

    Internal pull ups are weak as stated and Steve is again damn right. Optocontrollers do help but then you need an additional power line light the LEDs. PCB layout is equally important. If you post your whole code then we can find out if it is an interrupt issue. Normally a PIC would reset if it freezes, (WDT) so an improper code may put your PIC in endless loop especially interrupts. If you do not have an ICD then it is possible to dump some values of the SFRs related to PIC power, stack etc,. This would ease diagonisis what went wrong and where.
    Regards

    Sougata

Similar Threads

  1. Thermo 7 segments - little problem
    By fratello in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 27th July 2013, 07:31
  2. Windows 7 64 bit problem..can anyone help???
    By ljc4141 in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 18th July 2011, 15:29
  3. problem with sending data using RF module
    By rano_zen06 in forum mel PIC BASIC Pro
    Replies: 51
    Last Post: - 10th April 2008, 17:08
  4. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  5. 7 segment digit problem (using Mister E's code)
    By jmgelba in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 9th September 2005, 20:25

Members who have read this thread : 0

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