PIC16F886 Pulldown inputs


+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2016
    Location
    Plainfield, Illinois
    Posts
    73

    Default PIC16F886 Pulldown inputs

    I'm using a 16f886 to detect digital inputs. I set RA5 for example to be a digital input. No analogs for this project.

    ANSEL = 0 ' Make AN0-AN7 digital
    ANSELH= 0 ' Make AN8-AN13 digital

    I'm using opto isolators to accept 12V and convert the 12V to 5v (VCC).
    That output is connected to pin 7 (RA5).

    I'm observing that it thinks its high all the time because I made the mistake of leaving that input floating instead of tying it to GND thru a high ohm resistor as a default. When I touch my probe on the pin it works - telling me it needs a pull down.

    I then put a thru hole resistor on the opto isolator output (1.5M because thats what I had) and it works, that fixed it. But now I have to modify my prototype.

    My question is there a way to configure the 886 to have pulldown capability on portA. I'm reading and reading and can't seem to find that solution. Prob not possible.

    And last - the PIC886 is a fairly old IC - is there a newer version which might incorporate pull down functionality? I'll hang up and ask Micrchip for that answer...

    Any ideas that might solve this rather than redoing my proto to have the pull down resisitor fix?
    My dad never liked you...

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: PIC16F886 Pulldown inputs

    No. The chip has internal pull-up resistors not pull-down.

    Normally you would connect the optocouplers to ground and the input of the chip. Then enable the internal pullup.

    What exactly you did?

    Ioannis

  3. #3
    Join Date
    Apr 2016
    Location
    Plainfield, Illinois
    Posts
    73


    Did you find this post helpful? Yes | No

    Default Re: PIC16F886 Pulldown inputs

    I didnt do that - as you can see PARK for example - pin 15 - is the output of pin 16 when pin 1 is high. 15 is basically floating when not activated - I want the pin on the PIC to be active high - not low. I think adding a high ohm resistor to ground will take care of it. Unless you have another idea?

    I could have used a simple voltage divider as the input - but the input voltages could exceed the divider output (<5V) and I thought the opto would do the trick passing 5V(VCC) which is regulated.

    Any way to paste a screen shot instead of a pdf?

    https://optoelectronics.liteon.com/u...is%20Mar17.PDF - opto pinout
    Attached Images Attached Images
    Last edited by pescador; - 9th January 2024 at 22:54.
    My dad never liked you...

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: PIC16F886 Pulldown inputs

    I am sorry but this is not correct as you designed it.

    Now the only way is to add the resistors to ground from all the relative PIC inputs. And do add 10K resistors. Not more than that because of noise that can distrurb the input. Better change the 2K to 100 ohms too.

    The usual practice is to have Pull Ups and then the opto drive to ground the input. If you want the input high then just reverse the byte your read from the port in software. Easy task.

    Also note that in 886, there are Pull-Ups only on Port B and not on Port A.

    Ioannis
    Last edited by Ioannis; - 10th January 2024 at 10:19.

  5. #5
    Join Date
    Apr 2016
    Location
    Plainfield, Illinois
    Posts
    73


    Did you find this post helpful? Yes | No

    Default Re: PIC16F886 Pulldown inputs

    Ok thanks - I'll connect the opto collector tied high to the PIC and drive the Opto to GND - easy - no need then for ground resistors...

    Thanks for R values..REV.pdf
    My dad never liked you...

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: PIC16F886 Pulldown inputs

    Maybe I was not very clear.

    With your original design, you would change the 2K to 100 ohms.

    But with the new design, the pullup will be around 10K. NOT 100 ohms. I am pretty sure you will destroy the optos.

    Ioannis

  7. #7
    Join Date
    Apr 2016
    Location
    Plainfield, Illinois
    Posts
    73


    Did you find this post helpful? Yes | No

    Default Re: PIC16F886 Pulldown inputs

    - So just to be clear - I'm driving the optos using the 2k to the anode, the output is the "collector" tied hi to a resistor - to the PIC w 5V. I'm not sure 100 ohms to the PIC would damage the PIC, but I dont think the opto would care?

    In any case - I'll use 10K like you suggest.. no real reason to use 100.
    My dad never liked you...

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: PIC16F886 Pulldown inputs

    With 100 ohms from +5 to the collector of opto, you will force 50mA through opto. This is the absolute max according to the data sheet. It will lead sooner or later to the destruction of the opto.

    Please do use 10K from +5 to the collector of the opto and drive from the collector the PIC port. The emitter of the opto will be earthed.

    Everytime you feed current to the LED of the opto, the PIC port will be low and when the LED is off, port will be high.

    Ioannis

Similar Threads

  1. PIC16F886 not running.
    By Lilleljung in forum PBP3
    Replies: 19
    Last Post: - 6th January 2015, 21:35
  2. pic16f886
    By NURULHAIZA in forum General
    Replies: 5
    Last Post: - 21st May 2010, 08:09
  3. neebee wants to know pullup or pulldown?
    By lecoind in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 24th May 2009, 03:36
  4. pullup and pulldown resistor help
    By studysession in forum General
    Replies: 5
    Last Post: - 29th January 2009, 02:46
  5. Pic16f886
    By Larry in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th October 2008, 22:40

Members who have read this thread : 15

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