Skip to main content

USB to Serial Converter using AVR microcontrollers




AVR-CDC converts USB and RS-232C signals using the AVR micro- controller which has no on-chip USB interface. This technology is based on Object Deveopment's V-USB (Software-USB on AVR), and the CDC (Communication Device Class) protocol was extended over it. AVR-CDC enables PC to communicate with the USB device through virtual COM port.
The basic idea of using CDC protocol over Low-speed USB is based on Kyosuke Ishikawa's experiment in 2005. To make it stable and practical, Christian Starkjohann in Object Development helped me modifying his V-USB stack. Since three endpoints and the bulk transfer on low-speed device violates the USB standard, I added a tiny patch driver on Windows' USB stack.
Although this technology is quite experimental, it may be useful to interface your original system to PC easily. The circuit is very simple, but it requires a certain amount of skills to control. If you need practical or stable solutions, or you are not familiar with electronics nor installing drivers, use the dedicated chip from vendors like FTDI.
The back door to the low-speed bulk transfer is gradually closing on the newer OS. After enjoying this USB technology, switch to the HID protocol or to MCU having on-chip USB controller.





CDC-232
CDC-232 creates a virtual COM port on PC that doesn't have real RS- 232C port. It enables RS-232C communication (without control lines), after connecting the device and installing the driver.


Virtual COM Port over Software-USB



Usage
Write the program to AVR, build the circuit, and connect the device to PC's USB port. Install the driver on Windows. Access the device through generated virtual COM port from terminal software or your application. Control lines (DTR, DTS, RTS, CTS) are not used by the host application. Set the terminal software as "no flow-control".
Windows requests the driver installation again when connected to other USB port. Detect the previously installed driver automatically. Another COM number will be assigned. If you set serial number in AVR (rebuild with modified usbconfig.h), you can get the same COM port at any USB port. However, you cannot connect multiple CDC devices of the same serial number.
Before detaching the device, close the COM port in terminal software or in your application. Otherwise, you cannot connect to the device again because of the broken file handle. Restart the terminal software or your application then. Switch to the fast transfer mode using "lowcdc.vbs" to get the baudrate higher than 9600bps.

Loop-back test on ATtiny45 version
Schematics
These schematics are for ATtiny45/85, ATtiny2313/AT90S2313, and ATmega8/48/88/168. Their firmware are all ISP-programmable. The red LED drops the USB voltage from 5V to 3.3V, and provides to AVR. The current is about 10mA, and is not enough to drive other circuit. When connecting to other MCU, connect Gnd and connect TxD and RxD in crossing way. R4 limits the leak current when the MCU's Vcc is 5V. You can omit if the Vcc is equal. R5 protects the TxD pin when it shortened to Gnd. You can omit both R4 and R5 if you connect to the RS- 232C driver like MAX232. Use crystal oscillator. Although ceramic resonator works well in most cases, it becomes unstable if the frequency deviation is bigger. 

 CDC-232 for ATtiny45-20
ATtiny45/85 uses internal RC oscillator and PLL. It is calibrated by  USB signal when connected. UART is implemented by software. It is not enough for high speed data transfer. If the TxD and the RxD are inverted (rebuild with -DUART_INVERT option), you can directly connect to RS-232C line.     1200 - 4800bps, 8N1
 


CDC-232 for ATtiny2313-20               

ATtiny2313/AT90S2313 has 2KB program memory. Although the baudrate is configured automatically, some functions are omitted.   600 - 38400bps, 8N1

CDC-232 for ATmega8/48/88-20
ATmega8/48/88's internal UART is configured from the PC. The flow-control (RTS/CTS) is supported.
600 - 38400bps, data 7/8, parity N/E/O, stop 1/2


Schematics

 
 CDC-232 for ATtiny45-20



CDC-232 for ATtiny2313-20

 



CDC-232 for ATmega8/48/88-20
 


Driver and code click here for CDC home page

Comments

Popular posts from this blog

PIC 16F877A Microcontroller Based Electronic Lock 16x2LCD 4x3 Keypad

 Circuit Diagram Security is a prime concern in our day-today life. Everyone wants to be as much secure as possible. An access control for doors forms a vital link in a security chain. The microcontroller based digital lock for Doors is an access control system that allows only authorized persons to access a restricted area. An electronic lock or digital lock is a device which has an electronic control assembly attached to it. They are provided with an access control system. This system allows the user to unlock the device with a password. The password is entered by making use of a keypad. The user can also set his password to ensure better protection. The major components include a Keypad, LCD and the controller PIC16F877A. This article describes the making of an electronic code lock using the 16F877A microcontroller. The system is fully controlled by the 8 bit microcontroller 16F877A which has a 8Kbytes of ROM for the program memory. The password is stored in the

Electronic Voting Machine Using 8051 Microcontroller (AT89C51)

  Circuit Electronic voting machine has now replaced the traditional mechanism of voting due to several advantages like security, automatic counting etc. This project presents a way to develop an electronic voting machine which displays the count of votes on a 16x2 LCD interface. A user can get his/her vote register through a set of switches (one for each candidate). After every cast of vote, the subsequent count can be seen on LCD. The circuit uses AT89C51 microcontroller and the code for the project has been written in C. This LCD based electronic voting machine is designed for four candidates. The input part consists of a set of six tactile switches. The switches and 16x2 LCD are interfaced to microcontroller AT89C51 for various operations and displays. The provision of casting votes for the candidates has been provided through four of these switches. These switches are made active high and connected to pins 2-5 (P1^1 – P1^4) of the controller. The remaining two

89C51 Based Digital Thermometer Using DS1820

Introduction The hardware configuration when using multiple 1-Wire temperature sensors like the DS1820 is very simple, as illustrated in the block diagram below. A single-wire bus is used for communication between the microcontroller and the temperature sensor. It is also possible to power the devices direclty via this 1-Wire bus. An almost unlimited number of 1-WireTM devices can be connected to the bus because each device has a unique 64-bit ROM code identifier which is used to address each sensor   Temperature measurement using DS1820 sensor. Use of ‘1-wire’ protocol... Temperature measurement is one of the most common tasks performed by the microcontroller. A DS1820 sensor is used for measurement here. It is capable of measuring temperature in the range of -55 °C to 125 °C with 0.5 °C accuracy. For the purpose of transferring data to the microcontroller, a special type of serial communication called 1-wire is used. Due to a simple and wide use of these sensors, commands us