Controlling a motor through USB?

Discussion in 'Embedded Systems and Microcontrollers' started by Rallen, Mar 1, 2009.

  1. Rallen

    Thread Starter Member

    Mar 1, 2009
    Hey there.

    I need to build some kind a circuit which makes me able to control a motor through USB. What I need to do, is basically to make a motor run either direction, controlled by some kind of application on a computer.

    What im thinking would be something along the lines of;

    An H-bridge, to make me able to start the motor running either clockwise or counter-clockwise depending on the input I send to it. My plan is then to be able to send inputs to this H-bridge from my USB-interface, and that way make myself able to control the motor from my computer..

    Now im stuck though. How am I going to make the communication between my computer and the H-bridge? Something like a PIC microcontroller controlling the outputs to the h-bridge, and then sending the usb outputs to this controller?

    Any suggestions?
  2. Rallen

    Thread Starter Member

    Mar 1, 2009
    .. A serial interface could also be used, if that is easier :)
  3. leftyretro

    Active Member

    Nov 25, 2008
    An Arduino board would work well. It has a USB serial convertor built in on the board and has lots of software support for PWM signals and lots of I/O pins to control a H drive controller chip. The software to program the Arduino is free and open source and can run with windows, linux or Mac PCs. Programming language used is C or C++.

  4. russ_hensel

    Well-Known Member

    Jan 11, 2009
    Bitwacker from sparkfun is a nice PIC based solution. USB is preprogrammed ready to go, as is enough IO for motor control. Works with free microchip compiler ( or any other 18 series compiler ) which I believe the preloaded software is written in. About $25.
  5. bathini

    New Member

    Jan 25, 2009

    I have a similar problem but in my case, I have built an H-bridge from this site - the last circuit on the bottom and it works when connected to a function generator.

    I have a USB to serial converter and I intend to send 4 bytes to the PIC16F628 using this utility -

    The reason I am using the PIC16F628 is that it has USART hardware and has PWM hardware. I do not know how to write the code in assembly. Please help and thanks

  6. Rallen

    Thread Starter Member

    Mar 1, 2009
    Thanks a lot everyone!

    Theres only one problem though .. As I'm doing it in school, i have to build _EVERYTHING_ myself.. Which means I cant just buy any finished solution..

    So. How could I design a board that makes me able to control a motor through usb or serial, when I have to make every part myself?
  7. Dreso12

    New Member

    May 19, 2013
    You can build a circuit in a prototype board. The problem is that for that you might need a through hole USB controller and that's not easy to find.

    The only one I know is Microchip MCP2210 which you can buy in SOIC package and them use a adapter to convert it to though hole (look in FARNELL for that).

    This chip is a USB to SPI converter so you should be able to control your motor with any SPI enable microcontroller.
  8. kubeek

    AAC Fanatic!

    Sep 20, 2005
    No need for a microcontroller here, that chip already has general purpose I/O pins, so should be enough to control the H-bridge.
  9. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    You can buy little USB->TTL converter modules on ebay for about $3 to $5.

    I'm sure that would qualify as a "component" in the project if you use a PIC or other micro and hbridge to do the rest.

    Likewise you can buy tiny hbridge PCB modules too.

    I think most teachers would agree that making the project from a couple of tiny modules, all joined together with a PIC and your code would still be "building it all yourself".
  10. Vitesse

    New Member

    Feb 10, 2013
    an 18F2550 would work. Little external hardware needed for USB, just a USB connector, 470nf cap (from VUSB -> GND) and a few decoupling caps. As for the H-bridge afraid I'm not much use there.

    There is a pretty good tutorial and a Hitech C for PIC / C# for PC at Used that a few times for projects now and it works well.

    hope this helps
  11. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    One of the software engineers at work has as his signature, "if you want to bake a cake from scratch, first you have to invent a universe."
  12. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    I like that. :)

    It's a bit of overkill compared to the old "first you have to grow the wheat". But taken right to the engineering limit I guess...

    Hang on, don't you have to invent "inventing" first? That's a tricky one. ;)