element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs First experience "building" a USB interface: success!
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: modalpdx
  • Date Created: 7 Sep 2016 7:07 PM Date Created
  • Views 677 views
  • Likes 5 likes
  • Comments 4 comments
  • spaghetti
  • usart
  • ch340g
  • usb 2.0
  • attiny104
Related
Recommended

First experience "building" a USB interface: success!

modalpdx
modalpdx
7 Sep 2016

Okay, so most folks are going to read this and go "Huh? Who cares, I did that when I was 4." However, in all my years of dinking with electronic gizmos, I've never before "built" a USB interface to an MCU. That is, until today.

 

I recently bought a set of 5 CH340G chips via eBay. If you have a cheap $3 Arduino UNO knock-off or perhaps a cheesy USB/TTL adapter off of eBay, odds are good you have a device that uses this chip for USB instead of the usual FTDI chip. I think I paid around $4 for the set, free shipping. Can't beat that. I'm sure the quality pales in comparison to FTDI's chips, but I'm not looking for quality, I'm just looking for a basic USB connection that interfaces with the USART of the ATTiny104 MCU on my Xplained Nano board.

 

Holy wowza, there's a lot of hardware that's required outside of the CH340G chip! It's a good thing that I've gone on lots of pointless buying sprees on eBay, collecting capacitor sets, different flavors of jumper wires, etc, because I had all the parts. There's no better feeling than when you decide to embark on an electronics project and you don't have to order a damn thing because you have everything you need.

 

The schematic that I used was only slightly spaghetti-ish:

 

image

 

 

(Image from sunrom.com.)

 

The breadboard, however, was COMPLETELY spaghetti-ish.

 

image

 

The Xplained Nano board on the smaller breadboard was programmed to receive a single byte via USART and copy that byte into PORTA, which would then either turn on or turn off pins (PA0 - PA7) depending on whether the pin's associated bit was on or off. I had this working fine with the built-in USB hardware, but this is the first time I've gotten it to work with home-grown external USB hardware wired directly to the MCU. I shouldn't be too surprised that it works, but shoot me, I am.

 

Anyway, I just wanted to yell about my minor victory. I guess I need to crank up Eagle now and bang out a basic ATTiny104 dev board so I can stop hammering on my Xplained Nano. If nothing else, I can put on a MINI USB connector. Micro USB connectors are like plastic food wrap to me. Grrr...

 

That's all, folks. Time to get back to work. image

 

image

 

(Don't look at my bad hand-solder job. I was in a rush.)

  • Sign in to reply

Top Comments

  • uscdadnyc
    uscdadnyc over 9 years ago +1
    To: ER. Great write-up. Over the past Three years I have accumulated stuff that is RaspPi/Arduino related. To hedge my bets, I admittedly bought stuff that I really did-not-know whether I actually needed…
  • DAB
    DAB over 9 years ago +1
    Nice post. Any time you have a successful project helps convince you and others that you can do more and that you are learning. We all started somewhere. Well done. DAB
  • modalpdx
    modalpdx over 9 years ago in reply to DAB

    Thanks! I hope some day I can slow down on learning and speed up on creating, but I guess there's no rush. I don't do any of this for a living so it's mostly just having fun.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 9 years ago

    Nice post.

     

    Any time you have a successful project helps convince you and others that you can do more and that you are learning.

     

    We all started somewhere.

     

    Well done.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • modalpdx
    modalpdx over 9 years ago in reply to uscdadnyc

    For me, the problems began with an Arduino UNO that my wife gave me for Christmas. This was probably about 4 years ago. I decided to try controlling two tiny servos for a pan/tilt camera base for a web camera, but at some point I decided that using an expensive Arduino for something that simple was wasteful, so I started looking into programming the AVRs directly. It's been downhill since then. My office is filled with art supply bins and containers of samples, bulk purchased chips, various components like capacitors and resistors, a scrappy SMD soldering setup, PCBs from OshPark, motors culled from dead PC peripherals, power supplies, etc. I've done nothing useful with any of it other than tinker and learn.

     

    And to date, my tiny pan/tilt web camera base is still disconnected from everything and sitting in a drawer waiting for me to give it some attention. Sometimes I think I'm moving backwards. I did begin working on controlling two servos using the same Xplained Nano board shown above, but the motors are very jittery so either I'm not using enough timers or I don't have PWM figured out or I'm doing something that'll make my Xplained Nano explode (or all of the above). The servos are being powered separately (of course) but something still isn't right. Not high on my priority list, but something I plan to look into.

     

    As for grandpa's RS-232, I guess some tech will never die. I'm happy that I can get things to work at all, and if yesterday's tech gets me there, I'll take it. image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • uscdadnyc
    uscdadnyc over 9 years ago

    To: ER. Great write-up. Over the past Three years I have accumulated stuff that is RaspPi/Arduino related. To hedge my bets, I admittedly bought stuff that I really did-not-know whether I actually needed or Not. ex: Popolu USB AVR Programmer. By reading the various Blog Threads here at element14, I am getting an idea of what is what. Right now I am plodding thru a MOOC course on Matlab Programming, delaying h/w implementations. B/C Matlab/Simulink have support for RaspPi/Arduino. I did mount a RaspI 3 B in a SmartiPi Enclosure along w/ the 7" LCD Touchscreen. Along w/ USB Keybd and Mouse. BTW in the 1980's to 1995, I did Data Communications. It is curious that the pins on the CH340G Chip are reminiscent of the old EIA RS-232 Standard  of the last century. RTS, CTS, RS232_EN, DSR, etc. I guess this is Not your grandfather's RS-232?

    USCDADNYC (NY NY USA)

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube