Teensy to imitate a USB bulk data transfer - usb

I've purchased a teensy 3.0 in the hope I can use it to imitate the USB bulk transfer from another piece of hardware.
I am developing some software to read and process the data coming over USB in a bulk transfer
But I am trying to do this prior to actually having the USB device to test against
Hence I thought I could imitate the actual device by having a teensy send a few representative packets over the USB instead.
I know the USB packet format so can knock up a few char arrays with the expected binary format. I'd then have write a program (hopefully in C as thats what I know) that encapsulates those char buffers and then tries to send them as a bulk transfer over USB, probably using libusb I think. I'd have to build and load this on to the teensy using the correct build tool (avr-gcc and halfkay?) and then plug in the teensy and hope it behaves like the device i am trying to simulate
does this sound feasible/possible?
can anyone suggest what the code might look like or any good tutorials? I'm so new to this I don't even know what to search for.
Might it be the case that I have to learn 'arduino' as opposed to being able to write the program in C?

First let me clear what I understand from your question.
You are creating a software that can analyse any data that can come over USB.
You are trying to use Teensy to send data to USB and then process it.
Now the answer for feasibility lies in the compatibility of your software. If your software is able to read data from a USB that is initialized as a COM Port, then and only then your software wold be able to read that data.
This is because both Teensy and Arduino uses USB port with a FTDI chip that communicates with all the other devices as a serial communicator. This is a small chip near the USB port.
Now if your software is able to read data from a COM port, then when programming the Teensy, you just have to use usb_serial_write() function with a loop. You can get more help over here.
But if your software is not able to read from a serial COM port, there are many other applications such as Teraterm to store received data to a file. You can then use this file extract the data and process it.

Related

How to write firmware for a custom USB keyboard?

I have a custom ps2 keyboard(8x8 matrix) interfaced with AT89C51ED2 microcontroller, now I need to change it to USB interface. I have been studying about the basics of USB HID class communication(USB HID class specs, USB complete, Beyond logic) and have come to know little bit about the theory behind it.
But I am not able to understand the firmware part, I read a demo keypad application by Microchip which had given a sample source code, but I am not able to understand in the code how data(key pressed) is sent to the IN endpoint and how the host reads that through polling. I know that endpoint is a buffer from which data is sent to host, but Is it one of the registers of the micro-controller and how do I use it in my code?.
And I have been searching the suitable micro-controller with USB support, but no supported demo's are available, any suggestions will be helpful
The AT89C51ED2 datasheet does not mention hardware support for USB, so the answer is no: an endpoint does not correspond to a hardware register. Instead, an endpoint would refer to some software buffers in the RAM of the chip, and some data to keep track of the endpoint's state. Every bit of every USB packet must be handled by the firmware of the device, and endpoints are an abstraction that live entirely in the firmware of your device.
Note: I am assuming that the keyboard doesn't have some kind of USB interface chip, and that the data lines of the USB cable connect more-or-less directly to the microcontroller.
If you can't find the source code for the keyboard, you might look into using an open-source AVR software USB implementation. Here are some useful links:
https://www.obdev.at/products/vusb/
http://www.fischl.de/usbasp/
Please note that you are undertaking an advanced project, and if you are not familiar with AVRs, USB, microcontrollers, reverse engineering, and embedded development/debugging, it might be useful to start with something simpler first.

USB to COM, how does the RS-232 interperate data?

If I had a RFID reader that sends a bunch of keystrokes through USB like a HID, how would the COM port interperate that if I used a USB to COM converter? What would the COM port see?
You should see the "keystrokes" from the rfid device.
At the link level, the converter should take care of speed mismatch issues. It does this via an internal buffer or by throttling the sender.
But the HID protocol is more than simple keystrokes. So either the additional information will be suppressed by the USB-COM converter or it won't be. This issue may also be converter-dependent.
In this sort of HW mashup, the best thing is to try it and see. (And then write a blog post about what you discovered.)
What is your overall goal? What sw are you trying to connect the RFID reader to?
Added I agree with #Turbo J's point: most every USB-COM converter acts as a USB device. As such, if you connect them to another USB device, nothing will happen since you're using them "the wrong way around."
You'll need to find a USB/Host to COM converter. The usual name for such things is "computer" -- a used laptop may be your best bet if you want to continue down this road.
On USB, a device can only talk to the host.
The RFID reader is a device. The USB->COM converter is a device. They cannot talk to each other wihout a host.
Conclusion: If you want the RFID data going out of the COM port, write a program which does that - by reading the HID data from RFID device and writing to the USB COM port.
Probably nothing. COM ports are usually very low speed things (you can usually tweak them up to about 115kbps. USB ports are (by comparison) incredibly high speed ports. I think the lowest speed USB is like 1.5mbps.
The more important question is how you are going to make the physical conversion.
You have an RFID reader that has a usb plug on it. Are you going to chop this off and solder a db9 connector on the end, which you are then going to plug into an USB to COM adapter and try to read serial data off the com port?
You are adding in one more step into it that you don't need to (you're taking up an usb port anyway).

Provide input data to FPGA using USB

I am working on Xilinx Spartan 3E platform, using this development board:
http://www.xilinx.com/products/boards-and-kits/HW-SPAR3E-SK-US-G.htm
My program operates on certain data and then provides output. I wish to transfer the input signals externally. The input data is a stream of 8-bit signals.
So, how do I send the input signals from my laptop to the FPGA via USB? Does Xilinx support this or is there standard software to do this?
Thanks.
It sounds like you are describing a uart more than a native USB interface. You can get a USB to logic level serial adapter that will let you easily transfer data to and from a Pc at up to 921.6k baud. A uart/serial port is easy to implement in the Fpga and PCs are easy to use with serial ports.
Here is the cable:
http://www.ftdichip.com/Products/Cables/USBTTLSerial.htm
If you have a development card it is very possible this type of interface is present.
On the software side you can use your programming language of choice as if it was interfacing with a seal port or use a terminal program like hyper terminal or Download teraterm http://ttssh2.sourceforge.jp/
Updated response:
100Hz is not a hard interface to make. At that rate you should use the serial interface if at all possible. The board you referenced has 2 full RS-232 connections. At that point you only need a way to connect that to your computer. If you have a PC with RS-232 connectors you only need a cable if you have a newer computer without you need a RS-232 to USB translator cable (like this one: http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=768-1014-ND or google rs232 usb). This will give you a virtual com port on the pc to interface with the previously mentioned terminal programs or your custom software.
Update 2:
on the resource tab of the development board page you linked to there are several UART based fpga designs that you should be able to use as a starting point.
i.e. the "PicoBlaze Processor SPI Flash Programmer".
That board doesn't provide easy access to the USB interface from the FPGA as far as I can tell. It's just for configuration and debug.
Some of the newer boards and tools do allow something called hardware-in-the-loop testing where the simulator can upload data to the FPGA, wait it to calculate the results and then pull the data back. This is relatively common when using Xilinx's System Generator product as the simulations can be really long.
But I think with that board you'd be better off using the on board RS232 port to get data to and from the board. You will have to build the infrastructure to do it yourself though.
This may also give you some ideas:
http://www.1pin-interface.com/

Korg Nanokey MIDI Controller for Arduino?

I have a Korg NanoKey which I'd like to use to control a simple synthesizer I've designed on the Arduino platform. (I have an Arduino Uno.) Basically, I don't care about MIDI, I just want to read what note the keyboard has pressed down, but if MIDI is the only way I can do that, then it's okay with me. So my big question is, how do I do this? I haven't been able to find anyone else on the Internet who has already done this.
But more specifically, I see two challenges: First, I'd like to plug my NanoKey directly into the Arduino's USB port, but then I'm wondering if the Arduino would provide the necessary power to the NanoKey. Second, I'm not sure what protocol I would be reading. Can I just read MIDI signals as described in this tutorial?
I don't want to curb your enthusiasm but what you're attempting might be a bit hard basket. A USB system consists of a host controller and one or more peripheral devices. It's the host that controls traffic flow to the devices which means that devices can't transmit data on the bus without an explicit request from the host controller.
I'm not familiar with either the nanoKey or the Arduino platform but I'd be fairly confident that the nanoKey is a USB "device", normally connected to a computer which would act as the host. So what you would need for this system to work is for the Arduino to act as the host when communicating with the nanoKey. The Arduino schematic shows that the Arduino Uno uses an ATmega8U2 for USB coms. Unfortunately the ATmega8U2 is a USB device, so you've got two peripheral devices but no host controller to facilitate the transfer of data between them. You'd be better off using a development board for a micro that provides either USB Host or USB On-the-Go.
I opened up a Korg Nano controller yesterday and was surprised to discover that there's an AVR mega32 inside. It would be a significant undertaking, but with a bit of work you could probably work out the schematic and reprogram it yourself using their programming header breakout. You might not end up with much more functionality than you've got this other way, but it would be very educational.
I agree with the Jono - you are biting off a lot - it might even end up easiest to hook the keys up to the Arduino directly - tearing out the electronics and figuring out a way to multiplex the keys into a single channel without losing polyphony (resistor 'ladder' maybe). I any case, good luck. Amusingly, you'd making an analog keyboard to plug into a digital synthesizer.
Quick and Dirty Arduino MIDI Over USB demonstrates how to send/receive MIDI out over USB, but unfortunately, this probably isn't any help for what you are trying to do, since he's found a way to send and receive MIDI signals from a USB host, not act as a USB host himself - the opposite of your problem. However, I thought perhaps it would be of use, if you ever wanted to control your device from a computer.
As mentioned in the other posts, you would need to use a separate chip to provide the USB Host interface. Here's a great guide to using the USB Host shield by Circuits#Home to interface with an Akai LPK25 (USB Midi Keyboard).
http://blog.makezine.com/2010/11/30/usbhacking/
The Arduino sketch is provided, so you should be able to try it out, however debugging the USB Host connection could get tricky real fast if it doesn't work out of the box.

Arduino project using infrared sensor and usb communication

I am planning on doing a small arduino project and would like to know if what I'm thinking would work with a regular arduino board. I'm thinking of buying an Arduino Uno for my project, along with an IR LED and an IR sensor. So here's what I want to go with this:
I want to point the LED towards the sensor, so that the sensor is always detecting light. Then', I'll start "cutting" that light (say, with with my hand) several times. I want the arduino program to time the intervals between the times the light is "cut" and send these times to my computer via USB, so I can process this data.
I've seen many people talk about serial communication between an arduino board and a computer, but I'm not sure how that works. Will it use the same usb connector I use to upload programs to the board, or do I have to buy anything else?
EDIT: tl;dr: I guess my question, in the end, is twofold:
1) Am I able to "talk" to my computer using the built-in USB connector on the board, or is that used solely for uploading programs and I need to buy another one? and
2) Is this project feasible with an Arduino Uno board?
Thanks for the help!
Yes, your project is very feasible.
You use the built in USB connector to both program the device and communicate with it. Check out some examples on the Serial Reference Page
For reading the sensor, you'll want to use either a digital or analog input. For a digital input, you'll likely have to external components to control the light threshold, but it will provide a simple yes or no if something is in front of it. With an analog input, you can use a threshold in code to determine when your hand passes.
Timing can either be done on device with the Millis() function or on the connected computer.