A more stable way to develop / debug serial communication?

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

For several days now I'm writing & debugging code that communicated between and AVR and another device over UART. To "tap into the action" I am using my computer, running a terminal program and a small USB2SERIAL dongle. I have several types, some dirt cheap and others more expensive. The problem is that when you connect and disconnect things all the time Windows or the software will start going crazy and at some point the device won't get recognized. This happens with all the adapters I own, and they use different drivers.

 

Perhaps there is a better solution? Something like a stand-alone serial monitor that is robust enough not to lose connectivity when things connected and disconnected all the time?

 

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

slow_rider wrote:
The problem is that when you connect and disconnect things all the time Windows or the software will start going crazy
Your problem is presumably where you do that connection/disconnection. If you actually unplug USB plugs then Windows is famous for getting confused, especially if applications already have COM ports being provided by those USB devices open. So just leave USB-serial leads plugged in all the time and arrange to break the link at the other end - AVR connection. Nothing in Windows should get confused by that.

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

clawson wrote:
If you actually unplug USB plugs then Windows is famous for getting confused, especially if applications already have COM ports being provided by those USB devices open

Indeed.

 

just leave USB-serial leads plugged in all the time

Absolutely.

 

This is what I do - and I rarely get problems.

 

If I do get problems, it usually boils down to USB plug having been pulled while it was "in use".

 

For the minimisation of clutter, I recommend getting some multi-port USB-to-Serial adaptors (having 4 ports in use at once is not uncommon).

 

If possible, I use only FTDI adaptors; I don't think they've ever given me any problems - but other brands certainly have ...

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

slow_rider wrote:

Something like a stand-alone serial monitor that is robust enough not to lose connectivity when things connected and disconnected all the time?

 

Or a logic analyser, most of which do decoding of serial data these days.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

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

awneil wrote:

If possible, I use only FTDI adaptors; I don't think they've ever given me any problems - but other brands certainly have ...

 

Somewhere I've seen an article explaining how to use FTDI adapters such that the allocated COM port stays with the adapters based on its unique ID.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

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

Brian Fairchild wrote:
 use FTDI adapters such that the allocated COM port stays with the adapters 

That is the way they "just work" - in my experience.

 

This is another way in which I find them superior to cheaper brands.

 

There was a discussion here about this recently - some people, it seems,  don't like that behaviour ...

 

EDIT

 

I am talking above about the COM port number remaining the same on the same PC - were you thinking of having it come up as the same number of different PCs ... ?

 

EDIT 2

 

What I've often thought would be a nice idea would be to have a little display on it which tells you what COM number it's on.

 

I guess *nix could say the ttyUSB number ... ?

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Fri. Dec 1, 2017 - 02:19 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Using a PC  terminal program is often a great approach, especially if one needs to log the output for close inspection.

 

For many PC to micro projects, where one is just sending "commands" and uploading small amounts of data, I often just plug in a little micro and LCD project made years ago.

It is, essentially, a small terminal emulator and displays the data on a multi-line LCD.

 

One can use it just as an output device, monitoring the comm's line, or use it for bi-directional comm's.

In that case pushing a push button switch can send canned data transmissions.

 

It takes up a lot less room on the bench that a PC!

 

Photo shows an Xprotolab "comm's monitor"  debugging the USB to micro comm's link.

 

JC

 

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

DocJC wrote:
Using a PC  terminal program is often a great approach, especially if one needs to log the output for close inspection.

Indeed.

 

Having a terminal which can timestamp its log is particularly useful.

 

The main trouble with a terminal is that it can't monitor both sides of the communication between some other devices.

For that, you may be able to get by with two terminals - but that's quite cumbersome.

 

And, of course, a terminal isn't much use for binary data.

 

In such cases, I would tend to find a microntroller with (at least) 3 serial ports - and use that to combine the 2 directions into 1 and forward to the PC

It could also do some translations, if required...

And do "drop & insert", etc...

 

Of course, Brian's suggestion of the Logic Analyser is excellent - especially with the small, cheap ones available these days.

 

EDIT

 

Example of using 2 terminals to monitor both sides of a conversation: https://www.avrfreaks.net/comment...

 

 

And another advantage of the Logic Analyser: it will show you your actual bit timing - whereas a terminal may show nothing or junk when the baud rate is wrong.

 

 

EDIT 2

 

Extended explanation of the 2-terminal debug setup: https://www.avrfreaks.net/commen...

 

 

 

#DebugSerialComms

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Fri. Mar 23, 2018 - 08:53 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A sort of "grown up" version of Doc's idea might be to use an Rpi. Yup you need a monitor but being Linux, not Windows it's less likely to be confused by USB extraction / insertion.

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

clawson wrote:
A sort of "grown up" version of Doc's idea might be to use an Rpi.

Indeed

 

 

Yup you need a monitor

Not necessarily - you can get TFTs for the RPI, or use remote access; eg, VNC

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

I am talking above about the COM port number remaining the same on the same PC - were you thinking of having it come up as the same number of different PCs ... ?

 

Found it. It's a tweak so that the COM number stays attached to the physical USB port.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

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

Brian Fairchild wrote:
 COM number stays attached to the physical USB port.

Ah - so that's exactly what I don't want to happen!

 

The "normal" behaviour for FTDI is that the COM number stays attached to the particular adaptor.

 

I like it this way, because it means I can write, say, "COM24" on the cable/adaptor and not have to worry about which physical USB port I have to plug it into to get "COM24", or whether I'm using a hub, etc, etc, ....

 

 

COM number stays attached to the physical USB port

So, in this case, does the same COM number stay attached to the physical USB port even when you plug a different adaptor into that USB port?

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

So, in this case, does the same COM number stay attached to the physical USB port even when you plug a different adaptor into that USB port?

 

That's how I read it.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

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

I guess I could live with that.

 

But I'm pretty sure that hasn't happened with other adaptors which get a different COM number per USB port - I think they's also given a different COM number for a different adaptor in the same USB port.

 

 

I think Linux just calls the first one you plug in "ttyUSB0", then next one "ttyUSB1", etc, ... ?

So the number is entirely unrelated to either the particular adaptor or the physical USB port ?

 

But at least that means you don't get COM numbers being "reserved" ("hogged"?)by things you've used, but will never use again ...

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
But at least that means you don't get COM numbers being "reserved" ("hogged"?)by things you've used, but will never use again ...

Adafruit Learning System

How to Find Hidden COM Ports

https://learn.adafruit.com/how-to-find-hidden-com-ports?view=all

...

... ghost devices ...

...

 

"Dare to be naïve." - Buckminster Fuller

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

clawson wrote:
Yup you need a monitor ...
The value-added part of PlatformIO has such a monitor or could go via a terminal server.

 

http://docs.platformio.org/en/latest/userguide/remote/cmd_device.html#platformio-remote-device-monitor

ChiliPeppr

Hardware Fiddle

http://chilipeppr.com/

Create Javascript software workspaces that talk to your hardware. Use one of our hugely popular workspaces or create your own by forking one you like.

...

(about mid-page)

Serial Port JSON Server

The heart of ChiliPeppr is a server that links your serial port devices and your host controller like a Raspberry Pi via websockets to your browser.

...

 

"Dare to be naïve." - Buckminster Fuller

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

gchapman wrote:

Adafruit Learning System

How to Find Hidden COM Ports

https://learn.adafruit.com/how-to-find-hidden-com-ports?view=all

...

... ghost devices ...

...

Great - thanks for that!

 

I'm over COM90 - so this will come in handy ...

 

laugh

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...