I/O pin default low.


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

    Default I/O pin default low.

    How do I set an output digital pin low by default?

    16f15324 - pin PORTA.4
    My dad never liked you...

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,389


    Did you find this post helpful? Yes | No

    Default Re: I/O pin default low.

    this will do it
    Code:
    ansela = ~ 16
    lata     = ~ 16
    trisa    = ~ 16
    but i doubt its the actual problem, i suspect you are most likely driving the mosfet improperly
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: I/O pin default low.

    Electronically I am driving it correctly.. its actually only driving an npn transistor..

    Somehow my program is restarting when I introduce an input.
    My dad never liked you...

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


    Did you find this post helpful? Yes | No

    Default Re: I/O pin default low.

    Quote Originally Posted by richard View Post
    this will do it
    Code:
    ansela = ~ 16
    lata     = ~ 16
    trisa    = ~ 16
    but i doubt its the actual problem, i suspect you are most likely driving the mosfet improperly

    you are correct - with transistor out, it works - the transistor turns on the fet which has a load. With no load the code works - with load the program resets because the PIC output pin cant drive it on startup. Once its on and a load is then applied it works...

    So I guess the question is how do I get the PIC to work with load already on.
    My dad never liked you...

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,389


    Did you find this post helpful? Yes | No

    Default Re: I/O pin default low.

    So I guess the question is how do I get the PIC to work with load already on.

    provide more detail and a schematic to begin with
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: I/O pin default low.

    attached pdf
    Attached Images Attached Images
    My dad never liked you...

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,389


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: I/O pin default low.

    that's a fairly standard sort of high-side switch that I would expect to be ok.

    given that pic i/p leakage current is typically 100nA~ish MAX either R4 is not what is depicted
    or your code is not as described [bootloader maybe].
    you could try a smaller R4

    Thats about all i can see


    Somehow my program is restarting when I introduce an input.
    is a different story, a big heavy load needs a good power supply and adequate filtering
    together with a proper layout to prevent noise affecting the logic circuits
    Last edited by richard; - 31st May 2023 at 06:42.
    Warning I'm not a teacher

  8. #8
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default Re: I/O pin default low.

    Hi,

    Please ...

    - provide your full config section ( ports config included )
    - provide your full schematics ( Pic + Supply + Power sections )

    No way to give you a decent answer without those infos ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default Re: I/O pin default low.

    I'll give more infor in a bit - but my guess while sleeping is filtering - I need a few caps on inputs and output - which are next to the reset pin. I'll try that tonight. - and maybe a larger one on the PIC itself.

    I'll provide a better schematic and my code for ports etc later today.. I'm sure my code is different than what the good programmers use. I didnt use LAT for example - just ports.


    thanks ahead of time...
    My dad never liked you...

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


    Did you find this post helpful? Yes | No

    Default Re: I/O pin default low.

    ok - no insults please... - if someone wants to clean my code up for $ I'm all ears... - seriously...

    16f15324PIC-SCHEM.pdf

    schematic says it s 16f616 - its not - its a 16f15324 ********************

    #CONFIG
    __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_OFF
    __config _CONFIG2, _MCLRE_ON & _PWRTE_ON & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON
    __config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_ON & _WDTCWS_WDTCWS_6 & _WDTCCS_SC
    __config _CONFIG4, _BBSIZE_BB512 & _BBEN_OFF & _SAFEN_OFF & _WRTAPP_OFF & _WRTB_OFF & _WRTC_OFF & _WRTSAF_OFF & _LVP_OFF
    __config _CONFIG5, _CP_ON
    #ENDCONFIG


    OSCCON1=%00000011
    OSCCON2=%00000011
    INLVLA = %11111
    INLVLC = %1111111
    TRISC = %11111111


    DEFINE OSC 4
    OSCFRQ_4MHZ

    ANSELA = PORTA.2
    ANSELC = %00000

    OUTPUT PORTA.1 ' FAULT LED
    OUTPUT PORTA.0 ' TIMING LED
    OUTPUT PORTA.4 ' FET
    INPUT PORTA.5 ' IGNITION
    INPUT PORTC.5 ' V UNDER TRIP POINT - 11 OR 11.75
    input PORTC.4 ' CHOICE BIT OF HOW THIS TURNS ON


    SW1 - SW6 are inputs
    green and red - outputs to leds
    "Battery sense" is an analog in
    "I sense" is a 12V in (broken down to <5v)
    FET - output


    whats happeing is when IG comes on the program resets when there is a load on FET - with no load it works. (I'm trying more filtering on IG AND FET output and make sure C3 is .1)

    btw - insult it all you want...

    Again - I'm all ears on someone helping me - lmk I'll giv emy email and set it up.
    Last edited by pescador; - 31st May 2023 at 12:55.
    My dad never liked you...

  11. #11
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default Re: I/O pin default low.

    Top secret electronic ignition ??? ....
    MC3334P clone ?

    - ADC inputs have a maximum input feed impedance to respond as fast as required ... see Pic datasheet for details.

    so, I presume @ first sight your current detection is wayyyy too slow, and your coil enters saturation ...

    add to that your IPB protection is wayyy too weak and slow !!! be prepared for in-use failures, after some running time.

    Now, automotive circuits need lots of filtering to avoid pic supply surges ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default Re: I/O pin default low.

    Quote Originally Posted by Acetronics2 View Post
    Top secret electronic ignition ??? ....
    MC3334P clone ?

    - ADC inputs have a maximum input feed impedance to respond as fast as required ... see Pic datasheet for details.

    so, I presume @ first sight your current detection is wayyyy too slow, and your coil enters saturation ...

    add to that your IPB protection is wayyy too weak and slow !!! be prepared for in-use failures, after some running time.

    Now, automotive circuits need lots of filtering to avoid pic supply surges ...

    Alain

    No current detection - just if IG is on (12V) and monitors battery voltage - this all working for past 5 years. Discovered the issue of no load it starts right up - with load it resets program. In other words I can turn it on with Ignition and then apply load - works. But I can tell the program gets reset because I put a turn on/off red led before the main and it comes on when IG is applied. I'll try caps later tonight on signals.

    I also do not think code is correct setting up registers. Thats what I want help on.
    My dad never liked you...

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


    Did you find this post helpful? Yes | No

    Default Re: I/O pin default low.

    Quote Originally Posted by Acetronics2 View Post
    Top secret electronic ignition ??? ....
    MC3334P clone ?

    - ADC inputs have a maximum input feed impedance to respond as fast as required ... see Pic datasheet for details.

    so, I presume @ first sight your current detection is wayyyy too slow, and your coil enters saturation ...

    add to that your IPB protection is wayyy too weak and slow !!! be prepared for in-use failures, after some running time.

    Now, automotive circuits need lots of filtering to avoid pic supply surges ...

    Alain

    no - not a clone of MC3334P - it just turns on a load if IG is present.
    by the time I get the IG signal its been filtered.

    What coil?

    IPB?
    Last edited by pescador; - 31st May 2023 at 15:39.
    My dad never liked you...

  14. #14
    Join Date
    Aug 2011
    Posts
    412


    0 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: I/O pin default low.

    Your ANSELA statement is incorrect... you don't set it that way.

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


    Did you find this post helpful? Yes | No

    Default Re: I/O pin default low.

    Quote Originally Posted by tumbleweed View Post
    Your ANSELA statement is incorrect... you don't set it that way.

    ok - please elaborate..
    My dad never liked you...

  16. #16
    Join Date
    Aug 2011
    Posts
    412


    Did you find this post helpful? Yes | No

    Default Re: I/O pin default low.

    ANSELA is an 8-bit register... you set it just like any register, 0-255

    If you want RA2 to be analog but all others digital then ANSELA = %00000100

    You have something very different... ANSELA = PORTA.2, which will read the value of the port pin and assign it to ANSELA (whatever that results in).

Similar Threads

  1. How to set pin to digital by default? PIC18F24J50
    By picmilan in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 29th May 2016, 21:27
  2. Replies: 10
    Last Post: - 14th April 2014, 20:47
  3. Can't keep a pin low
    By bartman in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 6th January 2006, 14:04
  4. Trouble pulling pin Low
    By pdegior in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 9th August 2005, 20:49
  5. Reading if Pin is High or Low?
    By Spindle in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 1st August 2005, 17:39

Members who have read this thread : 12

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