From: Steve H on
In message <htud5q$db0$1(a)speranza.aioe.org>, Jeroen Belleman
<jeroen(a)nospam.please> writes
>On 05/30/2010 06:10 PM, Steve H wrote:
>>
>> I've designed & built a device using a 16F877A PIC, and have had a few
>> issues with the device resetting or locking up due to static
>> [...] The electronics are
>> contained in an earthed steel enclosure and the 0v rail is connected
>> directly to earth, the connection being at the PSU end.
>
>If I understand correctly, your electronics and the box it sits in
>each have their own individual wire to a common ground at some
>remote PSU?
>
>That's bad!
>
>The box should *be* the electronics ground. In the setup you
>have, discharging static through either the box or the electronics
>ground will make the potential of one jump w.r.t. the other,
>causing all sorts of mayhem.
>

The arrangement I have is that the enclosure has the mains supply going
directly into it via an IEC connector. The steel enclosure is directly
earthed by a short wire from the earth pin of this connector to an
earthing point on the chassis. An off-the-shelf 15 volt 120 watt power
supply sits inside the enclosure. The 0v side of the DC output is
connected to earth internally within the power supply.

--
Steve H
From: Jeroen Belleman on
On 05/30/2010 09:28 PM, Steve H wrote:
> In message <htud5q$db0$1(a)speranza.aioe.org>, Jeroen Belleman
> <jeroen(a)nospam.please> writes
>> The box should *be* the electronics ground. In the setup you
>> have, discharging static through either the box or the electronics
>> ground will make the potential of one jump w.r.t. the other,
>> causing all sorts of mayhem.
>>
>
> The arrangement I have is that the enclosure has the mains supply going
> directly into it via an IEC connector. The steel enclosure is directly
> earthed by a short wire from the earth pin of this connector to an
> earthing point on the chassis. An off-the-shelf 15 volt 120 watt power
> supply sits inside the enclosure. The 0v side of the DC output is
> connected to earth internally within the power supply.
>

OK, that doesn't sound so bad then. Attention shifts to the other wires:
I suppose there's a reset button mounted in a hole of the enclosure
somewhere. Do you have a GND wire from that button back to the board,
near the connection to the MCLR pin? The idea being to minimize the
loop area of the current path from MCLR, through the button, back to
GND. Don't rely on the box being at GND potential to pull MCLR down!

Next is the opto-isolated part, which also crashed the controller, when
touched: How much of that part of the circuit is exposed inside the box?
Is there anything to keep the potential of the isolated part in check?
Does it get close to any part of the controller circuitry? Possibly you
have capacitive coupling or maybe even a flash-over from that part?
A few kV finds ways that a few volts cannot bridge.

Jeroen Belleman
From: Steve H on
In message <htui1j$kof$1(a)speranza.aioe.org>, Jeroen Belleman
<jeroen(a)nospam.please> writes
>
>OK, that doesn't sound so bad then. Attention shifts to the other wires:
>I suppose there's a reset button mounted in a hole of the enclosure
>somewhere. Do you have a GND wire from that button back to the board,
>near the connection to the MCLR pin? The idea being to minimize the
>loop area of the current path from MCLR, through the button, back to
>GND. Don't rely on the box being at GND potential to pull MCLR down!
>

No, in this apparatus there's no reset button, purely a 4k7 pulling the
MCLR to the 5v rail. I'm making the assumption (!), based on changes
I've made to the connection to the MCLR pin while problem-solving, that
the remaining minor instability relates to this pin, hence the original
question re best practice for a reset circuit. Of course there may very
well be other issues with it. I have in the past experienced a similar
issue when I had a PIC reset pin pulled up with a 100k resistor and
connected to a reset button via some longish wires; I discovered then
that RFI/EMI generated by mains equipment nearby switching on/off caused
the PIC to reset, and replaced the 100k with a much lower value.


>Next is the opto-isolated part, which also crashed the controller, when
>touched: How much of that part of the circuit is exposed inside the box?
>Is there anything to keep the potential of the isolated part in check?
>Does it get close to any part of the controller circuitry? Possibly you
>have capacitive coupling or maybe even a flash-over from that part?
>A few kV finds ways that a few volts cannot bridge.
>

The small isolated circuit exists on the same board and is tied to the
common 0v via a 1Mohm resistor. The circuit is very simple - a DC-DC
converter, resistor, optocoupler and a pair of wires that go to a
connector mounted on the enclosure. Connecting these two wires together
remotely via external equipment completes the circuit and provides a
logic signal to the PIC via the opto. Since removing the 100nf
decoupling capacitor on the MCLR, it does now take a significant static
flash to reset the PIC so it's really no longer a major issue. I'm
interested though in any clues as to how to make it as resilient as
possible.

--
Steve H
From: Frank Buss on
Steve H wrote:

> The first problem I faced was that the PIC would frequently lock up when
> either the case or any part of the 0v rail was touched. I realised this
> was due to a mild static charge building up when I got up off a chair
> and being discharged through whichever point was touched. The PIC would
> crash and would draw then excessive current from the 5V supply.
> Investigations found the solution to this particular type of crash was
> to pull the MCLR up to Vdd via a 4k7 resistor and not have it connected
> directly to the 5v (as the Microchip datasheet suggests is acceptable).

The datasheet doesn't suggest this:

http://ww1.microchip.com/downloads/en/DeviceDoc/39582b.pdf

Take a look at figure 14-5, recommended MCLR circuit.

I think it could be a problem, that the MCLR pin is used for HV
programming, too, so maybe add an additional BAV99 before R2 to limit the
voltage to about 0V..Vdd and place the reset components as close as
possible to the MCLR pin.

--
Frank Buss, fb(a)frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
From: Jeroen Belleman on
Steve H wrote:
> In message <htui1j$kof$1(a)speranza.aioe.org>, Jeroen Belleman
> <jeroen(a)nospam.please> writes
>>
>> OK, that doesn't sound so bad then. Attention shifts to the other wires:
>> [...]
>
> No, in this apparatus there's no reset button, purely a 4k7 pulling the
> MCLR to the 5v rail. [...]

That looks like a small target too then.

As the circuit previously suffered from latch-up (the increased current
after a crash), some of the controller pins must have seen voltages
well outside their permitted range.

As a rule, any wire that leaves or enters the circuit should be
filtered, using e.g., RC low-pass sections, transformers or common-
mode chokes, opto-couplers, feed-through capacitors, and/or clipping
diodes. The choice depends on the kind of signal that you need to
pass, of course.

Then there are a number of lay-out rules, valid for both PCB and
cable dressing, that will minimize trouble:

First, keep inductive coupling small by systematically using a
return wire with every 'hot' wire, and routing them along the same
path. Minimize the open area between them by twisting them together,
if you can. Use wide GND tracks, or a full GND plane, if you can.
Also, keep circuits carrying large, fast changing currents
well away from low-level circuitry. Static discharge is a fast
changing current.

Then, minimize common-impedance coupling, don't share wires between
different circuits, especially not if one is a low-level signal and
the other is a large signal. Keep in mind that for fast changing
currents, even a short piece of wire can have a sizable (inductive)
impedance, which will therefore have a sizable voltage between its
ends if the current rises fast enough. A useful rule of thumb for
straight wire is ~10nH/cm.

Finally, minimize capacitive coupling by keeping conductors with
rapidly changing voltages away from nodes with high impedances.
You can also reduce the coupling by reducing the rate of change
of agressor nodes, by reducing the impedance of victim nodes,
or by putting grounded or guarded shields between them.

How far you need to go in all this, and what sins you can get away
with, is a matter of judgment and experience.

Jeroen Belleman