I'm working on a little PIC project and out of sheer desperation I am
appealing to you for help!
I've designed a very simple alarm system for my house using the
PIC16F84, that uses Change on Port B Interrupt to detect whether a door
or window has opened. It then actuates a relay for an alarm and flickers
an LED to indicate on a diagram where in the house it was.
Simple to design and program using MPLAB, but when I burn it in and test
it, I find that it is VERY erratic. For instance when I apply power
(5.05v through a regulator) some LEDs flash spontaneously that are NEVER
supposed to flash and it acts strange. Normally when I then
apply Master Reset it resets properly and works fine, but not always.
Sometimes when reset it acts the same as during a power up.
Even when I think it IS working fine it sometimes does strange things
inconsistently.
I've even simulated a Power-On reset and it starts up properly in MPLAB.
BTW I've combed through the source code and everything looks fine also
in simulation.
It would be really great if you could give me some tips please. I use
12.45v to program it (unregulated) and 5.05v (regulated) for Vdd. I use
a 4MHz crystal and power up timer on, watch dog off.
I would add a 10uF and a .1 uF cap between Vdd and Vss at the 'F84'.
Also, I would enable the weak pullups on Port B as well. That is unless
you already have done these things. Also, make sure the watchdog timer
is not tripping you up. I don't think the W/D timer is the problem from
what
you state is happening. You may want to check the 5 volt regulator to make
sure it is functioning properly also. What kind of oscillator are you
using?
Are you using a crystal or canned Osc? Do you have the power up timer
and the Osc startup timer activated? If not, the part may not be getting
a good clock signal before it starts running. Just some things to check.
Hope this helps. Also, I'd like to know what you did to fix it when you
get it
fixed.
>I'm working on a little PIC project and out of sheer desperation I am
>appealing to you for help!
>
>I've designed a very simple alarm system for my house using the
>PIC16F84, that uses Change on Port B Interrupt to detect whether a door
>or window has opened. It then actuates a relay for an alarm and flickers
>
Graham:
In addition to suggestions from Jim, Bob and Zack....
Does the PIC drive any kind of load other than LEDs? If so, can you
temporarily disconnect them to see if that has any effect?
What about unused pins? Do you have any, how are they treated in
software, and are they terminated?
I have a 0.1uF decoupling capacitor and pull-ups on, with no WDT. The Power Up
Timer is active, and the Oscillator Timer is always on since I'm using a 4Mhz
Crystal (XT mode). The regulator seems fine at 5.05v.
I have found though that when I apply power while MCLR is low, wait a couple of
seconds, then let MCLR go high through a pull-up resistor, it works every time.
This could mean that the power line takes that long to stabilize, which is very
strange! I could work around this problem by actually attaching my ON/OFF
switch to MCLR instead of Vdd, and then the device would simply always be in
reset when 'off'. Do you think this is a good idea? It seems to solve the
problem.
I don't believe I've heard of this being done before, and I don't know
whether it
violates any engineering practices or PIC operating specs, but if it works,
I see
no reason why you shouldn't try it, unless one of the above conditions is
true.
You might want to try a cap to ground on the MCLR with a pullup from MCLR to
Vdd.
This will give you the 2 second wait until the power supply stabilizes. Or
you could
rig up a one shot with a 2 second delay,. This also would accomplish the
same result,
but would result in extra components, and complexity, as well as extra cost.
The only
other option you would have I guess is to change power suppiles, or at least
try to
speed up the stabilization of the one you have. One of these method should
be a good
compromise for you between cost, complexity and effectiveness. The final
decision
is up to you though. Thanks for the feedback. I appreciate it. Sorry
the suggestions
I submitted to you didn't really help as you already had them implemented or
thought of.
Again I would appreciate it if you could let me know what you finally decide
once you get
the circuit fixed the way you want it. This will not only help in my
projects in the future, but
also in other projects on this list. You may want to look at the power
supply on a scope to
see just exactly how long it takes to stabilize. This may help you in
deciding which one of
the above ideas best fits the situation.
Okay, I've taken up enough of your time with this long winded conversation.
I'll let you get
back to PIC'ing.
> Does the PIC drive any kind of load other than LEDs? If so, can you
> temporarily disconnect them to see if that has any effect?
No, only LEDs. I use 4 on Port B and 3 on Port A, maximum of 2 on at any
time. I've got a 0.1uF cap directly between Vdd and Vss.
> What about unused pins? Do you have any, how are they treated in
> software, and are they terminated?
No unused pins. Actually, I use the internal pull-up and change on pin int to
check when a switch opens on Portb 4-7. Maybe there is something strange with
the pullups drawing too much current?
Thanks!
Graham.
>Reginald Neale wrote:
>
>> Does the PIC drive any kind of load other than LEDs? If so, can you
>> temporarily disconnect them to see if that has any effect?
>
Use the output to drive a transistor and much bigger loads can be
operated, eg relays, opto-isolators then the world.
Ron
--
/\
[] Ron Dickinson
[] <<<<< >>>>>
[] Compusolve-Redilec
/--\ Derbyshire England
!!!! +44 01246 - 570281
> >
> >> Does the PIC drive any kind of load other than LEDs? If
> so, can you
> >> temporarily disconnect them to see if that has any effect?
> >
> Use the output to drive a transistor and much bigger loads can be
> operated, eg relays, opto-isolators then the world.
> I have found though that when I apply power while MCLR is low, wait a
> couple of seconds, then let MCLR go high through a pull-up resistor,
> it works every time. This could mean that the power line takes that
> long to stabilize, which is very strange!
Use the "brownout" circuit from the application notes. One PNP
transistor and three resistors, Figure 8-15 of document DS30430C, page
46.
As I see it, it is unwise *not* to use this circuit or a better one,
in any PIC application.
Why isn't it built-in? Well, if it were, it would limit you to a
specific voltage range for circuit operation. It is expected that you
design this circuit for whatever operating voltage you will be using,
taking into account the characteristics of other associated devices.
The circuit also uses a few microamps in operation.
Of course, they *could* have included some sort of very low current,
1V threshold device I suppose.
--
Cheers,
Paul B.