Device Resets / erratic operation - 16F88


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Apr 2009
    Location
    Northport Alabama USA
    Posts
    6

    Default Device Resets / erratic operation - 16F88

    Hey new member here! I've been building and programming "toys" for a while now and have not had issue anything like this before. I'm working on a controller for a car's load-levelling rear suspension. It uses a PIC16F88, reading a position sensor (0-5V signal) and controlling a solenoid valve and relay, as well as an indicator lamp, and an on-board LED.

    The circuit works well on the bench, driving test lights, however when connected to the acutal hardware it is to control, I get sporadic resets, lockups, and garbled operation.

    The problem happens when the relay turns off. I have checked and double-checked the MCLR pin (turned off in configuration, and set to output and LOW in program), all unused pins are output and LOW. The outputs are simple NPN switching transistors, biased through a 330R resistor. The relay coil has a diode to block inductive kickback, as well as a .1uF capacitor across its incoming wires.

    The solenoid valve output is constructed the same, and it does not cause any resets, in spite of the fact it is a much higher current load.

    The power supply is a 7805 regulator, with a 1000uF cap on the input side, a 1000uF cap on the output side, and the chip has a .01uF cap directly across the +5V and Gnd pins.

    If I replace the relay with a resistive load, the problem goes away. I've replaced the output transistor, back-EMF diode, PIC chip, and all filter capacitors, and the rests and lockups continue.

    I've built several other 16F88 based controllers that drive relays using the same configuration of transistor, and nothing like this has happened.

    Ahy ideas?!?

    Thanks in advance!
    David

    [email protected]

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    I have some ideas,
    I would like to see the schematic and your code configs, also part # of the snubber diode. I am thinking . . . Diode too slow . . . Not hooked up right . . . brown out PIC due to reverse EMF, remember the back voltage from that relay coil and motor is several hundred volts, also make sure the PIC is properly bypassed on it's power pins with .01uf and a 10uf, you may need to run separate power lines from the battery for the load and PIC circuits.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Apr 2009
    Location
    Northport Alabama USA
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    I have some ideas,
    I would like to see the schematic and your code configs, also part # of the snubber diode. I am thinking . . . Diode too slow . . . Not hooked up right . . . brown out PIC due to reverse EMF, remember the back voltage from that relay coil and motor is several hundred volts, also make sure the PIC is properly bypassed on it's power pins with .01uf and a 10uf, you may need to run separate power lines from the battery for the load and PIC circuits.
    Diode is 1N4007. I was indeed wondering about diode speed, since these are the cheapies from Radio Shack. I also put a small cap between the transistor base and ground, to slow down the fall time of the output and reduce the back EMF, too.

    Forgot to mention - motor has built-in supression, however the resets occur even with the motor disconnected and only the relay coil active.

    PIC is bypassed well, with ceramic cap directly under socket, and electrolytic at the voltage regulator.

    I did some further experimintation yesterday, and found out that the relay will cause a reset, even when not connected to the circuit. In other words, with the control wire from the board to the relay coil neg terminal unhooked, if I touch a ground wire to the relay coil (click the relay), the controller will sometimes reset. This is without the motor connected to the relay.

    I then took a "snap-on ferrite choke" and wrapped the harnss to the control board through this choke, and the problem is gone.

    Here is the schematic (sorry for the hand-drawn schematic - I am not a professional designer by any means!)



    The power supply works by taking ignition key switched power through the indicator lamp, through a diode and into the 7805 regulator. This is enough to start the CPU. The first thing the program does is turn on the power hold-up output (pin 10 on CPU) so that it will maintain power when the indicating lamp is grounded by the indicating lamp output. The program monitors voltage at the indicating lamp circuit to know when the car's ignition is on or off, and powers off the power hold-up circuit several minutes after the car is switched off.

    I bypassed this and had the circuit connected to stay on constant, and the resets continued so I don't think it is in my power control circuit.

    I think the capacitor added to the base of the relay drive (not shown) and the ferrite choke have it fixed hopefully!

    Thanks,
    David

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


    Did you find this post helpful? Yes | No

    Default

    Few observations.

    Diode should go in parallel with your Relay coil (pin 86/85). Something like
    http://terpconnect.umd.edu/~toh/ElectroSim/Relay.GIF

    It's a good idea to keep the relay as far as possible of the PIC, and not a bad idea to place a 0.1uF + something like 22-47uF close to your relay +12V line. Some also place a small capacitor across the relay coil, and some suggest to install a capacitor across the relay contact (kinda snubber), worth a try.

    There's something funky on your design about NPN-PNP connection (at pin 10)

    How do you supply the Pos sensor? From your voltage regulator or from the 12V line?

    I would suggest you to tie all unused pin to gnd, and set them as input.

    Mode switch... i find the resistor setting a bit non standard.

    1000uF at the regulator output may screw up most 7805 regulator. You want to keep this value lower than this. Check the datasheet for the brand you're using. Usually 10 - 22uF tantalum + 0.1 uF ceramic do the trick.

    HTH
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Not a bad idea to use a LC filter at the input, those car alternator do pretty good stuff on the +12v line
    Steve

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

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Not a bad idea to use a LC filter at the input, those car alternator do pretty good stuff on the +12v line
    Especially if a diode starts going away!
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7
    Join Date
    Apr 2009
    Location
    Northport Alabama USA
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Few observations.

    Diode should go in parallel with your Relay coil (pin 86/85). Something like
    http://terpconnect.umd.edu/~toh/ElectroSim/Relay.GIF

    It's a good idea to keep the relay as far as possible of the PIC, and not a bad idea to place a 0.1uF + something like 22-47uF close to your relay +12V line. Some also place a small capacitor across the relay coil, and some suggest to install a capacitor across the relay contact (kinda snubber), worth a try.

    There's something funky on your design about NPN-PNP connection (at pin 10)

    How do you supply the Pos sensor? From your voltage regulator or from the 12V line?

    I would suggest you to tie all unused pin to gnd, and set them as input.

    Mode switch... i find the resistor setting a bit non standard.

    1000uF at the regulator output may screw up most 7805 regulator. You want to keep this value lower than this. Check the datasheet for the brand you're using. Usually 10 - 22uF tantalum + 0.1 uF ceramic do the trick.

    HTH
    Thanks for the help!!! The diode, I mis-drew in the picture I posted. The circuit was build on-the-fly, with only the basic IO drawn up before hand. I drew that in haste to post here and that is not correct. The diode is actually connected with banded end to B+, and other end to the coil neg terminal. Then I found out, there is a second diode built into the relay its self! The relay is at least 18" from the control module, in a socket that is part of the harness.

    The NPN - PNP connection allows the PIC to switch +12V on the high side, to keep the power to the circuit on, after the power path from ignition switched 12V throuth the indicator lamp is no longer available. I use the signal through the light bulb to tell it when the ignition is turned ON, as well as being able to ground the lightbulb and cause it to illuminate. It looks odd but it works, and was buildable with components I had here.

    The reason I have such large input capacitor (before regulator) is that the circuit needs to stay up during engine cranking (possible B+ pulling down to less than 6V during starter inrush). I learned that trick on my headlights controllers I built for my other 2 cars! The large cap on the 5V side is only because.... that is what I had on hand.

    The position sensor is a throttle position sensor from a Rochester MPFI throttle body. It is a potentiometer only and requires clean regulated 5V supply and "clean ground" to give any sort of accuracy.

    It has a 3 wire sheilded cable in the harness, with ground coming off the board near the CPU ground, and +5V coming off near the CPU's +5V pin. The sensor is actually very accurate and does not vary significantly when the car's voltage changes or the CPU actuates outputs. I'm actually really happy with that part of the system!

    The mode switch resistors are that way because - once again they are what I had on-hand. It's just a pull-up resistor and a resistor to help protect the CPU if somehow +12V gets on the switch circuit.

    I've not had any resets since the choke was put on the harness, but I really like your idea of the snubber cap on the relay. Motor is supposedly internally suppressed, but it couldn't hurt to add a freewheeling diode to the motor too. If there is any reason to go into the system again, that will get done!

    Thanks again,
    David

  8. #8
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by turbokinetic View Post
    The NPN - PNP connection allows the PIC to switch +12V on the high side, to keep the power to the circuit on, after the power path from ignition switched 12V throuth the indicator lamp is no longer available. I use the signal through the light bulb to tell it when the ignition is turned ON, as well as being able to ground the lightbulb and cause it to illuminate.
    I used a Bosch relay on a 71 chevy to power an HEI ignition and the relay would hold down to 3volts which was low enough to allow engine to run when switched off due to receiving power through the alternator light, had to kill engine in reverse gear, where the backup lights would load it enough to cutoff relay.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. Watchdog Timers
    By Squibcakes in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th August 2014, 18:03
  2. RF Modules
    By tonyfelloni in forum mel PIC BASIC Pro
    Replies: 44
    Last Post: - 26th June 2010, 17:42
  3. Replies: 8
    Last Post: - 7th December 2006, 15:42
  4. 16F88 is not the dream device I thought it was.
    By keithdoxey in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 25th October 2005, 21:19
  5. @ Device Parameters
    By Randy_Suwanee in forum General
    Replies: 2
    Last Post: - 11th August 2004, 14:40

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