Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Microcontroller-->USB-->PC

Status
Not open for further replies.
I would like some recommendations for textbooks/books to help me get from the point of knowing nothing about creating windows drivers/applications to interacting with the real world from a PC. As a junior level EE student I am starting to realize that I will not learn everything that I want to know with the required courses for my degree. I have had programming classes (C & Java) but it seems the information that I want from these classes seems to be saved for the IT degrees.

What I would like to do is create my own piece of hardware that will communicate with the PC through USB to a program of my own design (in Java) to manipulate, display and save the data.

From what I understand I will have to create a communication protocol between my program and the hardware (I can handle that, I think), but from my limited understanding I will have to create a driver for windows so that my program can communicate with my hardware (i have no idea how to go about this... yet).

I would like to use my own programs throughout so that I will get the understanding of the subject from start to finish. I know there are already programs out there that do this (like labview) but I would like to do it myself. I'm also not asking anyone to do it for me, but if you are knowledgeable in this area your input would be greatly appreciated.

This is not homework, lab or anything, except, something that I personally am interested to know and use.
 
If you check the MicroChip website there are a number of USB application notes, some of these give software for the PC side as well, and advice on writing them.
 
i am no expert but i did have a couple of unsucessful goes of making a USB device, in the end i gave up as my need for the device wasnt that great.
BUT the good news is it isnt that hard.....or to qualify that a bit. Microchip have a USB stack for some of there chips this is designed/based on standard windows USB drivers such as HID. googlw for pic usb projects and have a look on pyroelectro there is a couple of projects on there.
HOWEVER if you wish to design/build a host device or indeed write your own stack then.........good luck and best wishes ;) as for writeing a application for talking to say a pic via usb that seems to be pretty easy if you use standard already availiable drivers, be careful tho if you go down the path of making a device to sell as you need to spend alot on a unique ID for the device.
 
The applications are for my personal projects that I would like to interface with my PC. I don't intend to sell for profit. I don't want to be pinned down to a specific brand of chip is why I would like to do it myself and honestly I know nothing about device drivers, just what little I have researched so far and if it costs money to create a driver for a one off project then I will also be dead in the water. Nigel, I will give the app notes a look, thanks.
 
If it's for general hobby use etc just use a USB->UART module (about $4 on ebay) so your hardware only needs to have a standard logic level UART, like on most PICs.

That plugs in the PC USB port and acts like a "comm port" and there are a ton of free windows applications that will record the data to a file on the PC hard drive for you.
 
Hi,

Re the USB-serial converters, the following transfer rates are supported (just off the top of my head):
FTDI:
* FT232 (full speed): 1M baud (100 kB/s)
* FT232H (high speed): 12M baud (1.2 MB/s)

SiLabs:
* CP2102: 1M baud (100 kB/s)

Prolific:
* PL2303: 3M baud (300 kB/s)

The FT232H devices is capable of asynchronous parallel read/write at datarates of up to 8 MB/s and a synchronous parallel mode up to 40 MB/s. So 'speed' shouldn't be an issue here.

The FT devices come with a driver and direct interface DLL, though you can change the VID/PID and the device name displayed by adding an EEPROM. If you change the VID/PID, you'll need to organise a new driver -- you can just use the generic libusb driver and just modify an INF file.

You should be able to use the libusb driver for any USB device though, even one that you create from scratch. Otherwise writing your own driver may be difficult, and you may have trouble finding sufficient information or support.

Microchip does have a bunch of App notes, drivers and code (as stated above) if you didn't want to use an interface IC.

So, in summary, the driver can be:
* painstakingly written by you from scratch,
* provided by the interface IC or uC manufacturer,
* the generic one provided with libusb...

Regarding VID/PID, you can get one for free from FTDI or from Microchip, for use with their chips. You don't need one if you're using the manufacturer's though.
 
Last edited:
Thanks for the reply dougy83. I have done a lot of researching today and have come to the conclusion that I do not want to create my own driver! I originally thought that the only way to do this would be for me to create my own driver with my application but I have found the Win32 API and will most likely implement the Communication Resources in my application. I actually have a FT245R ordered, which is 1M baud to use in my project. If everything goes according to plan (I can actually get this thing to work) I may upgrade to a faster USB chip later. I have come to a little better understanding of what it will take to use the chips included driver but I still have a lot to learn about the setup and using the driver in my application to get the information flowing.
 
Thanks for the reply dougy83. I have done a lot of researching today and have come to the conclusion that I do not want to create my own driver! I originally thought that the only way to do this would be for me to create my own driver with my application but I have found the Win32 API and will most likely implement the Communication Resources in my application. I actually have a FT245R ordered, which is 1M baud to use in my project. If everything goes according to plan (I can actually get this thing to work) I may upgrade to a faster USB chip later. I have come to a little better understanding of what it will take to use the chips included driver but I still have a lot to learn about the setup and using the driver in my application to get the information flowing.

Just bear in mind the FT245R is a parallel transfer device and will require 12 IO pins. The serial devices (e.g. FT232) only requires 2 pins (up to 4 if using HW handshaking). The parallel device does have the advantage of 10x the speed though.

It shouldn't take much to get the software up and running - install the supplied driver, use the supplied DLL (D2XX.dll or something) and you can access the device from C/C++/C# or from a bunch of other languages. Just open the device, set the desired mode (async FIFO I assume), then read and write to it. I think the reads and writes might be blocking, so keep that in mind.
 
dougy83 as far a pins are concerned, I can sacrifice a few to the machine cycle gods to keep the uC from being tied up.
Just open the device, set the desired mode (async FIFO I assume), then read and write to it. I think the reads and writes might be blocking, so keep that in mind.
This is part that I will need to work on until I get my parts.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top