6

I have bought a device which has an ATmega microcontroller and an FTDI chip which connects to a computer through USB. The FTDI is used only as an RS-232-to-USB adapter.

My problem is that this device hangs up the PC when some of the machines are running. I changed the cables to thick, heavy-shielded ones. Also the cable is in a steel conduit. And the device itself is inside a 2 mm stainless steel casing. The case connected is to ground.

Amazingly, the problem is not present when working with this device, but with a plain RS-232 version. (The RS-232 version works even with el-cheapo cable. no problems.)

My questions are:

  1. Is the problem related to a poor design of the device or is the FTDI chip fault? I am now confident that it was due to a bad design of the converter.
  2. What would be the best pick for a chip to convert RS-232 to USB in an industrial environment?
  3. How much work is it to use a microcontroller with a built-in USB port, for example an Atmel microcontroller? Will it be cheaper and faster?

The only requirement is that there must be drivers both for Windows and Linux for the converter.

Peter Mortensen
  • 1,676
  • 3
  • 17
  • 23
drzymala
  • 247
  • 2
  • 10
  • Do you have a scope? If you scope the TX and RX lines you might see the problem. Also what is the board (Arduino ?) ground connected to or is it powered off the USB? – geometrikal Apr 10 '13 at 05:28
  • Oh and how long is the USB cable and why not just use rs232? Does the board have a UART to rs232 converter chip on it? – geometrikal Apr 10 '13 at 05:33
  • The machine is now out of my reach. The board was a custom pcb. The power connected to 12V power supply from the PC with common ground. Cable circa 5m long. Now it works superb with the RS232 version of the device. Yes, there is a chip to convert RS232 to TTL. I am asking for a USB converter because I need to build a similar device but with USB. I have built a device with FTDI in the past but now I am affraid that FTDI is not so good in a high magnetic field conditions. – drzymala Apr 10 '13 at 05:41

4 Answers4

5

One possible cause for the problem report described, is a level mismatch between ground at the PC and at the industrial equipment side. This comes from similar personal experiences designing for industrial applications.

Either that, or some significant transients traversing the connections - RS232 is more forgiving than USB in some ways.

One thing to check is whether the two grounds are connected, and even if they are, whether there is significant enough potential difference for measurable sustained current, DC or transient, to be passing along the ground to ground connection / cable shield.

A resolution would be a galvanically or optically isolated implementation: The industrial sensors / actuator control lines to be isolated from the PC side through (a) transformer coupling, or (b) optocouplers, depending on the specific design requirements. The microcontroller device could be placed on either side of the isolation barrier.

In practical terms, the easiest way to implement this, once the need for isolation is established, is to use a standalone USB isolation device such as this one from Olimex, on the PC to board USB connection:

USB isolator.

Another such device is the USB Port Guardian, quite a bit better packaged, but essentially similar in functionality.

Neither of these devices seem to survive well in extremely harsh environments though - we have faced some device failures in deployed set-ups, but your environment may not be as challenging.

At a design level, Analog Devices offers single-package USB isolation parts in their iCoupler line. Incorporating such a part into the design is not very complicated, and the Analog Devices design support team is very proactive if you need help.

Specific to the 3 points in the question:

  1. The problem is most likely to be design-specific as noted above, rather than an issue with the FTDI part.
  2. This would require specifying the actual industrial envornment factors, i.e. temperature et cetera. Maxim and other manufacturers have parts specified for industrial temperature ranges, but if your PC is in there, and presumably its operators, the environment is probably not that harsh.
  3. The jury is out on this one: There are proponents of both the FTDI and the integrated USB MCU schools of thought. The actual cost advantage, including design cost, would vary situationally.
Anindo Ghosh
  • 50,188
  • 8
  • 103
  • 200
  • 1
    Thank you for your great answer! The only factor are big induction motors that are creating magnetic fields. I forgot to mention, another device is connected to the same PC through RS485, so it's probably not an issue with signal levels. – drzymala Apr 10 '13 at 06:05
  • @martini RS485 is very forgiving in the industrial space, compared to USB: It was designed for harsher electrical environments. – Anindo Ghosh Apr 10 '13 at 06:10
  • I agree. RS485 is the winner. But in your opinion is USB better than RS232? I think it is! Because USB uses differential signaling just like RS485. Only with lower voltage. – drzymala Apr 10 '13 at 06:22
  • @martini Yes, I would prefer (isolated) USB if I couldn't have RS485, if only because it is becoming progressively more difficult to find RS232 hardware in computers. Industrial signaling however isn't what USB is for, in that space the traditional 4-20mA, RS485, and perhaps radio, rule. – Anindo Ghosh Apr 10 '13 at 06:30
  • 1
    I've had good success with the [Keterex USB-150](http://keterex.com/kxusb150.php) isolator as well. – Adam Lawrence Apr 10 '13 at 12:29
  • You would be the winner, but @Spoon's answer is more valuable for me right now. I appreciate your time and effort in answering my questions. Your advice with signal isolation is very good in number of reasons. So thank you again for your help :) – drzymala Apr 13 '13 at 22:14
  • 1
    The isolation issue is very real and I follow it in addition to the pure USB-RS232 timing issue. – Spoon Apr 14 '13 at 08:39
