3
\$\begingroup\$

I would like to make a PCB that sends a specific byte of information through a usb connection. I need the PCB to be as small and simple as possible to fit into a nice thin housing. Simply put there would be a push button that would send a byte of information identifying it had been pushed, without a micro-controller. Is there a way to specify a sequence of on-off 1-0 within the circuitry on the PCB? namely a byte. I've searched EVERYWHERE and haven't found anything relevant.

\$\endgroup\$
  • 1
    \$\begingroup\$ possible duplicate of Need a device that can take single input and covert to a keyboard key press on USB \$\endgroup\$ – Dave Tweed Oct 22 '12 at 13:53
  • 1
    \$\begingroup\$ If the reason for avoiding a microcontroller is either cost or design complexity, you may want to consider one of the low pin-count microcontrollers that require little in support circuitry. The answers to electronics.stackexchange.com/questions/8676/… list several microcontrollers with 6 or 8 pins, in DIP packages, at prices of under a dollar in single unit quantities - though none of those seem to be natively USB capable. Ones with native USB support are in the $2.50 and higher range but it would be worth checking on DigiKey or Mouser. \$\endgroup\$ – Anindo Ghosh Oct 22 '12 at 14:53
  • 1
    \$\begingroup\$ I found some Atmel 6-8 pin micro controllers like you mentioned, and I'm thinking that is going to be the best direction to head in. It looks like it will be interesting to find a micro controller that can communicate over Usb natively. I'm starting to venture into other questions, thanks for the push in the right direction! \$\endgroup\$ – Mark Y. Oct 22 '12 at 16:44
4
\$\begingroup\$

USB is a master slave connection; for all practical purposes, let's assume you asked how to make a slave device which does this, as making a master is much more complicated.

While it would theoretically be possible to implement a USB slave interface as a state machine, in practical terms most implementations will use a microcontroller or stored-program processing core to handle the higher level protocol operations. Though possibly one with a factory installed firmware that is merely configurable, and not itself rewritable, by a circuit designer who utilizes it.

There are numerous physically tiny and/or inexpensive microcontrollers which implement true USB slave interfaces - pretty much every vendor offers one. For your purposes, available packages and external vs. internal oscillators may be a consideration - ease of development may also matter (for example, being able to install a raw chip on a board and program it over USB is nice, but sometimes a mid- to high- end feature).

Another option for a small project of this sort is a software emulation of the lowest rate version of USB on a small general purpose microcontroller. There are examples floating around on the net for building things using an ATTINY85 and a few zener diodes or LEDs to approximate the required signal voltage ranges, clocked off the internal oscillator so no crystal or resonator is needed. These aren't officially compliant USB implementations, but in many cases they work, and can be a simple way to have something that looks like a keyboard or virtual serial port and sends simple data in response to the state of a pin, or possible even does more complex things.

Given that microcontroller solutions are no more expensive than dedicated ones, and no physically larger, it's not clear why it would be desirable to avoid a solution of that nature.

\$\endgroup\$
5
\$\begingroup\$

USB is not an easy serial protocol. You cannot discuss on USB using some transistors and resistors. You need to have a chip that is able to behave as an USB endpoint and that know the USB protocol. If you don't want to use a microcontrollerm this could be difficult.

And the problem will be on the other side of the cable also: If you plan to use MS Windows, you will need a driver for your USB device. Thus you will have to write it. And with windows 7 and later, you have to get you driver signed in order to use it. (there is a way to bypass this but I think it's out of scope here).

What I suggest, is to dismantle a HID device such as a USB mouse or a USB joypad and connect your button to the electronics. Then you could use the HID interface without having to care about drivers.

It's not a nice solution, in an engineering point of view, but if you don't want to use a microcontroller...

\$\endgroup\$
  • \$\begingroup\$ HID may well be a good choice to avoid the driver issue, however there will be more control over what is sent and why in using a custom device which talks HID. But hacking a keyboard is a good solution when the desire is to simply generate some condition which custom software on the PC can detect, or to put a specific keypress into existing software. \$\endgroup\$ – Chris Stratton Oct 22 '12 at 14:00
5
\$\begingroup\$

Use the FTDI FT245RL chip for this. You can get one on a breakout board for testing from Sparkfun Electronics.

enter image description here

The FTDI chip can be used to send a byte over USB to a PC running an OS and using the appropriate premade USB driver from the FTDI web site. You can make this work by wiring the byte value that you desire to the D0->D7 lines of the FT245RL. Then wire your switch input into the WRITE input pin on the chip and it will initiate a transfer of the byte value to the PC. (The switch will need to be debounced so that bounce does not initiate multiple byte transfers). On the PC side the byte value will appear to be a byte being received via a COM port so you only have to provide a simple program that can open the COM port and respond to the byte when it arrives. There is ample information on this chip available from both Sparkfun and FTDI.

\$\endgroup\$
  • \$\begingroup\$ It's highly probable that this is, internally, a microcontroller running a fixed program. \$\endgroup\$ – Chris Stratton Oct 22 '12 at 16:08
  • \$\begingroup\$ You won't get away from that with USB. If it meets the price requirement, who cares? \$\endgroup\$ – akohlsmith Oct 22 '12 at 19:04
  • \$\begingroup\$ @ChrisStratton - The FT245RL may be an MCU internally. If not it is certainly one or more hardwired state machines. :-) \$\endgroup\$ – Michael Karas Oct 22 '12 at 22:35
  • \$\begingroup\$ Mark Y didn't say why he doesn't want a microcontroller, but a possible reason is that he doesn't want to program one. I.e. whip out a clunky development environment and write code, compile code and send code to chips. A device that sends bits from parallel input lines doesn't look like a microcontroller. It looks like a shift register (which happens to know how to talk to USB, which is abstracted away). \$\endgroup\$ – Kaz Oct 23 '12 at 0:06
2
\$\begingroup\$

You can use an ATTiny13 or ATTiny45 as a software-emulated HID interface. Projects such as "The cheapest dual trace scope in the galaxy" make this possible. Small code modification and you're done!

The code can really fit into an 8-pin DIP or SMD version of ATTiny. You would just need a few diodes and resistors to make this work.

Even if you use through-hole components, you can make this very thin, approxtimately the size of a pendrive. If you use SMD components, it could be even smaller.

\$\endgroup\$
1
\$\begingroup\$

A really minimal example based on an 8-pin ATtiny and almost no additional components is the AVR Stick. Out of the box it reads two voltages and reports them by "typing" as if it were a keyboard. The firmware is open source, and tools to build it are free. The stick itself is running under US$10 today.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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