Electronic – How to connect ATTiny13 to USB

attinyserialusb

This may be on the limit of ATTiny13 possibilities, but still: is it possible to connect ATTiny13 to USB to get ADC readings (one way)?

According to this article http://www.vk2zay.net/article/211 (and my understanding of it) it seems doable, though the size of the serial communication program takes a lot of memory.

However, instead of max232 I have Micro USB to Serial Adapter from microbot (http://www.microbot.it/products/mr002-002-1.php ). (Well, I also have max3323 chip, but I would like to spare it for something else).

I am aware of this question:
How can I communicate between micro-controller and PC without the use of RS232/USB Adapter?

but can't quite understand why max232 is needed in between?

UPDATE: I can't find any better datasheet on the adapter, but it uses MCP2200 chip.

UPDATE 2: as Passerby answered below, one can connect attiny directly to the microbot's adapter. For the record, these are changes I made to above mentioned project to make it work:

  1. Line 52 of the code needed "const": const unsigned long mags[10] PROGMEM = {… to make avr-gcc happy.

  2. Pin 6 of the attiny needs to be connected to RX of the adapter (attiny can use Vdd and Gnd for 5v power)

  3. I have not set any fuses with avrdude (removed them in Makefile)

  4. Baud rate in my case was 1200, and all it took to see the output of attiny was cu -l /dev/ttyACM3 -s 1200 (I guess, cu does some magic to the adapter in the beginning to set the baud rate). Baud rate has been calculated by looking at the pin 6 output with oscilloscope, which gave about 0.8 ms min pulse width. (cu is Linux/Unix serial utility, another one tried is minicom)

  5. The datasheet for the adapter is not enough. I needed to look up MCP2200 chip's specs to make better guesses

Best Answer

The microbot adapter is a TTL (Typically 5v) based usb-to-serial adaptor. I can't tell what IC they use, but they all act the same. Just hook up the TX, RX, and GND pins to your ATTiny13, and start a regular serial communication. Or in this case, just ATTiny's TX to the adapter's RX pin and Ground pins together, as the project you link to is transmit only. You would simply replace the max232 in the circuit, with the usb adapter instead. Everything else stays the same.

The max232 is used when converting from TTL serial (0v Low, +5v High) to actual RS232 like a computer serial port would use (+3~25V Low, -3~25V High). Since you are using a usb-to-serial adaptor with TTL levels, the same that the ATTiny13 would use, the max232 is not needed. There are some usb-to-serial adaptors intended to be used with actual rs232 level stuff, so the max232 or similar chip would be useful then, but not in your case.

The 5v from the microbot adapter is directly connected to the usb 5v pin. This gives you up to 500mA to use.