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.

asked Nov 17, 2016 at 5:44
7
  • 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. Commented Nov 17, 2016 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. Commented Nov 17, 2016 at 16:54
  • 1
    You could try using an 32u4 which have built-in USB. Commented Nov 17, 2016 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. Commented Nov 17, 2016 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? Commented Nov 17, 2016 at 20:00

1 Answer 1

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.

answered Nov 17, 2016 at 16:14
4
  • 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. Commented Nov 17, 2016 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. Commented Nov 17, 2016 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. Commented Nov 17, 2016 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. Commented Nov 19, 2016 at 22:13

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.