Author Topic: Best way/chip for an easy embedded interface between a PC <==>MCU ?  (Read 1190 times)

0 Members and 1 Guest are viewing this topic.

Offline SuzyC

  • Frequent Contributor
  • **
  • Posts: 546
Thanks in advance to anyone who can offer me some advice!

I have looked at the FTDI website and there are many choices, which is the easiest, cheapest, best interface for PC<-->MCU communication.

 The chosen chip will become part of the MCU PCB.

 The MCU is operating at 5V

The PC is operating with WinXP SP3, has USB 2.0 ports and I am using VB6 to write code (PC cannot be changed to a newer op sys).
« Last Edit: August 18, 2019, 05:39:56 pm by SuzyC »
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 19839
  • Country: nl
    • NCT Developments
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #1 on: August 18, 2019, 05:56:40 pm »
The best way is to have the USB software inside the MCU doing a virtual com port (CDC ACM device). That way the baudrate or any serial port parameter doesn't need to be set. It just works. I did one project for a customer where I used this and it makes life so much easier for them that they insist every product I develop for them has this type of USB interface. For Windows XP you'll need to create a .inf file which tells XP the USB VID/PID are a standard serial CDC port and install it as a driver.
« Last Edit: August 18, 2019, 05:58:12 pm by nctnico »
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 
The following users thanked this post: SuzyC

Offline MosherIV

  • Super Contributor
  • ***
  • Posts: 1374
  • Country: gb
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #2 on: August 18, 2019, 06:04:39 pm »
What does the interface do?

It is difficult to answer unless you give more details.

Most embedded processors have quite a few interface peripherals built in, eg usb and erthernet are very common. Wifi is starting to become well supported (built in erthernet + external transceiver devices).
There are also the old classic RS232.
 
The following users thanked this post: SuzyC

Offline SuzyC

  • Frequent Contributor
  • **
  • Posts: 546
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #3 on: August 18, 2019, 06:08:08 pm »
The interface provides a way to send commands and data to a MCU and then receiving data back from the MCU when data is ready to be sent and/or when requested by the PC. Comm speeds of 115200 would be fast enough.

The MCU is already chosen and designed into a machine control module that is now using the PC's legacy bi-directional parallel port.

I am not aware of MCU's that have virtual comm ports nor do I would like the extended learning curve to develop a LAN interface.
A LAN interface is not supported by the software I am writing the PC code with, and it would not be a good choice because it requires a very complicated revision of my PC and MCU code and its PCB and that would not be the best use of time and money.

I would be most pleased to find a solution using the UART peripheral built into almost all MCU chips that would interface with a PC USB port.

I am aware on EBay there are many fairly small USB-->Serial converter modules for Arduino, etc, but I would like to have a  single  chip solution on the existing PCB.
« Last Edit: August 18, 2019, 06:35:36 pm by SuzyC »
 

Offline MosherIV

  • Super Contributor
  • ***
  • Posts: 1374
  • Country: gb
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #4 on: August 18, 2019, 07:23:59 pm »
So it sounds like serial/RS232 is what you are after.
On the microcontroller, most offer some kind of serial peripheral. They only output logic level, 5V or 3.3V so the microcontroller is going to need an RS232 level converter like the old MAX232 chip.
Most will allow data speeds upto 115200baud and beyond.

Most modern pc do not provide RS232 ports anymore. If not, one of those usb serial adapters should work. I have used them many times before. Some are better than others, you may have to try a few before you find the right one.

I would not recommend trying to bypass the level convert ie 5V level RS232 on both ends, level convert is there to give noise imunity.

Whether you can achieve 115200 baud will depend mainly on how good the data lines are.
Experiment to see what data speeds you can get, you might get better.

Fyi virtual com port is just directing serial over usb. The host side just treats it as a serial comm port and the pc driver takes care of the conversion to usb. The micro end needs development of a usb serial device. Most micro vendors provide examples of this. On the micro, the output is usually in a buffer. Then you just connect usb to usb on both ends.
 
