• AVR Freaks

Hot!Best advice for making a USB to serial converter

Page: < 123 > Showing page 2 of 3
Author
mlp
boots too small
  • Total Posts : 825
  • Reward points : 0
  • Joined: 2012/09/10 15:12:07
  • Location: previously Microchip XC8 team
  • Status: offline
Re: Best advice for making a USB to serial converter 2019/10/17 06:14:26 (permalink)
0
(to stop the flashy)
#21
oliverb
Super Member
  • Total Posts : 240
  • Reward points : 0
  • Joined: 2009/02/16 13:12:38
  • Location: 0
  • Status: offline
Re: Best advice for making a USB to serial converter 2019/10/17 06:51:56 (permalink)
0
Depending on what the default timeout is would it help to pad to a multiple of 32 using nulls, so that the last 32 byte buffer is sent without waiting for timeout. Alternatively if the timeout is short enough this might increase delay?
#22
andersm
Super Member
  • Total Posts : 2673
  • Reward points : 0
  • Joined: 2012/10/07 14:57:44
  • Location: 0
  • Status: offline
Re: Best advice for making a USB to serial converter 2019/10/17 23:46:31 (permalink)
+1 (1)
swmclFrame size varies between 16 bytes and 48 bytes.  Would much prefer it if the frame wasn't broken up by the USB packets for processing on the other side.  My frames are indeterminate with respect to time.  They can arrive at any time.

Just to continue the pile-on... If you're using the host's serial APIs, all your application will see is a byte stream where data may or may not be available at any current point, just like with a real serial port. The application has no clue what the physical layer is, or that there's packets involved. The only time the packetization may cause issues is if the remote end is drip-feeding the host a few bytes at a time with long intervals, as that's when the converter's transmit timeouts come into play.
#23
nigelwright7557
Super Member
  • Total Posts : 310
  • Reward points : 0
  • Joined: 2006/11/06 08:15:51
  • Location: 0
  • Status: offline
Re: Best advice for making a USB to serial converter 2019/10/18 04:27:02 (permalink)
0
I use HID USB and that uses 64 byte packets although you dont have to use all the bytes.
 
#24
crosland
Super Member
  • Total Posts : 1695
  • Reward points : 0
  • Joined: 2005/05/10 10:55:05
  • Location: Warks, UK
  • Status: offline
Re: Best advice for making a USB to serial converter 2019/10/18 04:41:03 (permalink)
0
he who shall not be named
crosland
 
You need to remember that USB is polled and the best you will get is one frame every millisecond. Write your firmware to reply with whatever is in the buffer regardless. If it was more than 64 bytes it will have to wait for the next 1ms time slot to complete in any case. 



Umm, when I was playing with the MLA code some years ago you could send up to 1.9MB/ms as it packages up multiple 64 byte frames into one transfer, then the hardware unpacks it at the other end back into 64 byte packets.

 
It's fine to quote theory but in the context of this thread, if the device has only a 64 byte buffer, where is the extra data going to come from?
 
In fact the OP states that the MCP2200 has only 32 bytes. Furthermore, Microchip themselves demonstrated that a long packet is split into 32 byte chunks.
 
The latest FTDI serial chips have 512 byte buffers.
 
#25
ric
Super Member
  • Total Posts : 24581
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Best advice for making a USB to serial converter 2019/10/18 05:20:03 (permalink)
+1 (1)
I think the point is that Windows will grab more than one bulk packet per millisecond if there's spare capacity.
I'd assume Linux is similar.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#26
swmcl
Super Member
  • Total Posts : 271
  • Reward points : 0
  • Joined: 2014/05/10 13:54:42
  • Location: Queensland
  • Status: offline
Re: Best advice for making a USB to serial converter 2019/10/19 16:30:26 (permalink)
0
Thanks for the 'pile on' ...

Why USB ?  The reason for trying to use USB is because USB ports are on every computer whereas using RS485 would need a specialised card and the computer could not be as small and fanless ... RS485 is actually a best solution because of the isolation ability on each node.

Why full speed ?  As I understand it, the low speed USB is not supposed to be transmitting packets of more than 8 bytes (max packet size) (control) and does not allow bulk or isochronous transfers. (USB Complete Table 2.1)
 
Full speed allows 64-byte maximums for control, bulk and interrupt and 1023 for isochronous.  The poll interval is 1ms and one packet per interval (control, bulk and isochronous).
 
Full speed is significantly more flexible than low speed and is easily accommodated in the computers of the last 10 years.
 
Do I need full speed performance ?  If I have multiple devices attached to a USB hub then yes, I would like to have each device transmit its information in one packet and quickly.  No harm having a comms setup that doesn't create a bottleneck.  There is nothing difficult about full speed for a modern computer.
 
