PDA

View Full Version : How to support two (dual) USB ports?



jellis00
- 17th January 2012, 00:44
I have a requirement to provide an embedded microcontroller that will download data from two (dual) USB ports and then send the data to a MySQL database on the internet via a WiFi module (I plan on using ConnectOne's iWiFi Minisocket). I know the PIC 18F2550/4550 chips support a single USB port, but I don't believe there is a PIC chip that supports dual USB??
Has anyone on this forum ever done a dual USB application with one MCU? If so, would appreciate tips on doing so.

Demon
- 17th January 2012, 00:53
I'm curious why complicate matters (that's IF a Pic exists that has dual USB)?

Why not use a master PIC that supports the Wifi module, and have it send messages to two 18F4550 (or whatever USB Pic you prefer)?

Robert
:)

gadelhas
- 17th January 2012, 00:58
I think there is no PIC with 2 UBS, however you can use the serial port and a converter like FTDI, or any other.

ScaleRobotics
- 17th January 2012, 01:42
Curious if you can tell us a little more. Like others have said, either multiple USB PIC chips, or one PIC USB + something like this: http://www.maxim-ic.com/datasheet/index.mvp/id/3639

rsocor01
- 17th January 2012, 03:45
The USB channels option in the Microchip Advanced Part Selector (http://www.microchip.com/maps/microcontroller.aspx), MAPS, only has the option of 1 USB channel per chip. Why don't you use two 18F4550 like Robert suggested above?

jellis00
- 17th January 2012, 05:42
The USB channels option in the Microchip Advanced Part Selector (http://www.microchip.com/maps/microcontroller.aspx), MAPS, only has the option of 1 USB channel per chip. Why don't you use two 18F4550 like Robert suggested above?
Thanks for that...I didn't think of using MAPS to see if there was a PIC chip with dual USB. Since there isn't I guess my only choices are as follows:

1) Two PIC 18F2550 chips that each manage a USB port, and one of them to also collect the data from the otherone and to send both data elements to the WiFi module for transmission to the internet.
OR
2) Two MAX3421E Chips for thetwo USB ports and a PIC chip to collect the data from both MAX3214 chips and to manage the iWiFi module transmissions.

Have any of you actually created an app with one or the other of these approaches? Which approach do each of you think is the easiest to implement? I have a lot of experience with 18F2550 but no experience with MAX3421E so I tend to think I should go with 18F2550.

gadelhas
- 17th January 2012, 10:55
HI;

I made it with one 18F4550 using the USB module and one CP2102( UART<->USB converter).

Darrel Taylor
- 17th January 2012, 16:48
Why would you need two USB ports?
Are you connecting your device to two computers at the same time?

If you are thinking of plugging USB devices into your project and relaying the information to the ethernet adapter ... you can't do it with the on-board USB peripheral.
PIC chips don't do USB "Host" mode. At least not the PIC's that PBP can work with.

I think your best bet is the VNC2 - Vinculum-II Programmable USB 2.0 Host (http://www.ftdichip.com/Products/ICs/VNC2.htm)

jellis00
- 18th January 2012, 00:38
Why would you need two USB ports?
Are you connecting your device to two computers at the same time?

If you are thinking of plugging USB devices into your project and relaying the information to the ethernet adapter ... you can't do it with the on-board USB peripheral.
PIC chips don't do USB "Host" mode. At least not the PIC's that PBP can work with.



Darrel, maybe a more detailed explanation of the application is needed in hopes you can advise me of my best options.

The client is using temperature sensors as described at this website: http://www.vfcdataloggers.com/usbtcdatalogger.aspx As you can see each temperture monitoring unit is also a data logger and has a USB port that is used to access the stored data on the device. He wants me to provide a wireless gateway so that the temperature readings on these devices can be transmitted via WiFi to internet and displayed on a web page. He wants my embedded wireless controller to interface simultaneously with both of the temperature monitor devices to monitor two temperature probes at two different locations in a refrigerator....the freezer and the refrigeration compartment.

Therefore, my embedded controller has to have two USB ports and be able to dowload the temperature data from both temperature monitors on an hourly basis when an alarm interrupt is received from a RTC that will be in the embedded controller. The temperature probes will be continuously plugged into the controller via thetwo USB interfaces but will only download when qued to do so by the controller. The PIC microcontrollers (plural assuming one will be required for each USB Port) will(each download the hourly temperature reading from their respective thermometer that is plugged in to its USB port. One of the two pics will also be interfaced to the RTC and to the WiFi module as well as its thermometer/USB port. This "master" PIC will monitor the alarm interrupt from the RTC and upon receipt of an hourly alarm interrupt will start the data loggin/reporting process. The other PIC must send the measurement that is downloaded from its thermometer/USB port to the other PIC (serial?), which will then send both temperature readings to the WiFi module for reporting over the internet to the website.

With this kind of a configuration can't I program each of the PICs with PBP to download the temperature readings from their respective USB ports without having a "Host Mode"?

spcw1234
- 18th January 2012, 00:51
With this kind of a configuration can't I program each of the PICs with PBP to download the temperature readings from their respective USB ports without having a "Host Mode"?

USB requires a host. The PIC using the on-board USB or a USART to USB interface, and your temperature sensors are not capable of doing this. The VNC2 that Darrel linked to looks like it might work for your application though.

They even have precompiled rom's available. This one looks like it will do what you need, it is a USB host bridged to a UART port.

http://www.ftdichip.com/Support/Documents/AppNotes/AN_185_Vinculum-II_UART_to_HID_Class_Host_Bridge.pdf

jellis00
- 18th January 2012, 21:20
Thanks for that, Gadelhas. I reviewed the CP2102. It looks like it is a it is a bridge between a USB host and UART microcontroller like a PIC 18F2550/4550, in a similar manner to the VFC chips recommended by Darrel Taylor and spcw1234 in their below postings. Do you concur?

I guess a USB host bridge is the way I have to go to get two USB ports supported to meet my requirement. My decision on which chip to use (CP2102 or VNC) then boils down to which is the simpler to program and implement. Since the VNC chips can be provided with a pre-compiled firmware to support different USB interfaces, that is definitely a speedup on my development. However, if you already have code that implements the USB interface between an 18F4550 and CP2102 and are willing to share the code, that would be a rapid development process also.

Are you willing to share your code? I don't need the pincount of an 18F4550, so would probably use 18F2550 as smalleer chips, but the code should be almost identical.

Regards, John

jellis00
- 18th January 2012, 21:26
Shawn, I really appreciate your and Darrel's input on this. I reviewed the websites you both pointed to and have some questions.
1) I presume that in my application, the temperature datalogger becomes the USB host and my 18F2550 becomes the slave with a UART that is bridged to by the VNC chip...is that correct??
2) Since my application has to provide an interupt to the temperature datalogger when it wants the latest temperature sent via the USB to my application, how can I get the interrupt to the datalogger....it appears that the total interface using the UART<---VNC<---->USB Host is only uni-directional between the UART and VNC and would prevent me from sending the interrupt to the USB Host via the VNC. Don't quite understand how I am going to handle that if I use VNC. Can you elaborate??

gadelhas
- 18th January 2012, 22:53
Thanks for that, Gadelhas. I reviewed the CP2102. It looks like it is a it is a bridge between a USB host and UART microcontroller like a PIC 18F2550/4550, in a similar manner to the VFC chips recommended by Darrel Taylor and spcw1234 in their below postings. Do you concur?

I guess a USB host bridge is the way I have to go to get two USB ports supported to meet my requirement. My decision on which chip to use (CP2102 or VNC) then boils down to which is the simpler to program and implement. Since the VNC chips can be provided with a pre-compiled firmware to support different USB interfaces, that is definitely a speedup on my development. However, if you already have code that implements the USB interface between an 18F4550 and CP2102 and are willing to share the code, that would be a rapid development process also.

Are you willing to share your code? I don't need the pincount of an 18F4550, so would probably use 18F2550 as smalleer chips, but the code should be almost identical.

Regards, John

Hi John;

Yes the CP2102 is only a Uart/USB Bridge. This type of device should be only used for connection to a PC( Or to a device that handles it, it must have the USB Host capability), for instance, if you have some device that only haves UART, and your PC doesn't have a COM/Serial Port to connect it, you should use a UART/USB Bridge like the CP2102.

If you have a device that is allready USB, for instance a PC mouse, or a USB hard disk, and you want to connect to a PIC, then you must use a device like Darrel posted, the Vinculum. This type of device it haves the capability of USB Host/Slave controller IC.

The temperature device that you posted, it allready haves USB, so if you want to interface it woth a PIC, you must you the IC that Darrel posted.

The device that I did with a PIC/USB and CP2102, was to connect to two PCs simultaneously. I cannot share the code, but if you want i can tell you how to do. It's simple, you use the Uart module connected to the CP2102. Int he firmware PIC side, you just do the Hserout command, or the Serout command to feed the data to the Uart of the PIC and then the CP2102 converts to USB and feeds to the PC.
But like a said before, this is not what you want.

Hope you can understand what i wrote, English is not my native language, i'm Portuguese.

Regards
Gadelhas

spcw1234
- 19th January 2012, 00:29
The VNC2 has 2 USB ports on it, you would make both of them the host ports for the temperature sensors. Connect the VNC2 to a PIC using the UART connection as a USB to UART bridge. The PIC does not need USB on it for what you are trying to do. I was unable to confirm if you can set up both USB ports on the chip as a USB host. If not, then you would need to use two of them, but since there are 2 USB ports built into the chip I would imagine you can. I have no real experience (yet) with this chip, but plan to get one in the near future to play with. Good luck, and keep us posted!

gadelhas
- 19th January 2012, 00:36
Hi... again;

The Vinculum II, has 2 USB Ports Host / SLave Controller, the Vinculum I, i don't know.

You can see it here, first item of the "key Hardware features"
http://www.ftdichip.com/Products/ICs/VNC2.htm