The following users thanked this post: SuzyC

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 5447
  • Country: fr
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #5 on: August 18, 2019, 08:08:14 pm »
Asking for the best way of doing this is like asking for the best programming language or something.

Anyway, since you mentioned "The MCU is operating at 5V", we can only assume that the MCU is a given and we can't change it. So if it doesn't have an embedded USB core, suggesting to use an MCU with integrated USB will not answer your question, and you'll need an external chip.

And that said, first tell us more about your requirements:
- What is the expected max data throughput?
- Do you want to support only WinXP? Is that a one-off project?
 
The following users thanked this post: SuzyC

Offline RoGeorge

  • Super Contributor
  • ***
  • Posts: 2432
  • Country: ro
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #6 on: August 18, 2019, 08:36:12 pm »
You are looking for CH340.  10 to 100 times cheaper than FTDI.
 
The following users thanked this post: SuzyC

Offline Fire Doger

  • Regular Contributor
  • *
  • Posts: 179
  • Country: 00
  • Stefanos
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #7 on: August 18, 2019, 08:52:38 pm »
FT232 https://www.ftdichip.com/Products/ICs/FT232R.htm
MCP2200 https://www.microchip.com/wwwproducts/en/en546923#additional-features
CP2102 https://www.silabs.com/products/interface/usb-bridges/usbxpress-usb-bridges
CH340 Chinese

For all of them you need decoupling, you can avoid controlled impedance in usb if its very close to the connector, for the rest look their datasheet.
I would go with CP2102, MCP2200 needs oscillator, ftdi killed chips in past with drivers and CH340 is for cheapass products
 
The following users thanked this post: SuzyC

Online Mr. Scram

  • Super Contributor
  • ***
  • Posts: 9470
  • Country: 00
  • Display aficionado
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #8 on: August 18, 2019, 08:54:08 pm »
You are looking for CH340.  10 to 100 times cheaper than FTDI.
What you pay isn't what it costs.
 
The following users thanked this post: SuzyC, SiliconWizard

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 7407
  • Country: us
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #9 on: August 18, 2019, 09:17:02 pm »
If you come off of the MCU board at RS232 voltage levels, there are cables that start with the DB9 and end with a USB connector:
https://www.amazon.com/Serial-Adapter-Prolific-Chipset-Windows/dp/B0753HBT12

If you come off of the MCU with 3.3V or 5V logic levels, there are cables like:
3.3V  https://www.amazon.com/Converter-Terminated-Galileo-BeagleBone-Minnowboard/dp/B06ZYPLFNB
5V    https://www.amazon.com/Serial-Adapter-Female-FT232RL-Windows/dp/B07RBK2P47

Any of these work, I have used them all.
« Last Edit: August 18, 2019, 09:18:37 pm by rstofer »
 
The following users thanked this post: SuzyC

Offline SuzyC

  • Frequent Contributor
  • **
  • Posts: 546
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #10 on: August 19, 2019, 12:26:11 am »
I have  >10 PC's with identical control PCB boards to modify.  115200 baud is fast enough. Just want to use a very easy to find USB  to USB cable(like those used to connect a PC to a printer) to connect to the modified control board.
----------
CH340, "what you pay, isn't what it costs"

I take that to mean that you get a lot of free trouble with this chip and to get it work right requires an enormous cost in time?
-----------
Why would and how could FTDI kill a chip with a driver??
-----------
May I offer a long serial stream of thanks to all that have gifted me with their advice and taken a moment to share their know how to implement a solution!

-------------
Looks like there are two recommended best choices     CP2102 and FT232RL

Which chip has the best easy to get it to work  with no crashes/it just works driver?
« Last Edit: August 19, 2019, 12:51:35 am by SuzyC »
 

Offline PCB.Wiz

  • Frequent Contributor
  • **
  • Posts: 407
  • Country: au
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #11 on: August 19, 2019, 01:03:32 am »
I have  >10 PC's with identical control PCB boards to modify.  115200 baud is fast enough. Just want to use a very easy to find USB  to USB cable(like those used to connect a PC to a printer) to connect to the modified control board.
...
Looks like there are two recommended best choices     CP2102 and FT232RL