4

Anindo's answer is bang on - I strongly suspect you have too much grounding and the PC USB ground is being dragged around by the machinery.

In our experience, FTDI chips are about the best so I'd be very reluctant to blame them as the cause of failure.

USB's data lines may be differential but it is not isolated and the power & GND lines could go anywhere in the target device - not good if the target device has ground connections which are not common with the PC.

Many USB controller chips in PC's will shut down if they detect over-current conditions etc. so it's entirely possible the machinery is dragging the power/ground lines around and giving the PC a heart attack.

I would look at running the 232 to the PC and then having the converter at the PC end, or even converting to RS485/422 (plenty of Maxim chips to do this) and back at the PC end. There are FTDI USB/232/485 boards on eBay for $10, we use a lot of them.

John U
  • 7,041
  • 2
  • 21
  • 34
  • Our machines have common ground and are not using much power. It's the other machines (not connected to ours) that are polluting the air with magnetic waves. The issue was a bad design of the converter. My question now is which of the chips do you personally prefer? – drzymala Apr 10 '13 at 08:08
  • Indeed, isolating the serial data lines is likely a more robust (and technically simpler) solution than isolating the USB bus. – Chris Stratton Apr 10 '13 at 17:59
2

At my last company we found that USB-to-RS-232 converters can have a problem when they expect an almost instant responce from the RS-232 device. I was advised by the design engineer for our equipment that USB uses data packets. So when using USB, unless the software/drivers force a USB packet of data to be sent, the USB driver can hang around for more than a second (5000 ms) waiting for the packet to be filled before sending the incomplete data packet.

This meant that a lot of older DOS/Windows programs where they monitored RS-232 status lines would time out. The older programs often used timing loops based on looping a certain number of times... So as the PCs got faster, the polling got faster. As the length of time the polling continued to effectivly get shorter, USB came along.

The polling effectively became a memory location... (The drivers are usually optimised for maximum data packet throughput and didn't pass the status information on, because it was waiting to fill a packet). The drivers can sometimes be adjusted to help with this. FTDI drivers can adjust a lot of values in their configuration file. (Great for non-standard data rates.)

This meant we often had to run programs on desktops with RS-232 ports or drag the laptop base station out to the equipment to get it to work.

Additional information

See page 6 of the application note Advanced Driver Options for USB time out adjustments...

And for odd baud rates up to 3 Mbit/s, see Configuring FT232R, FT2232 and FT232B Baud Rates.

Spoon
  • 1,292
  • 1
  • 8
  • 8
  • The FTDI driver documents were good the last time I looked and did allow some easy fixes. – Spoon Apr 10 '13 at 08:09
  • So which chip/chips would you pick if you were to design a serial-to-usb device? – drzymala Apr 10 '13 at 08:19
  • I would clone this design. Not having used it I couldn't swear it's what you need but at least you can try it .http://www.ftdichip.com/Support/Documents/DataSheets/Cables/DS_Chipi-X.pdf – Spoon Apr 10 '13 at 11:25
  • See page 6 of http://www.ftdichip.com/Support/Documents/AppNotes/AN_107_AdvancedDriverOptions_AN_000073.pdf for driver options to do with latencey issues. – Spoon Apr 10 '13 at 11:29
  • Changing the USB time out resoved our problems.. see the addition to the answer. – Spoon Apr 10 '13 at 11:35
  • The response time from the hardware is really important for me. I am really thankful for your advice. – drzymala Apr 13 '13 at 22:04
  • @Anindo answer relating to isolation is still Very Important. USB scopes demonstrate the worst of this where the scope and the PC are killed because the isolation was missing... – Spoon Apr 14 '13 at 08:49
1

I am not sure this is you problem, but on my previous PC the use of an usb-serial converter in combination with certain other applications (especially audio and video) could cause my PC to hang and often reboot. This did not happen when I used the same gadget and application with the real (hardware) serial port. I never found out what the cause was, I just learned to avoid watching video during intensive USB serial port use. AFAIR this happended with both FTDI and prolific converters. It could have been a SW problem (windows version, USB stack) or maybe hardware (flaky motherboard). With my new PC (different windows version) I have never encountered this problem. (Which is all the better since it does not have a hardware serial port.)

Wouter van Ooijen
  • 48,407
  • 1
  • 63
  • 136
  • Thank you for your answer. In my case the problem was directly related to turning on high power electric motors. But yes, now I am using directly the hardware serial port and it is working quite well. – drzymala Apr 10 '13 at 07:27