0

Basically I want to use an Attiny running an Arduino boot loader as an usb device. I'm not sure how to even start or what phrases to search for.

So here's what I ultimately wish to do.

  • Load a listener like that of an RS232 serial communication program
  • trigger pin states based on received commands
  • plug the Attiny directly into a windows environment USB port for communication.

I understand that this will require some kind of driver to do this but i don't know what. I do have experience with serial port communication using Visual Studio C# as well.

Assuming what I would like to do is possible, im looking for pointers in how to make the Attiny can be seen by windows.

  • How far have you got? Do you have the Attiny plugged in and ready to go? Are you able to find and run an example program which, say, prints something to the serial port, and run a terminal on the PC and view the output? That's how I'd start. – Mark Smith Nov 17 '16 at 7:46
  • 1
    Which ATTiny? If you want to add USB, you'll likely drop in an usb-uart chip, like the CH340G or a FTDI chip. But UART may need a more accurate crystal. So you'll be wasting 2pins for the crystal and another 2 for the uart.. Which won't leave a lot for the rest. – Paul Nov 17 '16 at 16:54
  • 1
    You could try using an 32u4 which have built-in USB. – Paul Nov 17 '16 at 16:55
  • So far I have basically gotten no where. Mostly because I just don't know where to start. using serial im good to go. its the USB idea that has me stuck. Comments so far have given me some insight though.so there's a place to start looking. What i have are some 84s and 45's that i wanted to use one or the other for this.. I assumed that i could load some kind of usb driver onto the chip to let me communicate with it directly. – eatumup Nov 17 '16 at 19:55
  • 1
    How integrated do you want to make it. Do you need a USB driver at all? Could you use an FTDI adapter, treat it as a serial device and send text commands to it? Come up with a simple protocol, similar to AT commands for example? – Mark Smith Nov 17 '16 at 20:00
1

Generally there are (or could be many) USB Devices and (only one controlling) USB Host. The differences are discussed in this stackexchange.com question. Briefly, USB Hosts are usually very complex hardware and software devices that may know about many many different types of peripherals. They are usually only found on computers. USB Devices are usually dedicated peripherals. They only need to know about them selves. Many people do not realize that there are many protocols built into USB. These are normally called Device Classes. The USB Serial Protocol (or CDC) is one of dozens of Device Classes.

So, assuming you want a build a Serial Port USD Device, you would first need a processor with built in USB Device hardware. (There are likely some project out in the wild that have implemented this feature using software. It might be a good experience. But for practical purposes it is usually better to use hardware for this.) The next feature you need to implement is a software USB Device driver. This is not trivial. But is much simpler than the USB Host software. The next feature you need to implement the serial protocol inside the USB protocol.

In the real world, the USB code, even for a USB Device, is complex enough that most developers use the USB code provided by the processor manufacturer. This is very common as most manufacturers want you to use their hardware and provide the USB code for free. Here is Atmel's support page for CDC USB (serial port) support. (Of course, Atmel makes the processor found in most Arduino boards.)

Thus far this answer has been general and is likely difficult to implement in a practical sense. A more turn key solution is to use an existing platform which contains a USB CDC Device. The Arduino Uno comes in several versions. One has a USB CDC chip made by FTDI. Another has a 2nd processor programmed specifically to handle USB CDC type communications. Either version provides a USB CDC interface used for programming. I believe this web page explains how you can also use this port to communicate with your sketch.

  • 1
    You didn't say what arduino you are using. If this link helps, I can add it to the above answer to make it more specific. – st2000 Nov 17 '16 at 16:18
  • sounds like I want some kind of usb device. Based on what you have said what I was hoping to do was turn something like an Attiny84 into a usb device. Then use custom win32 software to tell it to specify analog pin voltages to control MOSFET transistors. It sounds like i might need a different MCU or to add an additional USB device chip. Can you recommend any beginner articles on arduino usb device development ? a 32u4 was suggested. Ill do a little looking into that too. – eatumup Nov 17 '16 at 20:01
  • I had a glance at the Trinket link you posted. At a glance it looks like it just may do everything i need it to for my project. Thank you for that suggestion. I am still curious about learning to make a USB Device if you have any suggestions there. – eatumup Nov 17 '16 at 20:07
  • 1
    Sorry my turn around was so long. Busy days. I'll try and flesh out the answer. As for USB, on stackexchange.com opinions are usually frowned upon. Regardless, this is the book I use. – st2000 Nov 19 '16 at 22:13

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.