PIC 16F819 Turn-On Problem


Closed Thread
Results 1 to 11 of 11
  1. #1

    Default PIC 16F819 Turn-On Problem

    I'm using the PIC to drive the gate of a n-channel mosfet. The fet controls a small, fast-acting solenoid. Code snippet as follows:

    low porta.1
    (some code here)
    pulsout porta.1,100 'pulse the solenoid on for 1 ms

    Everything works fine except for this:
    When power is first supplied to the PIC the solenoid will briefly turn on by itself. Obviously, the fet is coming on during start-up. Is there a way to stop this?

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Dick, I'm assuming that you have a logic level gate fet. I would put a pull down resistor of about 4.7k to 1k ohm from the gate to ground. This should stop the gate from seeing a turn on condition during poweron-reset while the micro port pins are in an input state.

    Dave Purola,
    N8NTA

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Dave,
    Thanks for your suggestion. Unfortunately, the pull down resistor did not work. The PIC behaves as if the port pin is very briefly going to the high state when it is first set as an output.
    I decided I can live with the anomaly for now. I will use a p-channel mosfet on my next board . That should fix it.

    Dick

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


    Did you find this post helpful? Yes | No

    Default

    this has to be really fast depending of your software and crystal speed

    did you try something like this right at the top of your code

    TRISB =0
    Solenoid var PORTB.0
    solenoid=0
    Steve

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

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Datasheet!

    By default your PIC will come up in Analog Input mode on PortA.

    When you initialise your PIC your first instructions should be...

    TRISA=%xxxxxx0x

    where x defines your other pins I/O status...

    ADCON1=%00000111

    to switch into Digital Mode, and finally...

    Low PORTA.1

    Now Bruce would prefer you to put the 'Low PORTA.1' first which could be good, but I calculate at 4Mhz, that's 3uS from the moment your PIC powers up, to that pin going low anyhow (and there's no-way your solenoid can react that fast). If you want to include a "belt and braces" solution, then put a 100nF Capacitor (of the type you use to decouple your PIC) between PortA.1 and Vss. That Cap will try to nail any initial spike during the first switch-on period before the PIC actually takes that pin low.

    Remember, these MUST be the FIRST instructions your PIC executes.

    Of course, depending on your PSU, if it's pretty crappy it could be a while (several mS) before your PIC wakes up. In that case you might need a more sophisticated input circuit to your FET than a single Resistor between the PIC and the FET gate. But that's another story...

  6. #6


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Thanks for your replies.
    My circuit is supplied from a battery driven voltage regulator which is fully on before the power is switched to the circuit.
    I neglected to mention that there are actually 2 solenoids and 2 mosfets. It is only the second one that misbehaves. Yes, I have 2 initialization steps at the very top of the code...already thought of that:

    low portb.3
    low porta.1

    I don't have a scope. The solenoids are very fast and can operate in less than 100 us. I will try the cap idea from Melanie. Otherwise, will go to a p-channel mosfet on my next board.

    Dick

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    If you have a device that can react that fast to a power-on condition, you
    might also consider disabling PWRT (power-up timer).

    PWRT alone can introduce a power-up delay period of roughly 72mS before
    any code can execute & set/clear outputs. Factor that in with normal start-
    up times, and you can end up with a substantial delay period before you can
    initialize everything properly.

    I think the PBP config word defaults in most device header files have PWRT
    enabled, but if your power supply comes up quickly, and you don't see erratic
    behavior on power-up with PWRT disabled, that just might cure the problem.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  8. #8


    Did you find this post helpful? Yes | No

    Default

    Bruce,
    PWRT is already disabled. Here is the whole configuration line:

    @device pic16f819,intrc_osc_noclkout,wdt_on,pwrt_off,mclr_ off,bod_off,lvp_off,cpd_off

    @ device ccpmx_off,debug_off,wrt_off,protect_off

    I will try M's cap fix. The approach makes sense because it creates a transient path to gnd for the spurious voltage. Can't do this right away though...will have to wait.

    Dick

  9. #9
    Join Date
    Jun 2005
    Posts
    53


    Did you find this post helpful? Yes | No

    Post

    Dick,

    Did you ever solve your 16F819 Turn-On problem?

    Like Bruce recommended, I have found the PWRT seems to help.
    I am also using INTRC and initialize to OSCcon = $60 (4mhz) and
    later switch to OSCcon = $70 (8mhz) at the end of my initialization,
    just before my main loop.
    I have used 16F627A with INTRC, and 16F876, 16F872 w/ crystal and never had power up Turn-On problem like the 16F819.

    Mark

  10. #10


    Did you find this post helpful? Yes | No

    Default

    Hi Dick. I had exactly the same problem with a 16LF818 attached to a music chip. Upon power-up the chip would blast a few milliseconds of music from the speaker. I cured the problem by turning "POWER UP TIMER OFF". It's been about a year now and no problems have arised by doing this.

  11. #11


    Did you find this post helpful? Yes | No

    Default

    Peter and Mark,

    No, I never really solved the problem, and yes, the power-on timer is already set to off as explained earlier. I have now moved past the problem because I no longer use the super-fast solenoid. Have gone to a servo instead .. no problem.

Similar Threads

  1. Trouble with most basic BLINK on PIC 16F819
    By confusedperson in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 16th April 2009, 21:46
  2. Help with PIC project
    By davekav in forum General
    Replies: 3
    Last Post: - 17th April 2008, 23:15
  3. Button problem driving me crazy!! Please help!
    By bearpawz in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 20th November 2007, 14:46
  4. Serin Problem 16f819
    By jjohannson in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd March 2007, 22:50
  5. Circuit needed to allow a PIC to turn something on or off
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th October 2005, 21:17

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