Which chip has the best easy to get it to work  with no crashes/it just works driver?
Both are good, The CP2102N is newest version of CP2102,  but the FT232RL  is now quite old. The FT231X is probably a more modern choice.
Get an Eval board for each one, and try them.

Does the package matter ? Will you be making your own PCB, or buying a interface module ?
If buying an interface module, you need to consider form factor and cable used.
USB-A is cheap in a module, but those cables are now less common.
 
eBay has many CP2102 modules, tho the eBay FT231X modules seem to be very silly prices - maybe they target someone who mistakes currency conversions ?
eBay has better prices on the older FT232RL parts

 
The following users thanked this post: SuzyC

Offline PCB.Wiz

  • Frequent Contributor
  • **
  • Posts: 407
  • Country: au
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #12 on: August 19, 2019, 01:10:20 am »
The interface provides a way to send commands and data to a MCU and then receiving data back from the MCU when data is ready to be sent and/or when requested by the PC. Comm speeds of 115200 would be fast enough.

The MCU is already chosen and designed into a machine control module that is now using the PC's legacy bi-directional parallel port.

What MCU does this use now, and how fast does the parallel port send data ?

If this is a legacy retrofit, did you look at the USB-Parallel port adapter cables on eBay ?  You would need to try one, but that may be simpler than USB-UART and then some additional parallel step.
eg USB to DB25 Parallel Port 25 Pins IEEE-1284 Old Printer Scanner Cables Adapters.

 
The following users thanked this post: SuzyC

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 19839
  • Country: nl
    • NCT Developments
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #13 on: August 19, 2019, 01:18:47 am »
eBay has better prices on the older FT232RL parts
But these are likely fake. The problem with FTDI chips is that the driver kills fakes or doesn't work silently. This can lead to huge amounts of wasted time & frustration to track a problem. Don't use FTDI chips at all. The CP210x devices don't have a unique serial number so it will end up getting a different COM port every time you plug it in UNLESS you program a serial number yourself (not difficult but it is an extra step). All in all maybe the CH310 is a better choice if it has a unique serial number.
« Last Edit: August 19, 2019, 01:20:21 am by nctnico »
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline SuzyC

  • Frequent Contributor
  • **
  • Posts: 546
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #14 on: August 19, 2019, 01:32:01 am »
USB to parallel printer port adaptors have no programming language interface drivers for general I/O, their only use is to interface with the Win printer drivers.
« Last Edit: August 19, 2019, 01:35:55 am by SuzyC »
 

Offline SuzyC

  • Frequent Contributor
  • **
  • Posts: 546
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #15 on: August 19, 2019, 01:35:09 am »
"UNLESS you program a serial number yourself"

Do tell, how is this done?

-----------
Some replies recommend FTDI chips and never mention a problem.

It is beyond my imagination to see how any small company would have the resources(or any promise of profit) to undertake making clone  FTDI chips.
« Last Edit: August 19, 2019, 01:44:41 am by SuzyC »
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 7407
  • Country: us
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #16 on: August 19, 2019, 02:14:10 am »
What about documentation and API support?  If you plan to modify so few machines and you plan to use a chip solution, I would go genuine FTDI all the way.

Is USB HID a possibility?  If so, the drivers are built into Windows

FT 260 from FTDI
 

Offline PCB.Wiz

  • Frequent Contributor
  • **
  • Posts: 407
  • Country: au
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #17 on: August 19, 2019, 02:36:20 am »
..The CP210x devices don't have a unique serial number so it will end up getting a different COM port every time you plug it in ...

Really ? I've not seen that problem at all.  Keeps the same COM port just fine...
Windows can vary IDs across a windows-reboot, but that's on all COM devices and more a Windows side issue.
 

Online oPossum

  • Super Contributor
  • ***
  • Posts: 1036
  • Country: us
  • Save the possum. Save the world.
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #18 on: August 19, 2019, 02:40:33 am »
It will typically get a new COM port number if you plug it into a USB port that it has never been plugged in to before.
 

