Shop OBEX P1 Docs P2 Docs Learn Events
USB interfacing — Parallax Forums

USB interfacing

ArchiverArchiver Posts: 46,084
edited 2002-04-26 07:25 in General Discussion
Hey folks,

Has anyone played with USB on a stamp?

I've been playing with a USBMOD2 from FTDI, and have had some success, but I
suspect my USBMOD2 may be dead.

Here is my first USB experiment:

A Mac with USB is connected to the USBMOD2
The USBMOD2 is connected to a Parallax Stamp Microcontroller.
The Stamp is connected to my Windows Laptop via RS232.

Pressing a Key on the Mac, should make the same Key character appear on the
Windows laptop.

I'm using Claris Data Comms on the Mac, and Hyperterminal on the Windows
Laptop.

Now, when data is sent to the USBMOD2, it sends RXF low to indicate data in
the FIFO.

The stamp then Toggles /RD low then high to make that data appear on the 8
bit data bus, then reads that byte and sends it to the Windows Laptop via
it's RS232 port.

The program seems to work OK. When I press a key on the Mac, Hyperterminal
advances one space. However, it seems the data bus is staying at 11111111
all the time, that is - the data isn't getting loaded on to the bus from the
FIFO.

I followed the circuit diagram in the sample application provided at the end
of a pdf document for this Module.

That document shows EERQ as being tided to V+. If I don't have an EEPROM, I
would assume that this input should be tided to ground, right?

However, when I do that, the power supply gets shorted. This seems strange,
considering that pin is an Input.

If I am running the Module from the stamp's power supply, should the
module's V+ and ground be wired differently? That is, I don't need a USB
BUS powered set up.

Below is my program for the stamp, does this look OK? It is easy to follow
(with comments included).

'{$STAMP BS2}

'This program receives data from the USB port
'and transfers it to the RS232 port

'*****DECLARE VARIABLES*****
'CONSTANTS
readUSB CON 9 'P9 = read data from the USB module /RD

'VARIABLES
datafromUSB var byte 'the data from the USB Module

'*****MAIN PROGRAM*****

INS = %0000000111111111 'Set required ports as inputs
HIGH readUSB 'set /RD high

ReadUSBMOD:
'If RXF is low get the byte else go to start of loop
IF IN8 = 0 then GetUSBdata
goto ReadUSBMOD
GetUSBdata:
PULSOUT readUSB, 1000 'Send /RD low then high
datafromUSB = INL 'D0 - D7 are connected to P0 - P7 of the stamp
SEROUT 16, 396, [noparse][[/noparse]datafromUSB] 'send the byte out the RS232 port
GOTO ReadUSBMOD

Cheers,

Ben, Wellington, New Zealand.

--
http://www.lennard.net.nz/
Ben Lennard, NCEE, Dip EE

Web Hosting and Electronics R&D
Club Coordinator, Victoria University of Wellington Hockey Club

Hm: +64 4 972 7567
Mb: +64 21 536 627
87 Spencer Street
Crofton Downs
Wellington
New Zealand

"To the optimist, the glass is half full. To the pessimist, the glass is
half empty. To the engineer, the glass is twice as big as it needs to be."

No animals were harmed in the transmission of this email, although the
Dog next door is living on borrowed time, let me tell you! Those of you
with an overwhelming fear of the unknown will be gratified to learn that
there is no hidden message revealed by reading this warning backwards.
>
>
Sign In or Register to comment.