Author Topic: Micro with USB support for a software guy  (Read 11352 times)

0 Members and 1 Guest are viewing this topic.

Offline ndictuTopic starter

  • Regular Contributor
  • *
  • Posts: 211
  • Country: sk
Micro with USB support for a software guy
« on: May 22, 2011, 10:51:04 am »
Hi guys,
I've been watching Dave's blog for quite a while and recently started reading these forums and it's awesome, I learned a lot from you :). I tried searching around but since I don't even know what I want I didn't find it, so I thought I would ask you, sorry if this was already discussed before.

I'm a software person but always liked playing hardware stuff so I got an Arduino some time ago, did some very basic stuff on the breadboard with it and so on. Anyway, I think it's time to move away from this to a more standalone project. The arduino hides a lot of stuff from me and it just isn't the real thing. I want to make a simple little project from scratch, design it on breadboard and then make my first PCB, get it manufactured and build it. Nothing fancy, just a microcontroller, USB port, few LEDs and some sensors (probably 1Wire since I already have DS18B20).

So, I guess what I'm looking for is a simple, cheap uC in DIP package (breadboarding+my soldering still sucks), has USB support (I want to make software that will communicate with the uC and read sensor data / write LED status, maybe even put on some bootloader and program it over the USB but that isn't that important) and then just some basic stuff like few ADCs, few PWM pins for the LEDs and support for SPI/1Wire/I2C.

I tried looking on my local electronics' shop site but from that very limited selection they have (http://www.gme.sk/sk/elektronicke-soucastky/mikroprocesory-atmel-avr-mega/552911636.html, Slovak but I guess you can understand the important stuff) I couldn't find anything that has USB support in DIP package. And since I'm unaware of a better local distributor and don't want to pay big shipping from Mouser/DigiKey just for a few micros, I'm not sure what to get.

Thanks for your time guys. Maybe if there is someone here from Slovakia you could recommend me a better distributor? :)
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10179
  • Country: nz
Re: Micro with USB support for a software guy
« Reply #1 on: May 22, 2011, 11:12:59 am »
I'm no Arduino expert (in fact i've never used one) but i'm sure the USB port on all the arduinos is not part of the microcontroller at all.
It's a separate chip that appears to windows/linux/osx as a typical serial port.
So the microcontroller only needs a serial port (which 99% of them do) and it can communicate over USB to a computer through this separate chip.

That's probably why you're having problems finding a cheap micro you can use that has a usb port. It's typically the expensive high spec micros that come with built in USB.

It's much easier to use a separate chip that does a USB->SERIAL bridge because then you don't need to worry about coding any USB protocol, which is quite complex and not something you want to do for your first project.
« Last Edit: May 22, 2011, 11:25:25 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: Micro with USB support for a software guy
« Reply #2 on: May 22, 2011, 11:23:03 am »
Since you mentioned Atmel 8-bit AVRs, non of the USB models come in a DIP package. But that isn't the biggest problem (you can get ready-made boards). The big problem with Atmel AVRs is that you need to know a lot about USB to get the USB periphery working. A lot needs to be done in software, the AVR USB hardware is rather dumb.

There are at least two libraries out there to help. One from Atmel, and one called LUFA. The Atmel one isn't worth to mention. LUFA is rather complete, but still requires you know USB and know what you are doing once you want to do something not covered by the included demos.

At typical alternative is to use a normal AVR with a serial interface and connect that to some FTDI FT232R. However, the FT232R also doesn't come in a DIP package. Another alternative is to look for some cheap mobile phone "data cable" for older mobile phones. They often contain TTL level serial to USB converters. Yet another alternative is to use a typical RS232 level converter (MAX232) together with the AVR and then a cheap RS232 to USB adapter.

Or look at other vendors. Microchip has the PIC18F13K50 and PIC18F14K50 in DIP with USB. Microchip also offers USB framework software for them. But again, you need to know what you are doing if you want to do anything outside what is included as demo.
I delete PMs unread. If you have something to say, say it in public.
For all else: Profile->[Modify Profile]Buddies/Ignore List->Edit Ignore List
 

Offline ndictuTopic starter

  • Regular Contributor
  • *
  • Posts: 211
  • Country: sk