Why try to avoid reconstructing a frame at the computer end ?  Again, if there are multiple devices on a USB hub it is best to avoid more processing than is necessary.  If the hardware can filter the frame and be sure that it is whole, why do it again at the computer ?  Also, I am finding it hard to locate people with software experience at the hardware level on Linux.

Why Linux ?  Something I don't want to answer here ...  :-)
 
The MCP2200 has a 64-byte buffer that they chose to effectively split into two 32-byte buffers.  I don't know what would happen in other USB-serial converters if you were in the process of filling a buffer when the poll came along ...


#27
swmcl
Super Member
  • Total Posts : 271
  • Reward points : 0
  • Joined: 2014/05/10 13:54:42
  • Location: Queensland
  • Status: offline
Re: Best advice for making a USB to serial converter 2019/10/19 16:36:53 (permalink)
0
 
In a quick reply to #19 Crosland ...

Instead of all the calculations you suggest, I think differently.  I think I should transmit my frame in one transfer and be done.  I assume there will be no chopping up of the USB packet.  The best variant of USB is the 12Mb/s full speed variety as it is as common as you could ever get and the specification allows for a packet that exceeds mine easily.  I do not have the skills nor equipment at this stage to warrant such an investigation.  I would simply 'suck it and see'.
#28
swmcl
Super Member
  • Total Posts : 271
  • Reward points : 0
  • Joined: 2014/05/10 13:54:42
  • Location: Queensland
  • Status: offline
Re: Best advice for making a USB to serial converter 2019/10/19 16:43:41 (permalink)
0
Replying to Northguy @ #18 ...

My microcontroller that I have settled on is on its own in terms of its features.  I have no other choice.  The PIC18F47K42 has 5V, 44-pin TQFP, XLP, unique serial number, dual UART, ADC, DAC, SPI, I2C, CRC ...

It just doesn't have the USB.

It is a very late model PIC.

The USB is on a separate daughterboard feeding into one of the UARTs.
 
post edited by swmcl - 2019/10/19 17:07:44
#29
swmcl
Super Member
  • Total Posts : 271
  • Reward points : 0
  • Joined: 2014/05/10 13:54:42
  • Location: Queensland
  • Status: offline
Re: Best advice for making a USB to serial converter 2019/10/19 16:51:14 (permalink)
0
reply to jtemples @ 16 ...

I am trying to get software made for Linux that handles a generic case at this stage.  The programmer is being paid on a contract basis and is not in this country.

I'm not sure letting go of critical IP is a good idea.  IP is important yes ?

Yes things could be a lot better if I had oodles of cash to splash on a local programmer or firm ...

At this stage I have almost got something built in software that the local university formally quoted me 100x as much to do...  450$ vs 45k$ ...

I'm trying to build a prototype that I don't even know will work - on a budget.  I will spend if I absolutely need to but I have a built-in disability in that I can't spend recklessly...
#30
swmcl
Super Member
  • Total Posts : 271
  • Reward points : 0
  • Joined: 2014/05/10 13:54:42
  • Location: Queensland
  • Status: offline
Re: Best advice for making a USB to serial converter 2019/10/19 17:52:57 (permalink)
0
Hmmm.   I am reminded why I don't consider Atmel devices ... I'm on Linux !

The PIC16F1455 looks to be a possible contender.  Only 14 pins in a SOIC with XLP, EUSART and USB ... 512 byte dual access RAM for use in the USB ...

Thoughts ?  Anyone with experience using this device as a USB-serial converter ?
#31
OscarTheGrouch
Super Member
  • Total Posts : 308
  • Reward points : 0
  • Joined: 2010/11/29 18:07:28
  • Location: 0
  • Status: offline
Re: Best advice for making a USB to serial converter 2019/10/19 20:28:05 (permalink)
0
swmcl
Hi,
The behavior of the MCP2200 in that it chops up an incoming byte stream into chunks that are a maximum of 32 bytes of data in each packet means I will need to take on the task of creating my own USB to serial converter.
I think the current production device called an ATMEGA8U2 or 16U2 is about the least pin-count 5V device I can see at the moment.

Can I ask for advice on this journey please from whatever direction.

I'm wanting a 64-bytes of data in a single USB packet. 
I need full speed USB 2.0 performance. 
I also need hand-solderable chips.  The TQFP-32 devices are possible.

If you have a previous project you could share (even for money) then PM me !

Rgds,
Steve


FIDI chip. ;)
#32
ric
Super Member
  • Total Posts : 24581
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Best advice for making a USB to serial converter 2019/10/19 22:50:21 (permalink)
0
ok, I'm signing out of this topic.
The unswerving determination to only use one perceived solution is going to make this project unachievable.
I have enough frustration in my day job already,
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#33
PStechPaul
Super Member
  • Total Posts : 2438
  • Reward points : 0
  • Joined: 2006/06/27 16:11:32
  • Location: Cockeysville, MD, USA
  • Status: online
