Author Topic: Controlling USB port  (Read 2756 times)

0 Members and 1 Guest are viewing this topic.

Offline robokiTopic starter

  • Beginner
  • *
  • Posts: 5
  • Helpful? 0
Controlling USB port
« on: June 14, 2008, 01:14:10 AM »
Hi...I'm a novice student learning robotics whenever I have time...
I've been working with parallelports untill now...
I recently got a new computer, and it DOESN'T have a parallelport,,T_T
So I'm trying to communicate with my robot (Atmega series Microcontroller) using a USB port.
Is there a specific line of code or command for basic avr lib to output in USB port?
I know USB works in rate based signal transmissions, unlike the parallelport...(Life was so much simplier when everything was just 0/1)
I have limited knowledge of USB and C...(My major is pure software-Java)
Can anyone explain to me how(program based) to communicate with MCU using USB port?

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: Controlling USB port
« Reply #1 on: June 14, 2008, 02:21:00 AM »
implementing the USB protocol on a microcontroller is very complicated.
here's one example:
http://www.obdev.at/products/avrusb/index.html

a more simple option is to use a USB to UART chip and connect it to your microcontroller's UART.
the FTDI232 is an example of such a chip: http://www.ftdichip.com/Products/FT232BM.htm

i've done it both ways and would recommend using a USB to UART chip as it leaves far more microcontroller resources to use on your project.


dunk.

Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: Controlling USB port
« Reply #2 on: June 14, 2008, 07:36:38 PM »
perhaps just use a USB-parallel converter

that creates a virtual parallel port that the computer sees
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: Controlling USB port
« Reply #3 on: June 14, 2008, 09:08:19 PM »
Definitely use a converter, like those from FTDI series.
With some headache, you can set up and compile libusb on the host side. With more headache, you can set up a client-mode firmware for usb (such as igor cesky's, or obdev's) - non comercial of course. With most headache and least restrictions, you can write your own usb client.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline benji

  • Supreme Robot
  • *****
  • Posts: 832
  • Helpful? 0
Re: Controlling USB port
« Reply #4 on: June 15, 2008, 03:15:58 AM »
by the way,, arnt there any microcontrollers that has built in hardware USB ? it would just add 2 pins
good ol' BeNNy

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: Controlling USB port
« Reply #5 on: June 15, 2008, 07:49:12 AM »
PIC18Fx550, AT-90USBxxxx.
It's not the pin problem, it's the unfriendly design. Have you every looked over the Windoze' kernel API calls for accessing USB? Even with something like libusb, it's still a big mess.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline benji

  • Supreme Robot
  • *****
  • Posts: 832
  • Helpful? 0
Re: Controlling USB port
« Reply #6 on: June 15, 2008, 01:48:14 PM »
this has usb (its a usb to rs232 converter thats used)

www.olimex.com/dev/avr-p40-usb-8535.html
good ol' BeNNy

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: Controlling USB port
« Reply #7 on: June 16, 2008, 07:45:35 AM »
It boils down to this
if you have a converter, you have a serial port. nothing more. no fancy usb features, bulk transfers, high speed. also, no complicated driver installation (or programming) is required
if you have an usb chip or an usb on your uc, you have to learn to use all its registers, configure, make it work, write (or get) drivers for it on the host side, experiment, link the two together, debug, test for errors. on the good site, you can do whatever the hell you want (and usb specs permit).

a converter is more hobbyist-friendly though. way, way, more. none of those fancy features are really required.

Now, something really cool would be if we could write a USB host library for a uc. For under $10, we'd have a camera for our robots, and huge storage in a tiny space
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline benji

  • Supreme Robot
  • *****
  • Posts: 832
  • Helpful? 0
Re: Controlling USB port
« Reply #8 on: June 16, 2008, 10:43:52 AM »
ye izua yer right
good ol' BeNNy

Offline robokiTopic starter

  • Beginner
  • *
  • Posts: 5
  • Helpful? 0
Re: Controlling USB port
« Reply #9 on: June 16, 2008, 07:28:42 PM »
Thanks for all your help...
It seems like almost all devices today are USBed...
Some of the newest technologies don't even have Parallel or Serial ports...
I guess I'll have to stick with USB>parallel converter for now...
Hopefully in the future, all MCUs are competible with USB link...
Cause right now, I'm having problem with setting up libusb...Real pain...

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: Controlling USB port
« Reply #10 on: June 16, 2008, 07:34:29 PM »
libusb is a real pain.

I used obdev firmware usb. That's how I found out about libusb. After some work you can compile both the firmware and the host-side software.
they both work, and with some understanding of C, you can modify them to suit your needs. Just use a converter, like the FTDI chip.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline emmannuel

  • Full Member
  • ***
  • Posts: 87
  • Helpful? 0
Re: Controlling USB port
« Reply #11 on: June 16, 2008, 10:31:01 PM »
libusb is a real pain.

I used obdev firmware usb. That's how I found out about libusb. After some work you can compile both the firmware and the host-side software.
they both work, and with some understanding of C, you can modify them to suit your needs. Just use a converter, like the FTDI chip.

I'm so going to have to play with obdeb and libusb after reading their docs it seems its what I was looking for quite a bit ago thx! :D

I wanted to learn how to do really low level stuff like that.

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: Controlling USB port
« Reply #12 on: June 17, 2008, 12:40:54 AM »
Here, a usb led with obdev firmaware and libusb.
I have succesfully compiled the firmware for 12 MHz and ran the console program with my compiled libusb. The led is in the examples folder, Custom Class
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline robokiTopic starter

  • Beginner
  • *
  • Posts: 5
  • Helpful? 0
Re: Controlling USB port
« Reply #13 on: June 17, 2008, 03:44:17 PM »
Because I want my interface between my computer and the MCU to be mobile and flexible, I can not use FTDI series (I wouldn't want wires and breadboards dangling along).
However, I got one of these:http://www.tigerdirect.com/applications/SearchTools/item-details.asp?EdpNo=381274&CatId=471
It's a USB>Parallelport Cable, and it seems to work fine with printers...But, when I try outputing to pin1 of Parallelport, It doesn't work...=(
Doesn't the driver create "virtual" parallelport?
If not, is there ANY driver,software,ctr that allows me to use this USB>parallelport Cable as my parallelport??

P.S- By the way, if one of you guys are using labtop to interface with your robots, how do you do it?
« Last Edit: June 17, 2008, 03:50:37 PM by roboki »

Offline krich

  • Robot Overlord
  • ****
  • Posts: 165
  • Helpful? 0
Re: Controlling USB port
« Reply #14 on: June 17, 2008, 04:40:00 PM »
I could be mistaken, but perhaps your USB to Parallel adapter makes the parallel port look like a USB port, rather than making the USB port look like a (virtual) parallel port.  There would be a distinct difference between the two, namely the way the interface looks on the computer.  If you look in your printer settings and its set to print to a virtual LPT port, then its the latter.  If not, then its the former and you're out of luck.

Of course, I could be completely wrong about this.

 


Get Your Ad Here