Re: Micro with USB support for a software guy
« Reply #3 on: May 22, 2011, 12:08:59 pm »
I'm no Arduino expert (in fact i've never used one) but i'm sure the USB port on all the arduinos is not part of the microcontroller at all.
It's a separate chip that appears to windows/linux/osx as a typical serial port.
So the microcontroller only needs a serial port (which 99% of them do) and it can communicate over USB to a computer through this separate chip.
At typical alternative is to use a normal AVR with a serial interface and connect that to some FTDI FT232R. However, the FT232R also doesn't come in a DIP package.

Yep, I have the Dueamillanove and this is exactly what they use there. I already tried looking for this in DIP but couldn't find it, and I also hoped I could avoid doing that if I could find one uC with USB support.

Since you mentioned Atmel 8-bit AVRs, non of the USB models come in a DIP package. But that isn't the biggest problem (you can get ready-made boards). The big problem with Atmel AVRs is that you need to know a lot about USB to get the USB periphery working. A lot needs to be done in software, the AVR USB hardware is rather dumb.

There are at least two libraries out there to help. One from Atmel, and one called LUFA. The Atmel one isn't worth to mention. LUFA is rather complete, but still requires you know USB and know what you are doing once you want to do something not covered by the included demos.
It's much easier to use a separate chip that does a USB->SERIAL bridge because then you don't need to worry about coding any USB protocol, which is quite complex and not something you want to do for your first project.


Oh, didn't know that. I wasn't looking for a full USB stack support, just a simple FTDI-like converter so I can do text-based communication between the uC and my desktop software.

At typical alternative is to use a normal AVR with a serial interface and connect that to some FTDI FT232R. However, the FT232R also doesn't come in a DIP package. Another alternative is to look for some cheap mobile phone "data cable" for older mobile phones. They often contain TTL level serial to USB converters. Yet another alternative is to use a typical RS232 level converter (MAX232) together with the AVR and then a cheap RS232 to USB adapter.

Yeah, I was hoping to avoid this adapter hell. I want something simple and reusable, so when I make another board I just put on the USB connector and use a standard USB cable since I have lots of those.

Or look at other vendors. Microchip has the PIC18F13K50 and PIC18F14K50 in DIP with USB. Microchip also offers USB framework software for them. But again, you need to know what you are doing if you want to do anything outside what is included as demo.

After a quick check I found some distributor for the PICs, I could get it for 3.58eur + 5eur shipping, that's not so bad if I would order a bunch of them, maybe if I tried harder I could get better price. But I couldn't find them in the local shop where I can just go pick it up, fast and no shipping costs.

Would it be hard to just do serial communication? I don't need anything else, just read current sensor values in my software, do some logging/processing and send back settings for LEDs or something like that. Just two-way text communication

So, I guess I either go with the PICs, get a bunch of them delivered, buy a programmer and hope I can use the USB stack.
Or, get whatever AVR/... that I can find locally and try to find some DIP package USB<->serial chip right?

Maybe I'm just thinking the wrong way. Basically, I want something that I can prototype on a breadboard to read some 1Wire/SPI/I2C sensors, drive some LEDs and talk to my PC over USB, then I want to take that, make a schematic and PCB of the final design and get it manufactured, solder it (I don't think I can do any SMT) and have a permanent board I can use.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10179
  • Country: nz
Re: Micro with USB support for a software guy
« Reply #4 on: May 22, 2011, 01:47:34 pm »
Might be worth looking to see if there is any code available to create a USB-SERIAL bridge using an AVR thats available in DIP.
You might be able to buy two DIP AVRs of the same type and use one for the USB-SERIAL bridge and one for your code.

I know there's definitly code available to create a USB joystick out of an ATMEGA8 (which is available in DIP).
It implements the entire USB stack in software so doesnt need any hardware USB support in the micro at all

« Last Edit: May 22, 2011, 01:49:43 pm by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline Leo Bodnar

  • Frequent Contributor
  • **
  • Posts: 808
  • Country: gb
Re: Micro with USB support for a software guy
« Reply #5 on: May 22, 2011, 02:27:53 pm »
PIC18F2550-I/SP

AVR software emulated USB stack is low speed (1.5 Mbps)

Offline sacherjj

  • Frequent Contributor
  • **
  • Posts: 993
  • Country: us
Re: Micro with USB support for a software guy
« Reply #6 on: May 22, 2011, 02:44:02 pm »
The new Arduinos (Uno and Mega) use the ATMega 8U2 chip for the USB to Serial conversion.  You can use the U2 style chips for direct USB interfacing.
 

Offline ndictuTopic starter

  • Regular Contributor
  • *
  • Posts: 211
  • Country: sk
