• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

I want to learn USB programming / electronics

Red Squirrel

No Lifer
I've always wanted to make a USB device, like a box with a bunch of relays or something, and actually write a driver for it. One thing I have in mind is a computer controlled programmable thermostat. Basically a couple 24V relays that can be controlled via a service running on a linux box and a temp sensor.

What does it take to make something like this? Obviously I need to learn how to program PLCs and electronics in general, as well as how to communicate programmaticly to a USB device. Could someone point me in the right direction? Seems kinda far fetched but I feel like learning something new. Probably wont get to it now due to lack of funds but something I'd like to at least read up on.
 
You'll need to familiarize yourself with the in/out assembly instructions, what they do and how they work. You'll also need to know how the USB controller transmits the data before you can start working with it.

After that, you need to get a good idea on privileged levels, and what they mean to making a driver. Finally, you'll need something along the lines of the Windows Driver development kit (as far as I can tell, it isn't free to download for vista).

Soon, I'll be working with the USB controller, so I'll let you know what I eventually use to get the job done.
 
I'd be doing this in Linux so what would be the equivalent of the windows kit? And yeah I'd be interested to hear progress and see what you did. I'm just thinking, once I know the basics the possibilities are endless.
 
I'd be doing this in Linux so what would be the equivalent of the windows kit? And yeah I'd be interested to hear progress and see what you did. I'm just thinking, once I know the basics the possibilities are endless.
I really don't think that there is a linux kit. You have access to the kernel source and source files for the drivers. You might be able to find a tutorial on writing drivers for linux.
 
Don't. USB is a pain in the ass.

Just get a USB <> RS-232 dongle and be done with it; It doesn't look like you need bandwidth anyways...
PC side is cake. Other side may or may not be a problem for you, you'll need to learn how to use a microcontroller. I'm kind of partial to the atmel micros, but there's quite a few families out there...


Now, if you just want some temp sensors and relays;
build one of these: http://www.harbaum.org/till/i2c_tiny_usb/index.shtml
(gives you another IIC bus)
slap on a couple I2C temp senders (LM75 or so); and some of the philips I/O expander chips (like a 8bit latch that sits on the I2C bus), hang some relays off it, and then you can control it all from PC.
You just open the I2C bus as a file (kernel driver is built in since 2.6.x); and use the i2c commands on it.
Still gonna have to read datasheets though.

Philips also makes some RS-232 <> I2C chips, you just send them a string on the serial port and it translates it to the I2C side, cake... You can use them instead of the i2c-tiny-usb linked above.
 
Depends on how much you want to spend and how much stuff you already have.
Easiest way is as mentioned , get a board with a onboard serial to USB converter usually based on the ftdi chipset. All OS have drivers for it and you can communicate via terminal apps.

I recommend ardruino if you are just getting started. It can more than do what you wanted. The software is free and plenty of examples exist. No programmer is required. Just buy the board, plug in a usb cable and run the software and start coding your program.

$30 to get started
http://www.adafruit.com/index.php?main_page=product_info&cPath=17&products_id=50

I used a stripped down version of the above board to code an IR receiver and transmitter for my HTPC. I can now cut it on/off via remote, reset the pc or send it commands for menus, etc. And it works with any remote I own, not just a preset remote like you get in kits or receivers that force you to use their remote. And I still have over 2/3 of the memory left on the device for other things. So it is very capable.

The biggest issue with usb is you need a unique device id and those are not just given away. There is a long registration process to get a device id. Then you have the issue of OS like x64 ones that will not let you use unsigned drivers.

That is why I went with Rs-232 > USB . It works without me having to install custom drivers on my target computers.
 
Get a 32-bit Microchip PIC dev/eval kit that has support for USB/LCD/LED. You'll learn the fastest with that because all source code is provided.

Writing drivers for USB on the embedded side is easy once you understand and implement the enumeration stage and setup the interrupts for the endpoints.

Writing custom device drivers for the PC side, however, is a whole new ballgame.
 
Ok, so for the USB development, we are using USB development boards. We aren't really writing the drivers for them, just learning how to use them.
 
Thanks for all the tips, I'll do some reading up and see if it's really something I want to get into. No cash to buy components needed now though.
 
Ok, so for the USB development, we are using USB development boards. We aren't really writing the drivers for them, just learning how to use them.

yep. USB is a pita... just start off with simple serial communication. the arduino board is neat and simple too. its ide is basically C with a bunch of wrapper functions.

you could check out this kit too:

http://makezine.com/controller/

both the arduino and the make controller use atmel chips. PIC is another big player in embedded chips... so you could pick up one of their 32 bit kits somewhere and start playing with it. atmel runs an open source program while pic doesnt...
 
yep. USB is a pita... just start off with simple serial communication. the arduino board is neat and simple too. its ide is basically C with a bunch of wrapper functions.

you could check out this kit too:

http://makezine.com/controller/

both the arduino and the make controller use atmel chips. PIC is another big player in embedded chips... so you could pick up one of their 32 bit kits somewhere and start playing with it. atmel runs an open source program while pic doesnt...


I have done the pic route too, ardruino is pretty new for me. Really only got the board because someone had done a library for decoding RC6 remotes. Philips is being a corporate jerk with the specs on the protocol.

If someone wants to go with the pic though, here is all you need.

18f4550 chip - microchip will send you 2 for free if you request samples on their site. They limit you to 4 chips total for most hobby users.
Then :
1- crystal per chip -20 mhz
2 - 20 pf capacitors per chip
1 - 47uf +16V cap per chip
usb cable with the end cut off. Red - +5v, Black - ground, green - d+ white d-

The 18f4550 has pins that connect directly to the usb port and can also be powered off the same port. Put it on a breadboard , connect the crystal and cable and it is ready to use once programmed.

Microchip has the usb source code and driver in their software mplab.

I would install a bootloader onto the chip, it is basically a program you flash once onto the chip and then each time it powers on it waits about 3 seconds for you to send program data to reprogram it. If you don't send the command it goes on to whatever program you installed.

I use tiny bootloader. Very small and supports lots of chips.
http://www.etc.ugal.ro/cchiculita/software/picbootloader.htm


You need a programmer for that.
If you want to make a programmer this works well.
http://www.ppl-pilot.com/programmer.htm

Once the bootloader is installed to the chip you never have to put it back in the programmer.
 
Back
Top