Provide input data to FPGA using USB - 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/

Related

STM32F767zIT6 to PC communication via a USB cable

I need to connect a custom board having STM32F767zIT6 as the MCU to a window PC through a USB. The aim of the board is to filter CAN-BUS messages. The existing solution uses a CANBUS-USB adapter through one of the CAN interfaces but I have been asked to implement the USB functionality on the board since it has a USB2.0 mini-B port. I need to receive CAN messages through one of the CAN interfaces and transmit it through the USB interface to a GUI on the PC and also receive CAN formatted messages from the GUI via the USB to another CAN interface on the board. I have been playing around with the HAL_library for STM32 using STM32CubeMX but I need guidance and materials I can learn faster. If possible a similar open source implementation I can learn from.

Data input/output on Basys3 board's USB port

I'm trying to configure/write VHDL code that would let me output or input data from the USB port on a Basys3 FPGA board. Problem is I have yet to found any threads or questions that talk about this topic.
The nearest thing to an answer I've found is this:
Provide input data to FPGA using USB
and it does not contain what I'm looking for.
Any clues anyone¿?
The Basys3 board has a usb-uart bridge chip as described in the reference manual. This will appear to a PC (or any device with a usb host and the appropriate usb-serial drivers) as a virtual com port. Sending data to and from a PC com port is quite easy.
You will need a uart implementation on the FPGA. There are lots of example designs on the web. One way is to implement a soft core microblaze processor with a uart peripheral in the FPGA. This example looks like it includes foundation for the functionality you desire.
The simplest implementation from the PC side is using a terminal program such as putty, Tera Term or realterm. Most languages include com(serial) port libraries or bindings. This type of interface tops out at a raw bandwidth of around 3-12Mbits per second depending on the drivers and implementation.
Read the manual for the Basys 3 board. It will explain how you can interface with USB devices plugged into the USB port. Be warned, however, that your options are pretty limited.
Short version: if you plug in a USB mouse or keyboard, they will be exposed to your design as an emulated PS/2 device. USB storage devices can be used to configure the FPGA. Other devices are not supported.

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.

Controlling simple relay switch via USB

I'm looking to control a mains powered light from a simple relay switch connected via USB to the computer.
The relay switch isn't even a USB device, it's just a simple switch that requires the USB voltage to turn it on. When the voltage drops below a threshold, the switch will turn the light off.
My problem is that I can't control the power output of a USB port. I'm happy to do it using any language on Windows or Linux (but preferably Java because I'm used to it).
Unfortunately, in most cases you cannot control the power supply to the USB port. The power supply is usually hardwired through, and not switchable in software. You can send a reset to a USB device, but that won't work in your case.
There are a number of projects on instructables that do similar to what you describe, but unfortunately they seem to either be quite complicated or require expensive parts.
EDIT: There is actually a product currently in the news which would do want you want, but it doesn't appear to be shipping yet: http://www.pwrusb.com/
EDIT (again): Apparently you can do this with some usb hubs. This post sugggests the Linksys USB2HUB4 is one that works.
EDIT (and again): Apparently there are a number of similar questions, but there don't seem to be any more useful answers:
https://stackoverflow.com/questions/405269/custom-usb-device-that-disables-power-to-usb-devices-plugged-into-it
Power off an USB device in software on Windows
Is there software or code to alter USB power output
Can I write a program that swiches USB on/off
Most of the USB to Serial or USB to RS232 $10 converters support hardware handshaking. Use one of those as a single channel digital io.
Connect your transistor that will drive the relay to DTR on the converter board and command DTR ON/OFF with the converters driver.
A 2N7002 is a good transistor to use (FET actually) since it will work from 3V and doesnt need any resistors anywhere.
Here is a complete solution.
It uses an Arduino board, with a USB connection, (and Uno for example) to control the relay and combines this with pfod (Protocol for Operation Discovery) www.pfod.com.au which will let you control the board/relay from either the Arduino IDE SerialMonitor, or a terminal window (TeraTerm) or a Java program. The message protocol encloses commands in { }, think simplified html for micros, and provides numerous screens, menus, sliders, text and numeric inputs, etc. A detailed protocol spec is available
See Garage Door Remote for a detailed example, with full Arduino code and an example of controlling the relay from TeraTerm as well as the Arduino IDE SerialMonitor.
There is also an Android app, pfodApp, which will do general purpose control via bluetooth, or wifi/internet with 128 bit security. The pfodApp does all the Android stuff, you only need to code some simple strings in your Arduino code to get any menu system you want. See www.pfod.com.au for numerous examples.
You need a USB-GPIO microcontroller:
Adafruit FT232H (about $15)
Arduino Nano ATmega328 (about $7)
See this answer
I would suggest placing a separate Raspberry Pi unit with a wake-on-lan feature activated so you can ping it off and on.
You could do it by combining these two products from Pololu, for about $25:
Micro Maestro (assembled)
Basic SPDT Relay Carrier with 5VDC Relay (Assembled)
The Maestro is mainly a servo controller but you can set any of its channels to be simple digital outputs instead. The output can be controlled from the Maestro Control Center software or you can write your own software. A digital output from a Maestro is suitable to turn on the relay on the relay carrier. The relay could be powered from USB through the Maestro; I think it draws about 100 mA of current so that probably will not be a problem for most USB ports, though it would not be USB-compliant because the total current drawn by the Maestro and the relay would be over 100 mA. You could supply your own power source for the relay if you are worried about that.

arm7 usb programming

we are developing a sendor device, with a arm7(current: LPC2368) .
this device samples a mv signal,A/D, and need to send this signal data to the PC.(continusly)
at the same time, PC need send command to arm7 (like get temperature, control status, etc..)
rs232 is too slow, so we choose USB.(20K/s - 200K/s)
but the question is, we donnot known how to do usb programming(both pc and arm..)
any direction? any portal? any tutorial?
currently we only sim the device as a HID....
For the ARM side you need a USB Stack. For the PC side you need to implement an USB driver and an application interfacing the driver. It is therefore easier to stick to one of the common profiles (HID, Mass Storage, Virtual COM). For all these you will be able to find USB stacks and not to have to implenent your own. Also you won't need to implement a USB driver for the PC.
I think that the easiest thing to do is to use a Virtual COM approach. From the PC side it would like you are accessing a Serial Port. The speed however can be higher than standard RS232 ports. I have found this USB Stack targetting an earlier processor. You could adapt it for your needs or use it as reference. Generally a Virtual COM driver for the PC will be provided along with the ARM USB stack.
Another approach is to use libusb. This will allow you to interact with USB without writing a kernel driver.
For application notes and commercial USB stacks look here. If you are determined to write your own stack and driver, Jungo is the industry leader for embedded USB stacks and drivers.