Re: Micro with USB support for a software guy
« Reply #7 on: May 22, 2011, 03:03:05 pm »
The new Arduinos (Uno and Mega) use the ATMega 8U2 chip for the USB to Serial conversion.  You can use the U2 style chips for direct USB interfacing.
I know, but those are available just in QFN32 package, which is even worse than the FT232 in SSOP. I would rather stick with just PTH parts for my first project. Also I have no idea how I would prototype with a SMD on my breadboard, I would have to get/make a breakout first.

AVR software emulated USB stack is low speed (1.5 Mbps)
Well, it's not like I need some highs-speed communication. Just a bit of data every second or so about the status of sensors, every once in a while some message about button press/... and then some response from PC.

You might be able to buy two DIP AVRs of the same type and use one for the USB-SERIAL bridge and one for your code.
Couldn't I then just use one AVR that will connect to USB and do all the other work?

Anyway, I'm leaning towards the PICs. I would get a few of the PIC18F???s, a programmer (PICkit, 2 or 3? I need to do some research on this) and then I could do something like this: http://www.waitingforfriday.com/index.php/Building_a_PIC18F_USB_device (hopefully).
Also there seem to be some bootloaders available so after I burn that I wouldn't need the PICkit anymore and if I decide to make a modification to the already finished product I could just program it over USB, right? That would be pretty sweet. :)

So what do you guys use on your PC-connected projects? The FT232/similar SMD chip?

EDIT: Another option would be to do something like this: http://arduino.cc/en/Main/Standalone
I would get an FT232RL breakout, burn the arduino bootloader and then program it over the USB port. Then I would make the PCB with both pads for the FT232RL and headers for the breakout. Then I could try to (somehow ... that thing looks really small) solder the SSOP on there, and if I fail I'll just plug on the breakout board. Little expensive at 10eur/breakout (http://www.sparkfun.com/products/718:-\.
« Last Edit: May 22, 2011, 03:38:23 pm by ndictu »
 

Offline ndictuTopic starter

  • Regular Contributor
  • *
  • Posts: 211
  • Country: sk
Re: Micro with USB support for a software guy
« Reply #8 on: May 22, 2011, 06:14:19 pm »
So, I guess I'm going to answer my own thread (since I hate finding threads that describe my problem exactly only to scroll down and find no resolution).

I kept looking around and seems like the PIC is really my best choice if I can't use FT232R/MCP2200/*U2.
There are few quite nice tutorials around like this one: http://www.pyroelectro.com/tutorials/simple_pic_usb_interface/schematic.html

Thanks for the suggestions everyone.

So I just have to find a good distributor for the chips and PICkit. If you happen to know about one that has low/free international shipping please let me know. :)
 

Offline tsmz

  • Contributor
  • Posts: 30
