Serial to USB communication problems

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

I have been having trouble with serial to usb adaptors. Sometimes characters get lost or corrupted in both transmit and receive. It seems I need a different serial-->USB adaptor/driver combintion, but what?

Here is the layout:
Atmega32 running at 8mhz, uart @ 9600 baud.
Serial adaptors tried: Keyspan, FTDI, Prolific.
Win7 64 drivers from the coresponding manufacturers website.
Oparating system: Windows 7 64bit home on a 6 month old cheap HP laptop.
Terminal program: MTTTY or Terraterm.
RS232 level converter from the AVR uart : ST232

Everything works fine on a real serial port on a desktop, and all the adaptors work fine on Linux, right out of the box. Even atmel's Avrprog under wine works fine.

The FTDI has troube on a winXP laptop, but the Keyspan and the Prolific work fine.

I've tried shorter usb cables, and made sure they where the shielded type.

Any suggestions appreciated.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've never had any problems with an adapter using the FTDI chip with WinXP and Win7 x64 laptops.

Leon Heller G1HSM

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
The FTDI has troube on a winXP laptop, but the Keyspan and the Prolific work fine.

So use the KeySpan and move on... :wink:

There are many threads about various USB to Serial cables and chip sets and bottom line is that some work better than others, esp with any given hardware / OS combination.

Laptops are notorious for often not having optimal serial port hardware. What works for most people, using most devices, is good enough if it saves a buck or two, (or less, really), on the motherboard.

That said, a 8MHz Xtal and 9600 baud rate should give a baud rate error of < 0.2%, 10 times better than generally needed, so this ought not be the issue.

Are you sure you are running the AVR from the crystal, and not from an internal osc?

Do you have a very clean power supply for the AVR?

Do you have by-pass caps on the AVR, across each V+ and Gnd pin pair, and (AVcc and its Gnd)?

Do you have an O'scope to look at the ST232's output? If you accidentally used an incorrect cap you won't get a true +/- 8 V output that that chip is suppose to supply, and some serial ports, (on laptops), make be particular about the signal.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello! I suggest such solution: connect usb-rs232 converter to your laptop. Short both rx and tx line (rs232). Run some test, for example press and hold for a minute button 'a' on your laptop. See in terminal program. Are there any received corrupter character( for example 's' instead of 'a')? If yes it means that your converter is bad, if no - check AVR hardware, code and so on.
Good luck!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

The FTDI has troube on a winXP laptop

Define what you mean by "trouble"? Also is the 8MHz internal or a crystal?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for all the replies. The 8mhz is from an external crystal with 22pf capacitors. The power for the MCU is 5v from a 78l05 with 22uf, and .1uf cap near the MCU power pin. The ST232 has 5 1uf 16v capacitors, but I will put the scope to the signal and make sure it has full +- rs232 voltages.

The "trouble" in all cases, is that my stream of comma separated numbers ends up with letters and other characters, missing commas, missing returns. It may run for 20 minutes just fine, then the problem occurs at seemingly random intervals, 5 to 500+ characters apart. Or the trouble will start upon power up. Or sometimes not at all that session.

Yes the Keyspan works for the Win XP laptop, but not the Win 7 laptop.

I did try the loop-back (rx to tx) test on a USB converter once a while back, but nothing came through. It seemed to me that the test worked on a real serial port on a desktop, but not on the usb-serial converter. I'll double check this.

One thought I had was to find a serial-->USB that uses the slower USB speed 1.5 Mbit/s "Low Speed" instead of 12 Mbit/s "Full Speed" Does anybody know of such an item?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
The ST232 has 5 1uf 16v capacitors,

?

My ST232 data sheet says these should be 0.1 uF caps.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

HI,
I had .1 uf caps on the st232, but changed them to 1uf, thinking that might help. There is a little note in my st232 datasheet that says "C1-4 can be 1uf ones" I use 1uf ceramic capacitors, so I'm not thinking too high ESR is a problem. Either way the problem remains.

Anyway, Here is a photo of the scope. 5v/division with 0 in the middle, and there looks to be a good +-10v.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

n81641 wrote:

I did try the loop-back (rx to tx) test on a USB converter once a while back, but nothing came through. It seemed to me that the test worked on a real serial port on a desktop, but not on the usb-serial converter. I'll double check this.

It must work. For OS (windows, for example) real and virtual port are similar.

BTW my usb-rs232 converter has been working for a week. It's something like a test for my equipment. Every 50 ms about 10 bytes are transmitted and received at 38400. Totally 2 - 3 errors has been noticed...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have probably used 2 dozen USB-Serial cables over the years. At one point I had a bad cable that dropped characters. Two others of the same brand brought at the same time, never dropped characters. Just saying, it might be a hardware failure.

Is the AVR serial port interrupt driven or polling? Are you using a circular buffer?

One time I was working on a interrupt driven serial port that would corrupt a single character every 16-20 hours. It didn't matter if the port was transmitting characters constantly at 19200 or 200 characters once a minute.

Turns out the serial buffer transmit input pointer was being incremented before the byte was stored in the buffer. About once a day the transmit interrupt would occur between those two instructions, voilà! Corrupted character.

Took weeks to find it, I'll never make that mistake.

Jeff

Jeff Dombach, JLD Systems
"We do the stuff behind the buttons!"
Your source for embedded solutions with a 100% Guarantee.
http://www.jldsystems.com
Phone 717.892.1100

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just tried the loopback with an FTDI adapter and a Proific one. Didn't work (under linux), but both work fine for rx and tx to the AVR. The FTDI has rx and tx LEDs and with the rx tx connected, the tx led blinks, but not the rx. That I can't explain. The real serial port loopback works fine.

When they bring the Win7 laptop back, I'll try the same on it.

Yes, I'm using interrupt driven uart and a circular buffer. I'll double check the code to make sure that the interrupt can't occur while writing to the buffer. That might explain some things, except that all these adapters work flawlessly with linux.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As I wrote the last post I realized that the problem may not be OS related, but PC related. We use the different laptops, connected to the AVR, in the field to measure temperature and flow in a duct with a blower. The duct is grounded via the blower's cord, but there's no guarantee that ground is good at random locations. There may be static buildup in the tube, and discharges causing all of this. I need to pay attention to whether the laptop is on the mains or on the battery. I've seen some of the laptop power supplies bring the ground through, and others the ground is not connected, I'm not sure which we have on which.