PWM via USB?

Discussion in 'The Projects Forum' started by wayneh, Jan 18, 2011.

  1. wayneh

    Thread Starter Expert

    Sep 9, 2010
    12,115
    3,039
    Is there a way to use a computer's USB port as a PWM controller? I think I know how an analog audio port might be used; I could use a tone generator to send a variable duty cycle square wave at, say, 5kHz to a comparator driving a MOSFET. Power would have to come from a wall wart or the USB port. But I'm thinking the 5v power of the USB port could drive a logic MOSFET directly, and thereby give a nice simple PWM controller for cheap.

    Now, I already have a LabJack which is a USB powered data acquisition device. It's perfectly capable of performing the PWM function. But it's ~$115, and I'm wondering if there is a solution that might be <$5. I think it's "just" a software problem, but maybe someone here knows more about USB?
     
  2. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    The Labjack is cool, a cheaper solution would be either a PIC (the 18F2550) or an Arduino as both support USB & PWM. I'm biased but I'd go with the PIC and something like JAL2 to program it. Not sure but the UBW might support PWM and that would be a good fit if it did.
     
  3. wayneh

    Thread Starter Expert

    Sep 9, 2010
    12,115
    3,039
    I see that PIC is cheap enough, but I have zero experience with such things. What would it take to get a working PWM solution using computer+USB+PIC 18F2550? What are the software options?
     
  4. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    The hard part would be the USB stack, it's not for beginners. The PWM part is dirt easy as it's done at the hardware level so it's set a few registers and it runs.

    The Arduino uses an FT232R which is a USB to serial converter so you don't have to write USB code.

    It may even be possible to bit bang the PWM with an FTDI chip.
    http://hackaday.com/2009/09/22/introduction-to-ftdi-bitbang-mode/
     
  5. wayneh

    Thread Starter Expert

    Sep 9, 2010
    12,115
    3,039
    Interesting link. I think that approach could definitely work, but for me personally there would be a considerable learning curve since I'm not a programmer.

    I think what I'm hearing is that there is no really simple and direct approach that doesn't involve another piece of hardware in between the USB and the device under PWM control. The hardware options range from $5 (IC only) to $115 (full overkill), and they all require some programming. The only option I can currently program with confidence is the LabJack, which I can control with ease in Excel using Visual Basic.
     
Loading...