Monitoring freezes

Python / C / Arduino serial monitoring programs freeze at seemingly random times. When the program has frozen, /dev/ttyUSB0 disappears and a /dev/ttyUSB1 appears. I have Kubuntu 10.04, kernel 2.6.32, Arduino 022. Onewire program in Arduino. Linux serial interface problem?

/var/log/kern.log shows:

Feb 11 18:12:58 localhost kernel: [832674.056051] hub 5-0:1.0: port 1 disabled by hub (EMI?), re-enabling... Feb 11 18:12:58 localhost kernel: [832674.056060] usb 5-1: USB disconnect, address 77 Feb 11 18:12:58 localhost kernel: [832674.056336] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0 Feb 11 18:12:58 localhost kernel: [832674.056357] ftdi_sio 5-1:1.0: device disconnected Feb 11 18:12:58 localhost kernel: [832674.300040] usb 5-1: new full speed USB device using uhci_hcd and address 78 Feb 11 18:12:59 localhost kernel: [832674.502533] usb 5-1: configuration #1 chosen from 1 choice Feb 11 18:12:59 localhost kernel: [832674.512990] ftdi_sio 5-1:1.0: FTDI USB Serial Device converter detected Feb 11 18:12:59 localhost kernel: [832674.513014] usb 5-1: Detected FT232RL Feb 11 18:12:59 localhost kernel: [832674.513016] usb 5-1: Number of endpoints 2 Feb 11 18:12:59 localhost kernel: [832674.513018] usb 5-1: Endpoint 1 MaxPacketSize 64 Feb 11 18:12:59 localhost kernel: [832674.513020] usb 5-1: Endpoint 2 MaxPacketSize 64 Feb 11 18:12:59 localhost kernel: [832674.513022] usb 5-1: Setting MaxPacketSize 64 Feb 11 18:12:59 localhost kernel: [832674.513755] usb 5-1: FTDI USB Serial Device converter now attached to ttyUSB1

Hmm, what hardware are you using? Do you get the same problem with nothing connected? It could be a large power drawn from some component temporarily resetting the Arduino and FTDI chip.

I have Duemilanove, using power from USB, measured VCC +4,74 V on the connector. It is a bit low but I think these chips have a wide range. I connected a Onewire bus with 7 x DS18B20 sensors to the board. Sensors draw max 1.5 mA. I could try a single sensor, perhaps one of them is faulty.

It now looks like this is a EMI problem. When a certain compact fluorescent lamp or a radio receiver is switched on/off, Arduino resets and the red
led ligths up momentarily. That causes the computer to think that the device at /dev/ttyUSB0 was removed.

I earlier used owfs and digitemp with DS9490R type adapters and they didn’t care about EMI.

I don’t think that the interference comes through the mains supply. I moved the computer to a dedicated supply line and resets still occurred.

I suppose that the interference jumps to the Onewire cables from poorly designed equipment with radiated electric or magnetic fields. I use
unshielded cables. My network has three Onewire buses where each cable is 5 … 10 m long. Sensors are in parasite mode.

I could try shielded cable but the trouble is that rewiring the house is such a big task. I guess that’s the only way to study further. Or maybe I could switch from parasite mode to active 5 V supply.

Can you not make a simple bandpass filter that attenuates signals below and above standard onewire frequencies?

I discovered that when I removed the USB cable, switching the radio receiver on / off did not cause failures anymore. So I thought that I will get a USB cable that has ferrite beads. I don't know if that helps but I'll give it a try. There are not many such cables around, is it because they don't pass the frequencies of USB 2.0?

I earlier said that Arduino was reset; however this probably does not happen and the red led which lit up was in the serial bus interface. So it seems that the USB cable picks up some noise and causes FT232R to fail.

I tried a shielded USB cable but no success. I am not sure what the shield was like, if it had any, I just measured with a multimeter that the resistance between the connector shields at the two ends was about zero.

I would assume that someone else has had this problem too. My system should be similar to the thousands around. Still I could not find on the forum any relevant posts. Strange?

Thinking about the use of a shielded USB cable, suppose that the interference gets into the shield and from there to Arduino. The PCB has no proper ground because it is grounded only to the computer via the USB cable and that has some impedance.

From what I recall about EMC issues in my earlier working life, cable shields must have a good ground connection. Devices should have a metal enclosure which is grounded and cables entering the enclosure should preferably be connected via a pass-through capacitor that leads any noise to the enclosure.

Now my Arduino PCB has no enclosure and it has poor ground. Noise coming from the USB cable shield makes the ground plane on the PCB noisy. This then has the effect that the chips behave badly.

I found this site where it said:

"USB cable shielding:

Shield should only be connected to Ground at the host. No device should connect Shield to Ground."

The Duemilanove I bought from ebay seems to be a clone. It has the USB connector shield connected to the PCB ground. I could try to disconnect these. That should stop any noise in the cable shield from entering the PCB. I suppose that the shield is still grounded at the computer end where ground probably is better.

Now it seems to be better. I did two things: - put a simple RC filter in each Onewire cable - use a shielded USB cable

Can't say if it will prevent all freezes, time will show. I'll also consider if I can do anything to the equipment which seems to emit the disturbances. I suspect that they emit noise through their power cable. First I'll check if there's any filter at all.

Just want to add an observation; feeding +5 V to the sensors instead of using them in the parasite mode seems to make the system more tolerant to noise.

I found an unexpected cause for this EMC problem. I measured 20 V AC swing in my desktop's case and also in the ground of Arduino connected to the desktop. My house dates back to the time when it was allowed to install wall outlets with L and N wires only without protective earth, in living rooms and bedrooms etc. I live in Europe, regulations may have been different elsewhere.

A TV card in the computer gets its signal from a rooftop antenna. The antenna is not grounded and the antenna cables seem to pick up noise from the power lines. Here the picture gets a little blurred but anyway when I connected the shield of the coaxial antenna cable to ground, the measured voltage fell to zero. Another solution would have been to change to wall outlets with PE. So it was a grounding problem.

I thought I should share my solution to this problem with anyone who might have similar problems. I’ve had a long and tedious struggle and I’m glad I
finally found a working solution.

First a few notes just to recap the problem.

I’m monitoring temperature in my house with Duemilanove to which I connected several 1-wire cables with DS18B20 sensors attached.
I had to connect Arduino with a 5 m cable to the computer (the long cable makes things worse).

My Linux computer sometimes killed the designated serial port /dev/ttyUSB0 and activated /dev/ttyUSB1 and then the program
froze (all USB ports behaved similarly for numbers up to USB10 and even backwards depending on what other ports were reserved).
I noticed that this happened when I switched power off in an old stereo receiver in the same room.

I tried just about everything that I could think of until I got one of those tiny USB expansion boxes. I placed it close to the Arduino with
a < 1 m cable which had EMI suppression chokes at both ends. Usually USB cables have no chokes but I found one shop that sells them.

I don’t really understand what was going on in Arduino / computer. I suspect EMI caused some USB communication error which the
computer then interpreted as if the USB device was detached.

Now the program has been running OK for a few weeks.