Re: Micro with USB support for a software guy
« Reply #9 on: May 22, 2011, 06:21:59 pm »
I think it mainly depends on what you want to do. The arduino is great for prototyping, as it abstracts quite a bit from the hardware.
Burning an arduino program to a standalone chip and programming the chip with directly C/C++ without the Arduino libraries are wholly different worlds. The first one is rather easy, as you just need to get some support parts and an AVR programmer (the arduino itself can be made into a very basic one by just loading a sketch--I think it's even included in the examples) and it allows you to re-use your arduino program. The second one involves massive amounts of datasheet reading to be able to actually program the hardware.
It's not 100% clear what you really want, so recommending a solution is not that easy. I know there's a software USB implementation for almost all AVRs (can't remember the name right now, sorry), which probably could do the trick for you.

If you don't need debugging support and could use the software USB solution for the AVR or get some cheap USB-TTL converter, you could go the rather cheap route of just using the arduino as a crude AVR programmer to just get the feel of programming microcontrollers with C/C++ or even Assembler directly before investing lots of money. It could well be entirely possible you don't want to mess around without the Arduino's big selection of easy-to-use libraries if you're just into small one-off projects. The Arduino uses a commonly available, yet a bit overpowered AVR, which is good for quick prototyping and helps when using memory-intensive libraries, but you would most certainly use a cheaper chip when programming it in standard C/C++. However, if you're just interested in getting a one-off project done relatively quickly as a hobby and don't care too much about cost, the Arduino as a development solution is an excellent choice. It might simply be more of a hassle to carefully choose the component you need for the price you're willing to pay than simply getting an overpowered solution for a higher price and call it a day. Really depends on your needs and whishes.
 

Offline ndictuTopic starter

  • Regular Contributor
  • *
  • Posts: 211
  • Country: sk
Re: Micro with USB support for a software guy
« Reply #10 on: May 22, 2011, 07:11:45 pm »
It's not 100% clear what you really want, so recommending a solution is not that easy. I know there's a software USB implementation for almost all AVRs (can't remember the name right now, sorry), which probably could do the trick for you.

Really at the simplest level what I want is a bidirectional communication over USB where the uC says "Hey, sensor1 changed value to 42" and the software on PC responds "OK, turn LED1 on". I know I could just take another Atmega328, burn on the bootloader, program it and put it on a boards but I that keeps me in the walled-in arduino garden that abstracts away all the real things with fancy libraries. I want to move to something more low level, something that doesn't hide the entire compilation/programming phase from me.

I'm prepared to spend weeks debugging my code, reading datasheets (actually, I LOVE datasheets. After years of reading the outdated, broken or simply missing documentation for most software there is I can really appreciate the few hundreds of well written pages talking about every little aspect of that chip ;D) and burning chips. Of course I'll still use arduino for some quick ideas and test, but I don't want to get stuck at the beginner level forever.
 

Offline Leo Bodnar

  • Frequent Contributor
  • **
  • Posts: 808
  • Country: gb
Re: Micro with USB support for a software guy
« Reply #11 on: May 22, 2011, 07:30:45 pm »
Of course I'll still use arduino for some quick ideas and test, but I don't want to get stuck at the beginner level forever.

I think you have developed some sort of guilt syndrome and emotional attachment to some soulless piece of silicon.

There are about 50 manufacturers of ICs with hardware USB support.

Draw a little table and see what IC suits your needs best (availability/cost/package/features/support/free projects/compilers/etc) and go for it.

Atmel makes at least a few dozens of USB hardware enabled chips with AVR, 80c51 and ARM cores if you have a sweet spot for Atmel or affected by online bullies.  :D
« Last Edit: May 22, 2011, 07:36:24 pm by Leo Bodnar »
 

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: Micro with USB support for a software guy
« Reply #12 on: May 22, 2011, 07:58:04 pm »
I consider the Arduino a PoS. But if you have one, then you also have everything to do normal AVR programming.

Most Arduinos comes with an STK500 compatible bootloader in the AVR. I don't like bootloaders, but if you already have an Arduino or payed five times as much for an AVR with an Arduino bootloader, you can as well use it as-is.

The bootloader doesn't care what kind of program you send to it. You can used it to load a normal AVR C program into it, instead of some Wiring/Processing stuff. It is a normal bootloader, that even existed before the Arduino became reality.

Note: STK500 is also the name of an AVR dev board. Its programming protocol gave the STK500 protocol its name.

The good old avrdude software can do the STK500 protocol under the name 'stk500v1'. Newer avrdude versions even have a programming type 'arduino', which takes care of a few Arduino-specific deviations from STK500.

I delete PMs unread. If you have something to say, say it in public.
For all else: Profile->[Modify Profile]Buddies/Ignore List->Edit Ignore List
 

Offline ndictuTopic starter

  • Regular Contributor
  • *
  • Posts: 211
  • Country: sk
Re: Micro with USB support for a software guy
« Reply #13 on: May 22, 2011, 08:15:55 pm »
Of course I'll still use arduino for some quick ideas and test, but I don't want to get stuck at the beginner level forever.
I think you have developed some sort of guilt syndrome and emotional attachment to some soulless piece of silicon.

I'm not sure if you misunderstood me, or I misunderstood you. I'm all for moving away from Arduino, that's the whole point of this thread.
I'm still going to use arduino on some prototypes/tests, because 1) pretty much the only thing I have right now, 2) It's easy and simple, I think it's good for a quick test of something. But for serious things I'll use something else. I do not want to use them as a disposable platforms like I sometimes see on some electronics blogs where people use the board for some very simple but permanent project and need to get a new one.

Of course it's not a great board, it's not supposed to be. But it helped me get started. That's why I want to do a standalone project, to move away from arduino to a next level. I'll go with the PIC, the USB support looks good enough and I can buy them around here, at least some models.
 

Offline Leo Bodnar

  • Frequent Contributor
  • **
  • Posts: 808
  • Country: gb
Re: Micro with USB support for a software guy
« Reply #14 on: May 22, 2011, 11:01:24 pm »
I'm not sure if you misunderstood me, or I misunderstood you.

Possibly, but no problems! I did not mean anything sinister. Piece!  ;D

Offline st1

  • Contributor
  • Posts: 18
Re: Micro with USB support for a software guy
« Reply #15 on: May 24, 2011, 02:13:30 pm »
I see where you are coming from,
I'm studying something called "Rafeindavirkjun" in Iceland, (Low voltage engineering type of stuff).
I also got my self Arduino and it dosnt really let me get my hands as dirty as I'd like  :P

I'm trying to do pretty much what your describing, and having some problems, Since I'm not really a Software guy I went on a book search.
And found a book called
"Advanced PIC Microcontroller Projects in C: From USB to RTOS with the PIC 18F Series"

It has an interesting USB chapter, So I hope that helps,
(Oh yeah, I'm going to go see if I can set up some basic communication in Proteus) I'll get back to you  ;)
« Last Edit: May 24, 2011, 02:22:06 pm by st1 »
 

Offline ndictuTopic starter

  • Regular Contributor
  • *
  • Posts: 211
  • Country: sk
Re: Micro with USB support for a software guy
« Reply #16 on: May 24, 2011, 02:31:45 pm »
And found a book called
"Advanced PIC Microcontroller Projects in C: From USB to RTOS with the PIC 18F Series"

It has an interesting USB chapter, So I hope that helps,
(Oh yeah, I'm going to go see if I can set up some basic communication in Proteus) I'll get back to you  ;)

Great, thanks for the tip, I'll add it to my book ToDo list :)

I also want to write all the stuff down and make a little reference for myself / tutorial for others once I get my project working.
 

Offline st1

  • Contributor
  • Posts: 18
Re: Micro with USB support for a software guy
« Reply #17 on: May 24, 2011, 04:45:20 pm »
Indeed! I'm working with the code and example from the book and some other places i'm trying to get this sucker to work
Here's a site I got some code from http://www.lvr.com/hidpage.htm#MyExampleCode
Gotta pop off to work but I'll be back in a few hours to continue this little adventure  ;D

oh and here's a pic of the circut, very basic but lets hope it works ;D
http://desmond.yfrog.com/Himg402/scaled.php?tn=0&server=402&filename=usb101.png&xsize=640&ysize=640
 

Offline Leo Bodnar

  • Frequent Contributor
  • **
  • Posts: 808
  • Country: gb
Re: Micro with USB support for a software guy
« Reply #18 on: May 24, 2011, 09:39:13 pm »
Indeed! I'm working with the code and example from the book and some other places i'm trying to get this sucker to work
Here's a site I got some code from http://www.lvr.com/hidpage.htm#MyExampleCode
Gotta pop off to work but I'll be back in a few hours to continue this little adventure  ;D

oh and here's a pic of the circut, very basic but lets hope it works ;D
http://desmond.yfrog.com/Himg402/scaled.php?tn=0&server=402&filename=usb101.png&xsize=640&ysize=640

You need some current limiting resistors for LEDs unless they have internal ones.

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13913
  • Country: gb
    • Mike's Electric Stuff
Re: Micro with USB support for a software guy
« Reply #19 on: May 25, 2011, 08:15:26 am »
There are several PICs in DIP packages with USB. Even one with USB host (PIC24FJ64GB004).
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10179
  • Country: nz
Re: Micro with USB support for a software guy
« Reply #20 on: May 25, 2011, 08:52:58 am »
You might be able to buy two DIP AVRs of the same type and use one for the USB-SERIAL bridge and one for your code.
Couldn't I then just use one AVR that will connect to USB and do all the other work?

Implementing usb on an avr in software is pretty demanding, there isn't much power left to do other things.

Plus it's convenient if you can just flash someones code into an avr and you have a nice USB-SERIAL bridge all ready to go, without needing to change anything in their code (which could be in ASM).
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline ndictuTopic starter

  • Regular Contributor
  • *
  • Posts: 211
  • Country: sk
Re: Micro with USB support for a software guy
« Reply #21 on: May 25, 2011, 10:06:08 am »
Implementing usb on an avr in software is pretty demanding, there isn't much power left to do other things.

Plus it's convenient if you can just flash someones code into an avr and you have a nice USB-SERIAL bridge all ready to go, without needing to change anything in their code (which could be in ASM).

So just using it like a FT232 replacement. I might try that some time but the PICs with USB support look more practical.

There are several PICs in DIP packages with USB. Even one with USB host (PIC24FJ64GB004).
I was looking at that one actually, might order some and use them for an android hardware accessory. But I still don't have the newest software update for that and want to avoid rooting my phone while it's in warranty.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf