USB mouse to BS2 using Parallax Memory Stick Data Logger
Bill Kingsley
Posts: 11
Has anyone used the Parallax Memory Stcik Data Logger as a USB Host to read input from a USB mouse to a Basic Stamp? I want to receive touch data from a USB touch screen into a BS2. I have done this with a few times before with a rs232 serial touch screen. The touch screen sends a string of bytes that relate to the x and y coordinates each time the screen is touched.
Is there a simple way for the USB Memory Stick Data Logger to simply pass received USB strings to the BS2? I am new to using USB with a micro. I suspect I may need to do some sort of hand shake to make the USB connection first?
Is there a simple way for the USB Memory Stick Data Logger to simply pass received USB strings to the BS2? I am new to using USB with a micro. I suspect I may need to do some sort of hand shake to make the USB connection first?
Comments
Memory Stick Datalogger as a HID Controller :: Parallax Forums
See:
http://forums.parallax.com/forums/default.aspx?f=21&m=416258
MSDTech
Total Posts : 318
Posted 1/7/2010 6:49 PM (GMT -7)
School finally got past the "Science Fair" and I've finally got some time to get back working on my robot Sparkey. I've gotten tired of lugging around a notebook
to allow me to use a game controller to drive him and have decided to build a dedicated controller module. As part of this effort, I've been looking at methods to interface a BS2px with a Philips SGC2909BB/27 Game Controller.
For one of the experiments in the "Science Fair", the student requested I build a module to measure and record the data in his experiment. To support this, I bought the Memory Stick Datalogger (#27937) and a USB jump drive. As it turned out, I was able to use the teachers PC and the Parallax PLX-DAQ Spreadsheet tool to log the data directly into Excel. Reading the datasheets on the data logger, I noticed that the default software would also support a HID on the port and decided to see if I could get it to read a game pad. And it does. The wiring for the attached code is simple:
Memstick Pin Connect to BS2px Pin:
1 Vss
2 Pin 4 (USBDataIn) I always have to remember the the
Serial Data Output for the device is Input to the Stamp
3 Vdd
4 Pin 5 (USBDataOut)
5 Pin 6 (USBClk)
6 Pin 7 (USBCS)
7 No Connection
8 No Connection
Also to use this code, the Jumper must be in the SPI position before the Data Logger is powered up.
Caveat: The only game controller I have this working for is the Philips unit listed above.
Reverse engineering the Philips unit, I came up with the following:
Data Packet - 6 Bytes Total
Byte 1
Left Joystick Horizontal 0=full left 128=Centered
255=full right
Byte 2
Left Joystick Vertical 0=full up 128=Centered 255=full
down
Byte 3
Right Joystick Vertical 0=full up 128=Centered 255=full
down
Byte 4
Right Joystick Horizontal 0=full left 128=Centered
255=full right
Byte 5
Button Status (Active High)
Bits 0 to 3 = Top Hat Control (my springs are loose and
I get non-consistant output)
Bit 4 - Button 1
Bit 5 - Button 2
Bit 6 - Button 3
Bit 7 - Button 4
Byte 6
Button Status (Active High)
Bit 0 - Button 5
Bit 1 - Button 6
Bit 2 - Button 7
Bit 3 - Button 8
Bit 4 - "Select" Button
Bit 5 - "Start" Button
Bits 6 & 7 - Not in packet
The controller sends a new packet each time a button status changes. The controller sends a continuious stream of packets any time one of the two analog joysticks is off the center position.
Now to start working on integrating a Propeller Backpack to display the telemetry the robot sends back on the TV monitor and replacing the bluetooth link with a pair of the 433 MHz RF Transceivers. The bluetooth link is in the same frequency band as the TV security camera and causes interference.
File Attachment :
Gamepad Test.bpx 3KB (application/octet-stream)