I have a battery-powered Arduino device that randomly freezes in regular use on a gym floor, but never on the bench. The only difference I see is that in use there is 100 ft (30 meters) of wire to 6 analog inputs. The device is simply sensing the contact between the ends of those 6 wires, and tells which two wires are currently touching. Is it possible that the wires pick up so much by induction, that a shot knocks the MCU (ARM SAMD21G18) unconscious?
After the power-cycle, the device works fine until, seemingly randomly, freezes again within anywhere from a minute to an hour or two. Device on the bench, running for days, never freezes, so it must be the wires to the analog inputs... Unless someone has a better idea...
Other than usual decoupling with a pair of capacitors from each analog input to ground would anyone have a suggestion what to do? I hesitate to use capacitors to not affect the sampling speed...
Wawa:
Do you use internal pull up or external resistors. What value?
Since I have to determine which two wires are in contact, each Arduino analog input has a voltage divider of total 1 MOhm <== EDIT: this is mistake, sorry, the total divider resistance is about 15 k Ohm
Wawa:
What sort of wire. Shielded, twisted?
Two simple 3-conductor signal cables. No shielding, to twisting or braiding.
Grumpy_Mike:
You are not going to affect anything in regard to your sample rate, they are way too slow.
Unfortunately I need to catch some very brief contacts, of the order of 10 microseconds
100 foot long wires are radio antennas, so at the very least you'll need to clamp high frequencies to ground at
the inputs with 1nF ceramic cap or similar. But what may be happening that knocks the chip out is spikes
from mains switching or something like that - the spikes put (parts of) the chip into CMOS latch-up. You must
prevent rogue voltages reaching the input pins. Normally a series resistor of a kohm or so with two schottky
diodes to ground and Vcc will do the job.
"Regular" noise won't cause a crash/freeze (unless there's something wrong with your code). But, "bad things" can happen with high voltage noise spikes. A resistor & "protection diodes" should take care of that. But, if you're getting enough voltage to crash the Arduino, you'll also get false triggers.
Run the Analog Read Serial Example to see what kind of noise you're getting.
[qutoe]see is that in use there is 100 ft (30 meters) of wire to 6 analog inputs. The device is simply sensing the contact between the ends of those 6 wires, and tells which two wires are currently touching. [/quote]Contact/no-contact is "conceptually digital", not analog. (I understand what you're doing and I've seen it done before, but it kind-of bugs me when people use analog when they really want digital.)
Since I have to determine which two wires are in contact, each Arduino analog input has a voltage divider of total 1 MOhm
There is no need for a voltage divider (unless you haven't told us everything) and there's no need for such a high resistance. Try a 1K pull-up resistor (with "contact" pulling down to ground). The lower resistance will probably solve your problems (and you probably won't need the over-voltage protection).
CORRECTION: The divider total resistance is 15 k Ohm (that 1 M I mentioned was for a battery voltage readout in another project that must have minimal leakage, in order to sustain months on a coin cell). I am sort-of forced into this order-of-10k resistance since I have to sense the contact with under-100-Ohm as good, and over that ignore.
The analog readouts on the bench are noise-spread in the range of about 300 units in the total 0-4095 range. I may try to record the lines readout in the field, that may show the noise higher than on the bench - thanks for the pointer. The thing is I did not see false readings in the field, e.g. indication of a contact while the object that creates the contact is physically not there, but that may be because the code asks for readout on both lines to be in range to call them "in contact", so spurious signal on all wires may bring one in range but will pull others out at the same time...
DVDdoug:
Contact/no-contact is "conceptually digital", not analog. (I understand what you're doing and I've seen it done before, but it kind-of bugs me when people use analog when they really want digital.)
There is no need for a voltage divider (unless you haven't told us everything) and there's no need for such a high resistance. Try a 1K pull-up resistor (with "contact" pulling down to ground). The lower resistance will probably solve your problems (and you probably won't need the over-voltage protection).
Yeah, analog read deeply bugs me too, but this is a real-world application in which the standard states something to the effect of:
event 1: line 1 in contact with line 2, and over 100 Ohm with 3
event 2: line 1 under 100 Ohm with 3, or 2 under 100 Ohm with 3
Then there are cases with 500 Ohm cut-off resistance...
Zigmund:
Other than usual decoupling with a pair of capacitors from each analog input to ground would anyone have a suggestion what to do? I hesitate to use capacitors to not affect the sampling speed...
Have you got decoupling capacitor on the arduino's DC supply pin to ground as well? Could put some there too.
Zigmund:
The device is simply sensing the contact between the ends of those 6 wires, and tells which two wires are currently touching. Is it possible that the wires pick up so much by induction, that a shot knocks the MCU (ARM SAMD21G18) unconscious?
So the aim is to build a device that monitors 6 long wires, and the remote ends of those wires are initially floating. And the device needs to be able to detect whether or not any PAIR of wires (at the remote end) touch each other, right?
Does the device need to also be able to determine if say triplets of wires are contacting each other?
OK, here's the actual schematic. 6 long wires are attached as two 3-conductor signal cables, and their ends are contacts that a rolling metal object may connect. Wires are what they are, my device connects to them, replacing an old analog circuit. The wires are connected to "top line" and "bottom line" connectors. For those not familiar with the SAMD21G18 chip, the pins that T1, T2, B1, and B2 are connected to are analog inputs.
There are several "event" scenarios, and most include 3 wires. Events I am sensing have limit of 100-500 ohm external resistance. Putting 1 k resistor in line would seriously reduce the sensitivity...
This has been one of the most "fun" projects since I can never get the device to freeze on the bench where I have instruments and computers to attach to serial or USB ports for diagnostics, but it easily happens in the actual environment where bringing computers and instruments is a big bother.
Why do you need the long wires, you are using a wifi connection, why not place the controller at the "rolling metal object"?
Have you placed say a 100uF and 0.1uF capacitors across the supply to gnd at the "rolling metal object" end?
How do the wires contact the "rolling metal object"?
If you have the project on the bench and it works okay, is that with the 100ft of cable still in circuit?
The device as at the end of the wires and that is the only place I can change. The contacts at the business end of the wires are 2 mm round, like nailheads. The rolling object is just a chunk of metal moving by inertia. No power of any kind there. I cannot do anything on the contacts end of the wires.
I brought the wires into the shop, so it's a complete device, including actual wires, that works continuously on the bench for 48 hours, but freezes in actual use in no longer than 30 min to maybe 2 hours. went back-and forth between the shop and actual floor several times, and consistently got the same result. The device is LiPo battery powered with 3.3 V buck regulator, so no mains connection - the only thing from the device to the outside world is 6 long wires, that are never connected to anything, except sometimes to each other, but the device freezes even when the wire ends are idle.
Last night I followed GMike's advice and installed 33 Ohm inline, 150 pF behind it to ground, on each of the four analog inputs. Still fine on the bench, I'll have it in actual use for 3 hours this afternoon.
Unfortunately, after flawless run yesterdayI am still having the MCU knocked out multiple times this afternoon. In regular use, it is. Back in the shop, it's been two hours of beating the thing, rubbing the wires and dragging them on the floor, and the thing runs nicely w/o a glitch. Aaaargh... So a pair of Schotky diodes? (I avoided those since I had none in my spare parts bin).
Hi,
The device is battery powered, it uses WiFi to communicate, why do you have 30m of wires?
Why can't the controller be at or near the input contacts?