Re: Best advice for making a USB to serial converter 2019/10/20 01:48:24 (permalink)
+1 (1)
I made a prototype with the PIC16F1455 as a CDC device (USB-Serial converter), but I did not actually test its performance. I used the MLA project for the PICdem FSUSB board, and a very simple circuit:
 

 

Here is the project. It's been a few years since I fooled with it, but I still have the board. It enumerates OK.
http://enginuitysystems.c...cs/Demo_PIC16F1455.zip

 
#34
crosland
Super Member
  • Total Posts : 1695
  • Reward points : 0
  • Joined: 2005/05/10 10:55:05
  • Location: Warks, UK
  • Status: offline
Re: Best advice for making a USB to serial converter 2019/10/20 01:52:59 (permalink)
+2 (2)
swmcl
Why full speed ?  As I understand it, the low speed USB is not supposed to be transmitting packets of more than 8 bytes (max packet size) (control) and does not allow bulk or isochronous transfers. (USB Complete Table 2.1)
 
Full speed allows 64-byte maximums for control, bulk and interrupt and 1023 for isochronous.  The poll interval is 1ms and one packet per interval (control, bulk and isochronous).

 
That says you want full speed functionality, not performance.
 

Do I need full speed performance ?  If I have multiple devices attached to a USB hub then yes, I would like to have each device transmit its information in one packet and quickly.  No harm having a comms setup that doesn't create a bottleneck.  There is nothing difficult about full speed for a modern computer.

It's nothing to do with hubs. Do you need the full speed performance at every device feeding into the hub? What's the average and peak data rate at each device?

 

The MCP2200 has a 64-byte buffer that they chose to effectively split into two 32-byte buffers.  I don't know what would happen in other USB-serial converters if you were in the process of filling a buffer when the poll came along

 
I am guessing it's double buffered.
 

In a quick reply to #19 Crosland ...

Instead of all the calculations you suggest, I think differently.  I think I should transmit my frame in one transfer and be done.  I assume there will be no chopping up of the USB packet. 

 
In that case I can't help you. The calculations are essential to scope out the problem. If you can't see that then you don't really understand how USB serial converters (with buffers of various depth, latency timers), USB polling, host software (drivers, VCP middleware and application) are going to interact.
 
All I can say is forget the MCP2200 and roll your own using the USB library and a suitable PIC, or simply use an FTDI USB UART.
 
#35
swmcl
Super Member
  • Total Posts : 271
  • Reward points : 0
  • Joined: 2014/05/10 13:54:42
  • Location: Queensland
  • Status: offline
Re: Best advice for making a USB to serial converter 2019/10/20 02:30:49 (permalink)
0
Thanks crosland @ #35 - yes I will concede 'functionality' not 'performance'.
 
Great post PStechPaul thanks.  I have tried to install the latest MLA in the last few hours on Linux but I'm getting a bunch of errors.  I'll seek the project you mention.
#36
PStechPaul
Super Member
  • Total Posts : 2438
  • Reward points : 0
  • Joined: 2006/06/27 16:11:32
  • Location: Cockeysville, MD, USA
  • Status: online
Re: Best advice for making a USB to serial converter 2019/10/20 02:49:00 (permalink)
0
The relevant files from the MLA are included in the zipfile. I just modified the project so it builds in C90 mode. I am using C:\microchip_solutions_v2013-06-15
 
http://enginuitysystems.c...cs/Demo_PIC16F1455.zip

 
#37
NorthGuy
Super Member
  • Total Posts : 5805
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: online
Re: Best advice for making a USB to serial converter 2019/10/20 06:47:01 (permalink)
+1 (1)
PStechPaul
I made a prototype with the PIC16F1455 as a CDC device (USB-Serial converter), but I did not actually test its performance.



Me too. Mine is based on PIC16F1454 and uses HID instead of CDC. It can go up to 2 MBaud on the UART side. Could go faster, but there's no point since the USB side is limited to 64kBytes/sec (because of HID, CDC would be faster), so the uninterrupted communications are only possible at about 500 kBaud. Anything faster requires flow control (RTS/CTS).
#38
NorthGuy
Super Member
  • Total Posts : 5805
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: online
Re: Best advice for making a USB to serial converter 2019/10/20 06:48:30 (permalink)
0
(removing blinks)
#39
Jim Nickerson
User 452
  • Total Posts : 6361
  • Reward points : 0
  • Joined: 2003/11/07 12:35:10
  • Location: San Diego, CA
  • Status: offline
Re: Best advice for making a USB to serial converter 2019/10/20 07:24:17 (permalink)
0
missing post page still blinking
#40
Page: < 123 > Showing page 2 of 3
Jump to:
© 2019 APG vNext Commercial Version 4.5