views:

2608

answers:

12

I am looking for a device that reads wiring voltages via a USB interface and returns the data. How would I go about programming something to interpret this data and what language would I use?

edit: If it helps, this project is to develop a digital tachometre for older engines that don't support a comprehensive ODB2 data port. Therefore, it will read voltages on a DC circuit and have an accurate graphical interface. I have absolutely no idea where to start with all this but am determined to make it work! it's for windows.

+3  A: 

Have a look at libusb. It is available for both Linux and Windows.

kris
+5  A: 

Cheat and use libusb. I did this for a project I've been working on for a while and wrote a C++/wxWidgets app to handle the data.

I've been thinking recently of re-writing the app on the PC in wxPython though as it's much faster for GUI development.

How you want to display / log the data? There are a lot of options available. You can do some pretty cool stuff (easily) with the OpenGL capabilities of wxWidgets whether it's 2D or 3D data representation.

Jon Cage
+1  A: 

Seems to me that if you want to read wiring voltages then you need an A/D converter. Are you making your own A/D converter? If so, you've got some nice firmware programming to do on the device side, more than the host-side driver that you're asking about here. Otherwise you're going to buy an A/D converter, and you should just use the driver that the vendor supplies with it.

Windows programmer
+2  A: 

If you can I would suggest using a library like libusb, as kris and Jon Cage have suggested.

If libusb isn't going to suit your needs and you're developing for Windows you should have a look at the software that Jungo provides. Again, this moves the usb software into user space rather than requiring Windows kernel development. (edit 3: Ilya points out in the comment that Jungo is also available for Linux)

If you must do some kernel development (either Windows or Linux) then C is pretty well the only option you have. Investigate this book by Rubini for linux development. For windows driver development I can recommend this book by Oney. But I'd investigate the libusb option in preference to the driver development in both cases.


Btw. If all you are interested in is being able to measure voltages on a usb device (and writing the code isn't important) there are many products out there that will do that for you. Take a look at some of the offerings from National Instruments. These will deal with the hard work of usb and the data acquisition and give you a nice programming interface to use in your application.


(edit 2) There are also some usb-serial chips (eg. these) that can be interfaced directly to an embedded processor usig only a uart. Typically these come with drivers.

Andrew Edgecombe
Jungo tool is not only for Windows, Linux supported as well
Ilya
Thanks Ilya - updated accordingly
Andrew Edgecombe
+1  A: 

Unless you're bit-banging your own USB driver on the firmware side, your chip will probably come with a driver for the PC. For example, PIC microcontrollers from Microchip come not only with firmware for the PIC, but with a Windows driver. I expect that other USB-enabled chips would also come with their own drivers.

Remember that while you interact with the USB port directly on the firmware side, on the PC side all you actually interact with is the driver for the host controller.

MrZebra
+1  A: 

Since you're still looking for a device that converts voltages into information, I suggest you take a look at devices that implement a USB-HID (Human Interface Device) interface, such as those found here.

They have the benefit of not requiring any device driver development to be made, or drivers to be installed. They are as plug and play as a mouse, keyboard or flash drive. The interface is pretty generic, and most manufacturers also provide the necessary libraries to read the information from the device, be notified when a device is plugged in/out, discover devices, and so on.

In addition, have a look at this article that explains how to use a HID device in C#, for example.

Dave

Dave Van den Eynde
+1  A: 

Your easiest option is probably to buy some kind of off-the-shelf data acquisition device. Lots of companies make that kind of thing, but they're sometimes frighteningly expensive:

  1. National Instruments
  2. Amplicon
  3. LabJack

You could also build your own from a kit, although I can't find any links for you just now.

If you want something more custom you could use an EZ-USB or a PIC. They provide USB drivers (for Windows, at least) that allow you to interact with the device without writing drivers.

With most of these you have a fairly wide choice of programming languages, I've written software to communicate with EZ-USB devices from Visual Basic 6 in the past.

Kevin ORourke
NI has OEM modules which can do this for reasonable cost (<$200). You'll have additional analog channels and digital inputs to play with as well, if you want to expand feature-wise. Check out the USB-6008 OEM.
Nick
+1  A: 

Most microcontrollers have built in ADC, and a ton of these also have a built in usb subsystem. Cypress, PIC, AVR come to mind. Whenever I am doing USB work for my own projects, I use pyusb and wxPython. They make it damn easy to get the job done, although there is quite a harsh initial learning curve.

Shameless self plug aside, I wrote a small python driver with pyusb for a USB-LCD device. You can check out my source code here.

jeremy
+1  A: 

I'm, personally, using Microchip PICs - they have AD/DA converters, USB ports, free drivers and boot loaders - and all this for under $4. After you plug in such a device you're getting one extra COM port - the rest is trivial.

IgorM
+1  A: 

You don't say what platform you're looking at. If you're targeting Windows, USB Revealed is an awesome reference.

plinth
A: 

For hardware, take a look at FTDI products.

If you have hardware and want to access it in Windows, I recently discovered WinUSB. If that's what you need, take a look at this white paper.

pelesl
A: 

In addition to WinUSB, libusb and Jungo, there is another option for programming USB devices from user-mode - User-Mode Driver Framework (UMDF).

Writing a UMDF driver is basically creating an in-process COM component with your favorite tools.

Taneli Waltari