Offline MosherIV

  • Super Contributor
  • ***
  • Posts: 1374
  • Country: gb
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #19 on: August 19, 2019, 07:02:41 am »
Quote
  I have  >10 PC's with identical control PCB boards to modify.  115200 baud is fast enough. Just want to use a very easy to find USB  to USB cable(like those used to connect a PC to a printer) to connect to the modified control board.
Hi.
Have I miss-understood something?

Does the micrcontroller (control board) have serial port or 8 bit port?

As far as I know, usb serial or usb parallel port adaptors just provide a serial port or parallel port in software, then you put another driver ontop to talk serial of parallel.

https://www.amazon.co.uk/slp/usb-to-serial-adapter/7mx4bkg982vz64r

https://www.amazon.co.uk/DB25-female-parallel-adapter-cable/dp/B001D50VQE
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 4850
  • Country: gb
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #20 on: August 19, 2019, 07:53:46 am »
An alternative to CDC is to implement a HID interface.

Some benefits I see to HID over a CDC serial interface on XP:

(1) No drivers or .inf files required for Windows XP.

(2) You have 64 byte packets each way available every milllisecond, although in practice maximum throughput is about 32kB/s (~250kbps). 64 bytes allow you to tailor a structured interface protocol rather than having to parse a serial stream.

There are already VB examples using HID in this way from vendors. I've used the Microchip MLA examples several times. The VB code for a custom hid device for the current MLA is in this directory \v2018_11_26\apps\usb\device\hid_custom\utilities\plug_and_play_example\windows\src\vb2008_express with the firmware here C:\Microchip\mla\v2018_11_26\apps\usb\device\hid_custom\firmware. There are examples supplied for about two dozen boards, from a PIC16 through to a PIC32MM.

(I would avoid trying to use Microchip's MCC for USB, it is very limited and buggy, and instead stick to the MLA: I don't think MCC even supports HID anyway. Harmony [for medium to large PIC32 only] is just far too over-complicated and has a huge learning overhead).

I am sure other vendors have similar HID solutions.
 

Offline PCB.Wiz

  • Frequent Contributor
  • **
  • Posts: 407
  • Country: au
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #21 on: August 19, 2019, 09:36:17 am »
The interface provides a way to send commands and data to a MCU and then receiving data back from the MCU when data is ready to be sent and/or when requested by the PC. Comm speeds of 115200 would be fast enough.

The MCU is already chosen and designed into a machine control module that is now using the PC's legacy bi-directional parallel port.

What is the MCU, and how does it interface with the parallel port - two way, or one way ? and which handshake signals, and what speed ?
Do you have the source code for that MCU, or must this emulate the parallel port as a transparent retro-fit ?
Do you have the messages sent (received?) and which parallel port mode it uses/expects ?

You might be able to get a FT240X (two way FIFO) to handshake with a SPLD, to look like a parallel port. and the FT240X can 'look like' a serial port.
 

Online NorthGuy

  • Super Contributor
  • ***
  • Posts: 2086
  • Country: ca
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #22 on: August 19, 2019, 12:51:56 pm »
I have  >10 PC's with identical control PCB boards to modify.  115200 baud is fast enough.

If your computer has a real COM port (it'll be eaither external DB9 or DB25 connector or a DuPont connector on MotherBoard), there's no reason to mess with USB. You can use RS232 to TTL converter instead, such as (just an example, never used this one):

https://www.digikey.com/product-detail/en/texas-instruments/MAX202CDR/296-18480-1-ND



 

Online Mr. Scram

  • Super Contributor
  • ***
  • Posts: 9470
  • Country: 00
  • Display aficionado
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #23 on: August 19, 2019, 12:59:33 pm »
Are MCUs with USB capabilities an option perhaps?
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 5447
  • Country: fr
Re: Best way/chip for an easy embedded interface between a PC <==>MCU ?
« Reply #24 on: August 19, 2019, 01:05:36 pm »
eBay has better prices on the older FT232RL parts
But these are likely fake.

After what happened with the drivers, still considering buying FTDI parts from dubious sources is complete madness. :-DD
Buy them from official distributors or just buy something else.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf