Accessing USB input lines on Arduino Mega 2560?

Hi,

I am building an electronics interface shield that has a lot of stuff on it -- 8 240VAC relays, 20 24VDC 100mA outputs, 20 open-collector outputs, 8 16-bit analog outputs, and 8 18-bit analog inputs. Needless to say, even using TQFP parts and working hard to optimize board layout, my shield is much larger than the Arduino Mega board. It's about 8"x8" in fact.

What I would love to do is instead of putting the "shield" on the "arduino" is to make a socket that I can use to plug in the arduino upside down. I'm already providing VIN via a 7.5VDC on-shield switching regulator (since I need 24VDC to drive my relays and my 100mA outputs), so I can safely ignore the power plug... but what I'd like to do is put a USB port on my shield and bypass the on-arduino USB port.

This would work wonderfully overall, but I'm not sure if it's possible to grab the USB lines. Is the only way I can do something like this with a USB jumper cable (or making a board with the arduino electronics onboard)?

The Arduino RX and TX are somewhat isolated from the USB interface by two 1k resistors so if you were to drive those signals from another source it should work. Not ideal though.

If this is a one-off you can just pull the resistors.


Rob

How often is the USB cable going to be connected? Is it really worth the effort of "relocating" the USB connection? Why not just put the Arduino near the edge of your "shield"? USB is a differential connection. Breaking it and jumpering it like you suggest is possible but might cause more problems than it is worth.

Or, follow Rob's advice. In that case, you need to re-implement a USB-to-serial circuit on your "shield."

(or making a board with the arduino electronics onboard)?

It doesn't sound like you need much from the Arduino.

If you add the "Arduino electronics" to your shield (I guess it's not a shield then :)) and don't bother with the voltage changover crap then it's only two chips and a few discrete components.


Rob

Are the arduino components really so few components?

I want to use an arduino for control because I hate implementing USB interfaces and the transparent USART is nice. I've done my share of atmel programming, and it's just so much more convenient to use the arduino that I prefer to just use an arduino as my controller nowadays even in professional projects.

The design engineer in my naturally wants to separate the controller electronics from my own electronics because the controller is a tested and professionally assembled module that has a nice clear abstraction barrier from the rest of my system. That way if I have errors in my interface board I can spin a new one or attempt repairs without having to resolder all the controller parts.

But I suppose if it is really just the atmega, the attiny (or whatever it is that they're using), 2 ISPs, the crystal... maybe it's worth just making my entire board an arduino derivative instead of a shield. It just seems unnatural to me to duplicate existing purchasable functionality.

I suppose the middle ground would be to put a chassis mount USB port on my system and put a jumper between that port and the arduino. Oh, that's why I don't like the idea of using the USB port on the arduino with the power port on my shield. I've done that before and because of the power plug already on the arduino it's very hard to design a chassis so that the USB port and the shield's power plug stick out of the case without interfering with the arduino's power plug.

Best,

I want to use an arduino for control because I hate implementing USB interfaces and the transparent USART is nice.

because the controller is a tested and professionally assembled module that has a nice clear abstraction barrier from the rest of my system.

That makes sense.

Do you need USB for the application or just for programming?


Rob

Both -- the intent is to make this a substitute for the ridiculously expensive (and underperforming) LabView data acquisition cards produced by National Instruments. The end result is going to be a board that you plug into your computer with USB and which has LabView drivers allowing you to read analog inputs, write analog outputs, and then write to the plethora of digital outputs.

My original design also had three RS232 ports on it. I was planning to make it so that if you sent out a serial packet to the arduino over USB with the right command register, it would pass the packet through to the selected of the three USARTs on the Arduino Mega 2560. Seemed like a classy way to simplify the rather ever-present annoyance of all instrument manufacturers using RS232 for communication with computers while computers themselves come with fewer ports every month. But I also want to do my prototypes using the 4pcb $33/each special, which limits my board size to 60 sqin, so I ended up not having space for it.

I suppose in principle I could just use a FTDI USB interface chip and plug it into USART1. Might bypass the slightly (but not terribly) annoying issue where I have to supply the board with 7.5VDC to VIN instead of being able to apply +5V directly because if I plug the USB in it'd create a massive current loop between the two competing power supplies (and probably break the computer's USB port). But then I'd have to be confident that I have the FTDI chip wired properly, and since I've never done that before...

Yeah, probably easiest is just to put on a short USB jumper cable. That's not a particularly bad solution anyway; probably more professional than putting on my own USB port and trying to connect it into the Arduino given that there are no header pins which give raw access to the USB data +/- lines. And I suppose for prototyping at least I can just plug it in to the Arduino module directly so long as I take care to not block the port with an inductor or something similarly obnoxious.

Thanks!

I suppose in principle I could just use a FTDI USB interface chip and plug it into USART1.

Having bought one of these inexpensive usb serial converter modules, I'm a big fan of them. Works great and give one a lot of flexibilty when developing and troubshooting arduino applications that utilize multiple serial devices, especially when a given sketch uses the existing Serial uart to interact with a PC application, this module would allow one to use either a software uart or the extra hardware serial ports on the mega boards to allow a debug serial stream to a PC terminal program while the sketch is being developed. They are just too inexpensive not to have a couple of them around for development purposes.

http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=190544446821&ssPageName=STRK:MEWNX:IT

Lefty