Pages: [1]   Go Down
Author Topic: Adding a second USB port to a Mega 2560  (Read 1606 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a Mega 2560 and would like to add another USB port to this.  I have an Arduino USB2 Serial light module.  The USB chip on the Mega is a 16U2, while that on the USB2 Serial light is an 8U2.  Is it possible to get the USB2 Serial light to work with the Mega?  Do I need to update the firmware on the 8U2 chip?  If this is not possible, can anybody recommend the correct piece of hardware to add the second USB port to the Mega?  Any information would be much appreciated.
Logged

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What are you trying to accomplish?  Why do you want to add a 2nd serial port?
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your reply.  I'm collecting nine streams of data 50 times a second and outputting to an Excel spreadsheet.  The first three data sources come from a load cell.  These are just analog values and are easy to deal with.  The second group of three signals come from an XSENS motion detector, and have values corresponding with yaw, pitch and roll.  Threse three signals come in over a USB connector.  I want to read these three immediately after reading the load cell values.  The last three data streams have yet to be defined.
 I believe that I can add three extra USB ports to a Mega.  I thought it would be simple - I mean there's only Tx, Rx, 5v, 0v and reset.  A basic sketch is contained in the communications section of the examples.  But try as I might, I cant get the little USB2 light adapters to work with the Mega. 
Logged

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Is this sensor an USB Device or USB host?  If it is a device, you'll need to add a USB host chip, write a protocol stack, and create drivers on the Arduino.  No small task.

You may want to reconsider your approach.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That sounds tricky!  The XSENS streams out its data at a pre-determined rate (50 readings per second) and at a pre-determined baud rate.

Is it not possible for the Arduino to read in this serial data just as it would any other data?
Logged

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Is it not possible for the Arduino to read in this serial data just as it would any other data?
Not if the sensor is a USB device.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for this information.  I imagine thaqt my requirement is not an unusual one.  Is there not an Arduino shield or add-on that could help perform this very ordinary task?
Logged

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

There is a USB host shield, but you have to understand that USB is a complex protocol.  This isn't an ordinary task for a microcontroller with 2K of RAM.  So there is a lot of work involved with getting USB devices to work with an Arduino.

If you can get access to do the data before it turns into USB, it would be relatively simply to read it with an Arduino.

USB devices work so well on your PC because there is tons of driver code built into the operating system already.  None of that infrastructure exists in the ATmega series chips.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Ayer, Massachusetts, USA
Offline Offline
Edison Member
*
Karma: 54
Posts: 1857
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well rather than trying to put multiple USB hosts on a system, you might consider getting multiple Uno's each with one USB, and use a serial protocol to get the information back to the Mega.
Logged

Maine
Offline Offline
Sr. Member
****
Karma: 14
Posts: 418
Caution: Explosives in use.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If I am understanding you correctly (and the specs from the XSENS website), the sensor sends its data over a serial connection, but it uses a serial to USB adapter to make it easier to connect to a computer. So wouldn't it be easier to modify the sensor so you can use the serial pins on the arduino to read it directly?
Logged

"Anyone who isn't confused really doesn't understand the situation."

Electronic props for Airsoft, paintball, and laser tag -> www.nightscapetech.com

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Michael, Wizdum, James
Thanks for your replies, guys.  The XSENS is an expensive unit (over £1000) and I would prefer a solution that did not involve hacking into it.  There is no way to get at the connections without dismantling part of it, so I will leave that avenue until later. 
A German company, Lipoly (lipoly.de) is distributing a USB host shield suitable for the Mega, so I will give that a try first I think. 
Logged

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You might consider a Beaglebone or Raspberry PI.

It'll be far easier to manage multiple USB devices and you probably don't need to develop any drivers.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks James.  That is a good idea.  If I can't get the shield to work I will try that.  Do these boards have built in A to D converters and digital inputs like the Arduino?
Logged

Ayer, Massachusetts, USA
Offline Offline
Edison Member
*
Karma: 54
Posts: 1857
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It wasn't clear from your description whether the problem is you wanted to have several of the xens sensors all tied into one Mega, or if you had just one xens sensor and needed a 2nd usb to communicate to your host system.

If it is the later, you could always communicate to your host system using other means (ethernet, wifi, bluetooth, good old rs-232, etc.).

If it is the former, then as I said, a possibility is to have a separate Arduino to handle each xens sensor, and then have them communicate to the Mega via a serial connection, and have the Mega aggregate the data and upload it.  It makes the programming harder, because now you have program multiple systems, and deal with uploads, etc.  A better solution is figure out how to have multiple USB headers, without running out of memory, etc.

Either that, or have each unit upload separately to your host, and do the aggregation on the host.  If nothing else, I would probably not want to create the spreedsheet on the Arduino, but just output numbers in a comma separated list (or other encoding), and on the host create the spreadsheet.  It depends on whether you have enough cycles to create the spreadsheet so that you can do your readings at 50 times a second.

I glanced at the xens products, and as far as I can tell, they emit RS-232 or RS-485, and then have a dongle that converts RS-232 to USB.  I could imagine just taking that dongle off, and doing data collection the old way with RS-232.  But given the cost of the sensor, I can understand if you are reluctant to pop off the dongle.

The Raspberry Pi just started shipping, and is in rather short supply right now.  At the moment, you are limited to buying a single cpu.  I signed up in March, and just got the notice to buy the single unit last week.  Raspberry Pi does have some GPIO pins, but I suspect right now it doesn't have the infrastructure to do embedded work like Arduino does.

I'm not as familiar with the beagleboard, but I glaced at the side, and it looks like it has GPIO headers in an expansion card.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Michael

I have just one XSENS which outputs three variables aggregated into one USB signal.  I need to read the XSENS, three analog signals from a load cell (X, Y, & Z forces), plus three more signals that have yet to be defined. 

I have had no trouble getting the X, Y & Z signals into the Arduino and from there onto an Excel spreadsheet.  I have gathered 6000 lines over a two minute period and the Arduino has easily coped with this with plenty of processing to spare.

What is important is that the signals from the XSENS are synchronised with the signals from the load cell - so I imagine the finished spreadsheet on the PC or laptop would have 6000 lines with nine values across each line.
Logged

Pages: [1]   Go Up
Jump to: