1
\$\begingroup\$

I want to build a USB peripheral device. The Device is to connect to an Android smartphone with USB OTG capabilities. The smartphone will be a host and will run an app that communicates with my device. I want to design that peripheral device from scratch i.e. create my own PCB.

USB peripheral controller chip - I was researching for chips that I could use for my device but then I thought that I should get an eval/dev board to train on, first. I want to be able to set up and program the chip so that it communicates with android phone. I don't want these FTDI usb-to-serial converters because they seem unprofessional and I would like to have a proper usb-to-usb communication.

Questions:

  1. Are there any reasonably priced eval/dev boards for USB chips ?

  2. Can you recommend any specific chips ?

  3. I'd like to learn more about usb, I've researched a bit and I'm a bit confused - would writing my own usb drivers for my device be too crazy ?

  4. Is there anyone else who done something similar that could share their experience ?

  5. Should I ditch my plan entirely and just get some sort of an off-the-shelf solution ?

\$\endgroup\$

closed as off-topic by PeterJ, Matt Young, Adam Lawrence, Daniel Grillo, Ricardo Jan 22 '16 at 18:34

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    \$\begingroup\$ The Arduino Mega ADK ("Android Development Kit") might be a solution for development. However, it isn't strictly OTG. \$\endgroup\$ – CharlieHanson Jan 22 '16 at 12:33
  • 1
    \$\begingroup\$ Maybe you want to use a microcontroller with integrated USB capabilities, e.g. ATMEGA32U4. Or did I misunterstand you? \$\endgroup\$ – deinoppa Jan 22 '16 at 12:52
  • 1
    \$\begingroup\$ A "USB peripheral controller chip" is just a MCU with native USB device facilities. \$\endgroup\$ – Ignacio Vazquez-Abrams Jan 22 '16 at 13:00
  • 3
    \$\begingroup\$ What is your level of embedded experience? Your goals are fine, but I would discourage you from taking this on as your first embedded experience. USB can be a very frustrating, picky thing to work with, and you should really have your basics down before you throw USB into the mix. If you're inexperienced in the basics, the FTDI approach would be my advice. If you've got some projects under your belt, than your approach can be fun. \$\endgroup\$ – Scott Seidman Jan 22 '16 at 13:26
  • 3
    \$\begingroup\$ @ShadyProgrammer -- then you're probably qualified enough to take this on. \$\endgroup\$ – Scott Seidman Jan 22 '16 at 14:40
3
\$\begingroup\$

My take on this.

Are there any reasonably priced eval/dev boards for USB chips ?

I assume with "USB chip" you mean a programmable microcontroller with USB peripheral.

Yes, plenty. But if you want to stay focused, start looking from where you are now. And by that I mean; how much and particularly on which embedded platforms are you familiar with? Some suggestions:

  • Arduino Leonardo
  • Arduino Zero
  • Arduino Due
  • ST STM32F4Discovery
  • ST Nucleo (there are couple of dozens board - some with USB, Ethernet, etc!)
  • MicroChip PIC32 USB starter Kit II
  • Mbed

Can you recommend any specific chips ?

I personally have used USB on the Microchip devices, and am quite pleased about them. PIC24FJ64GB004 is my personal favorite. It's faster than the average 8-bit microcontroller, has plenty of memory, remappable peripheral I/O, can run USB from internal oscillator, TQFP-44 is reasonably easy to solder (-002 chip in DIP-28 for breadboarding!), and it's USB implementation has 32 endpoints. Not all microcontrollers have 32 endpoints available. It's plenty to support any USB descriptor you want (e.g. create compound USB devices).

However don't be afraid to look at other devices. I'm pleased with that particular chip because I've invested some time into getting familiar with it. It does what I need it to do, especially considering the size/performance/cost/etc.

I'd like to learn more about usb, I've researched a bit and I'm a bit confused - would writing my own usb drivers for my device be too crazy ?

USB is a hard protocol. So a good approach is to first verify the hardware is OK, and then start looking at your own implementations.

"Drivers" is two sided story. The host needs a driver, and the device too. Most USB hosts will support standard device drivers like HID, CDC and Mass Storage. These are "class specific". If you want something custom you need to go "vendor specific" which is a lot more complicated. In that case you need to define your own setup commands, endpoint arrangements, what data gets filled into endpoint buffers, etc.

On the PC you could use libusb to load a "generic" driver and interact with endpoints in "user land". This mitigates the need for a "kernel land" driver. However this may be OK for a developer machine, but not for a customer machine.

On the Microcontroller, I would strongly recommended using a framework. USB is hard because many OS'es will give little to no debug info about why a device failed to enumerate. USB debugging can be done, but either requires expensive USB hardware sniffers or only works when you get past the enumeration stage. Additionally debugging on the device may seize communication (e.g. breakpoint is hit) and terminate the USB session.

That's why I would recommended to use what already works. Don't try to run when you can't walk.

Is there anyone else who done something similar that could share their experience ?

I've done some USB projects myself. As I said take small steps.

1) Design your PCB following the datasheet of the chip you have chosen. I also make sure there is a demo application available for the chip I have chosen.

2) Consider what you want to do on USB.

Do you want to create a mouse/keyboard/joystick (e.g. custom game input peripheral)? Probably a HID class device is necessary. Do you want to load new firmware and/or settings onto your device? Probably mass storage device. Do you want have custom needs? IMHO 2 options remain:

a) Simulate a serial port with the CDC-ACM. Then build a classic RS232 protocol on this.

b) Write your completely custom host and client driver. This is not trivial.

3) If you want to sell USB devices, you also need a VID/PID. These are not free, contrary it's out of reach for almost every hobbyists and even some small companies. Alternatively some manufacturers (like Microchip) allow limited use of their VID for customer applications.

Should I ditch my plan entirely and just get some sort of an off-the-shelf solution ?

I don't agree that "FTDI" chips are not professional. They are a different way of doing things. Getting your first USB project to work will take time. It took me a couple of afternoons tinkering around. However if you don't do it - you will miss out on the experience and keep this (mental) barrier.

\$\endgroup\$
  • 1
    \$\begingroup\$ +1 I've also played with the PIC24FJ64GB00x family of parts for USB devices. The Microchip MLA code for USB is a very helpful starting point but takes a little 'massaging' to make it production-ready. \$\endgroup\$ – Adam Lawrence Jan 22 '16 at 16:44
  • \$\begingroup\$ Great answer! I am now convinced that I want to use a PIC MCU for my device. I will get MicroChip PIC32 USB starter Kit II and start tinkering around with it first. My device will be a HID which should be automatically recognized on my PC. With regards to VID/PID - I don't want to sell anything, will I have any trouble with that when I'd like to use my device only for myself ? Are there any other gotchas if I go this route ? \$\endgroup\$ – Shady Programmer Jan 22 '16 at 20:11
  • 1
    \$\begingroup\$ No. it's not a technical limitation. The VID/PID combination is used to load the correct driver (.inf files). This is a matter of trust that each VID/PID is unique, and which is why it's rather strictly regulated. A HID device should be recognized fine, if not I would recommended using the VID/PID + ".inf file" from a Microchip HID demo. The PIC32s have the same USB OTG peripheral as the PIC24 family, and of course a faster 32-bit core. However they do need a crystal, because their internal oscillator is not accurate enough. \$\endgroup\$ – Hans Jan 22 '16 at 21:06
6
\$\begingroup\$

This is not a complete answer, and your question is too broad for that. I can give you my experience.

Are there any reasonably priced eval/dev boards for USB chips?

I can't answer this.

Can you recommend any specific chips?

I have used the PIC16F1454 in two projects. It has everything built-in for use as a USB peripheral. You literally only need 1-2 capacitors and a USB connector. It has a built-in 3.3 voltage regulator for the USB drivers, slew rate limiting, pull-ups, everything. Runs on the USB 5 volt.

(A lot of people will likely scream at me for recommending a PIC - deal with it. I hate it as much as anyone, it has a horrible architecture internally, but who cares today, you will code it in C anyway. Considering that Microchip is buying up Atmel now, it's also hard to tell what's going to happen to the AVR controllers.)

I'd like to learn more about usb, I've researched a bit and I'm a bit confused

You're not the only one who's confused. USB is hard. If you want an overview of USB I can recommend USB Made Simple.

Would writing my own usb drivers for my device be too crazy?

When you write "usb driver", I assume you mean on-chip firmware. It is not crazy, it's just stupid. A normal embedded developer will use one of the USB stacks supplied by the manufacturer, or by someone else who was crazy enough to make one, essentially picking a program that's close enough to whatever you want to achieve. For the PIC16F1454 I recommended, there are hundreds of example programs with corresponding client software, or there is the open source M-Stack.

Is there anyone else who done something similar that could share their experience?

Likely, but not on stack exchange. Or actually, that is what I'm doing right now, in a limited sense.

Should I ditch my plan entirely and just get some sort of an off-the-shelf solution?

No, because you write "I want to design that peripheral device from scratch i.e. create my own PCB.". This is a nice goal and your question is a good start.

\$\endgroup\$
  • \$\begingroup\$ I will have a look at the PIC that you suggested as it seems like a sweat deal. What's so bad about PIC's architecture anyway that you said people will likely to scream at you ? I'll also have a look at the "USB Made simple" guide that you linked and try to demystify it. And now for the whole USB "on chip firmware" discussion: "One of USB stacks supplied by manufacturer" does that mean that there's many different ways USB is done ? Also as you seem knowledgeable: what's the most widely used professional way of implementing usb functionality , PIC? Do serious designers use those FTDI chips? \$\endgroup\$ – Shady Programmer Jan 22 '16 at 14:19
  • 2
    \$\begingroup\$ Thank you for the confidence in me, but it is sadly unfounded. Everything I know about USB, I learnt over the past two weeks. ;) What I dislike with the PIC architecture is purely from the viewpoint of an assembly language programmer. The smaller processors only have one register, and convoluted instructions that you have to use to shuffle the data around. With regards to many different ways - yes, kinda. Different microcontrollers have different levels of hardware help, and does everything differently, which is why you want to use someone else's code. I hate USB but it's here to stay. :) \$\endgroup\$ – pipe Jan 22 '16 at 14:38
  • 2
    \$\begingroup\$ Oh, and serious designers do indeed use those FTDI chips, but you have to evaluate for yourself it they are a good fit for your project. If you're designing something from scratch, maybe it's not so good to add another chip just for USB. It can be nice for other things though, for example if you want a slow but electrically isolated data transfer, you can put optocouplers on the TX/RX from your microcontroller, connect them to an FTDI transciever, and you're done. \$\endgroup\$ – pipe Jan 22 '16 at 14:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.