Shop OBEX P1 Docs P2 Docs Learn Events
basic 2 stamp and usb... — Parallax Forums

basic 2 stamp and usb...

dottedquaddottedquad Posts: 11
edited 2007-04-16 15:18 in BASIC Stamp
I would like to create a project that connects to my computer VIA usb using the basic stamp 2. Then I would like to create a C# program to send and receive commands. Is this possible and what type of hardware would I need to use? The only hardware I thought of is a usb cable and usb port for the hardware end.


-Thanks

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-16 02:21
    It is possible. The Stamp speaks standard asynchronous I/O. If you're using USB, you already have a USB to serial adapter either built into the development board you're using or separate from it and you're using it to program the Stamp. You can use the same adapter to talk to a program. Have a look at the SERIN/SEROUT and DEBUG/DEBUGIN statements in the PBasic manual for the Stamp side of things. You'll have to work out the C# end yourself. The only tricky part is that, if you use the programming port for communications, when the virtual (USB) serial port is opened on the PC, it will reset the Stamp since that's how programming is done. You can disconnect the DTR (reset) line temporarily (when not programming the Stamp) if you need to or you can use a separate USB to serial adapter and a pair of I/O pins for the serial port.
  • dottedquaddottedquad Posts: 11
    edited 2007-04-16 02:41
    sounds interesting. I was under the assumption that I could get a usb port solder it onto my pcb and connect a usb cable from that to my computer. Then communicate with my i/o leads from the microprocessor to the usb port then to my computer.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-16 03:21
    USB is a very complex protocol that also requires a lot of high speed bit manipulation, far beyond the capabilities of something like a Stamp or PIC or similar processor that doesn't have special purpose circuitry built-in. There are some special exceptions for things like a mouse or joystick, but even that is usually problematic. FTDI and others have relatively cheap ($30) USB to serial adapter chips that do all the work for you and require a minimum of external parts. One example is: www.saelig.com/miva/merchant.mvc?Screen=PROD&Product_Code=U040&Category_Code=U and another is Parallax's PropPlug: www.parallax.com/detail.asp?product_id=32201.
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-04-16 15:18
    The typical way people do this is to purchase a USB to Serial adapter. They then plug the Serial part of this adapter into the DB-9 connector of the BOE board, and the USB end of it into the PC.

    The PC C# program (or whatever) treats the USB adapter as a "COM" serial port. It would be possible to purchase a DB-9 plug, solder some wires to it, and plug those wires into the BOE breadboard. You could then use the USB to Serial adapter with other pins than the BS2 programming port.

    However, as Mike says, the 'native' USB protocol is quite involved. There's a 'slave' device, a 'master' device, an identification phase, the 'master' needs to load a 'driver' for the particular 'slave' involved. Unlike RS-232, there's a lot of signalling and communication going on to establish the link. Fortunately, a simple $20 or so USB to Serial adapter handles all of this for you.

    So that's the easy way to go. I believe Jan Axelson has written a complete "USB Interfacing" book which covers all the complexities if you really want to go that way. But you could easily spend $3,000 on hardware to get your simple $20 interface working.
Sign In or Register to comment.