locked
What options do I have for operating multiple DC motors with a Raspberry Pi 3 and Windows IoT? RRS feed

  • Question

  • I'm currently working on a project which involves operating some DC motors. My hope is that I can use Windows 10 IoT on the Raspberry Pi 3, but I'm having trouble finding definitive information on the capabilities of this software online. The motors I'm operating are relatively small -- they run at a maximum of 3A and 12V -- but I have six of them I need to be able to control at once. I'm hoping to find some relatively cheap motor controllers (along with auxillary hardware) that suit my needs.

    My general expectation would be that I would need to find a generic motor controller spec'd to my power needs and then drive it with PWM, however this thinking seems to be hitting lots of snags. First, the PWM capabilities of the Raspberry Pi running Windows 10 don't seem to be obviously documented. I'm guessing that, if I attempt to generate a PWM signal on any generic pin, I'm going to get a software-based (and likely highly imprecise) signal -- not good for driving motors! Almost every resource I find tells me that Windows 10 IoT doesn't support hardware PWM, and even if it did, my understanding is that the RPi's SoC only has two channels available, a far cry from the six I need. I have found one mention (with examples!) of the so-called "Lightning" DMA driver which seems to support the PWM hardware, but if there are only two channels available that won't help me anyway. Is my understanding correct? If so, I believe I will need an external PWM driver if PWM is, in fact, the right way to go.

    Going back to my original assumption that I'll need PWM signals to run a motor controller, I need to understand what I should be looking for in the controller. Are there options other than PWM that may work better (that aren't overly expensive)? Are there any shortcuts I should be taking instead of just searching for generic PWM motor controllers? Are there specific manufacturers/distributors that I should be looking at for use with the Raspberry Pi?

    I have a fair amount of experience with using motor controllers from the software side, but have never actually been the one to pick the hardware; I also haven't spent enough time working with the Raspberry Pi ecosystem to know if there are more specialized options that suit my needs.


    Wasabi Fan

    Wednesday, December 21, 2016 10:08 PM

Answers

  • Hi All,

    Windows 10 IoT Core does support PWM (in fact all versions of Windows have support for the Windows.Devices.* namespace and only require a provider to be implemented - We only implemented a provider for IoT Core and it's supported boards).

    Unfortunately while the RPi boards have some PWM capability, it is somewhat limited. We recommend that people looking to run PWM based motors on a Pi do so using an external motor controller board (like the Adafruit one being discussed).

    As for Lightning, it was designed to give you faster access to GPIO and using this it is possible to simulate PWM via normal everyday digital GPIO pins (I actually did this for a demo earlier in the cycle and found the that RPi2 maxed out with 4 threads bit twiddling to get simulated PWM, based on Karlssja comment though it looks like the perf work the team did has increased that a bit). Again, we'd recommend that you use a dedicated controller board (usually via SPI or I2C busses) rather than trying to run multiple threads simulating the PWM signal on pins especially if you're going to be putting loads on those motors as you'll be limited to the current the pins can provide.

    Thanks,

    Tony Goodhew, Program Manager, Windows IoT Core.

    • Marked as answer by Wasabi Fan Friday, December 30, 2016 3:31 AM
    Monday, December 26, 2016 5:52 PM

All replies

  • I use the adafruit pwm servo board, works really well for me for four motors, but supports a lot more:

    https://shop.pimoroni.com/products/adafruit-16-channel-pwm-servo-hat-for-raspberry-pi-mini-kit?utm_medium=cpc&utm_source=googlepla&variant=1038409565&gclid=CjwKEAiA7ejCBRDlp8uF6ezPnjoSJAAPED7MHj1BwJ729c_pPhkb5LyncJThFGE4oIvcfcOokklMdRoCQcXw_wcB

    I initially tried to use the onboard pwm with lightning drivers, but found they gave an erratic output and so the motors didn't spin properly.

    Adafruit tend to provide good docs, but it is usually assuming you are using python on linux, so needs a bit of translation to work with IoT.

    Thursday, December 22, 2016 6:47 AM
  • Little bit off topic.

    I have built a educational model using windows iot, pi2 and 360 rotary servos as motors using the onboard pwm with lightning drivers. It works very well with 8 servos. The pwm signal is perfect according to my needs and looks ok on my oscilloscope.

    Thursday, December 22, 2016 7:25 AM
  • My problem was when using the PWM with brushless dc motors rather than servos. With the brushless dc motors I was adjusting the speed rapidly. It was only when doing the rapid adjustments that I saw the problem. I guess with servos that is not a problem.
    Thursday, December 22, 2016 8:27 AM
  • Did you see this thread? https://social.msdn.microsoft.com/Forums/en-US/ac27f53d-a953-4a28-b04e-b6249bf31cf1/lightningpwmprovider-and-single-step?forum=WindowsIoT

    Yes, I read through that thread. It doesn't help me much unfortunately, because the discussion there is focused on the dynamics of stepper motors, which are extremely different from standard DC motors. PWM shouldn't be used to control a stepper motor in general.

    I use the adafruit pwm servo board, works really well for me for four motors, but supports a lot more:

    Cool, I'll take a look! Would you say that the native PWM drivers on Win10 IoT aren't worth attempting to use for DC motors (I should just directly buy a controller board)? And does that board that you referenced expose male pins for the standard RPi header, or would I need to solder my connections onto it for things other than PWM? Might the motor controllers that you used be helpful for me?
    I have built a educational model using windows iot, pi2 and 360 rotary servos as motors using the onboard pwm with lightning drivers. It works very well with 8 servos. The pwm signal is perfect according to my needs and looks ok on my oscilloscope.
    Does that mean that you were able to use the Lightning drivers to control 8 pins simultaneously? I'd assume that that means that you are using some unknown combination of hardware and software signals without your knowledge, because as far as I know, there are only two hardware PWM generators. We'd need someone with domain knowledge to confirm that though.

    My problem was when using the PWM with brushless dc motors rather than servos. With the brushless dc motors I was adjusting the speed rapidly. It was only when doing the rapid adjustments that I saw the problem. I guess with servos that is not a problem.

    Yeah, I'd expect that you would change the position of a servo much less frequently than the speed of a DC motor. If the PWM controller is badly-implemented, the waveform may be interrupted every time you set the value.


    Wasabi Fan


    • Edited by Wasabi Fan Friday, December 23, 2016 9:07 PM
    Friday, December 23, 2016 9:06 PM
  • It's been a few months since I tried the lightning PWM drivers, so it may be worth a go with the latest IoT release.

    The Adafruit board comes with headers but they are not soldered on, so some soldering required there. The big female header they provide only has short pins, so you can't attach anything else to those pins (not very well anyway). In my case I actually bought a longer a pin header, so that I could more easily attach things to the pins.

    One thing to note is that I'm not sure if this board can help with brushed DC motors (I can't see any reference to it), I think there are Adafruit DC motor boards if that is what you need. If you are using brushless DC motors then you will also need to buy an ESC (electronic speed controller).

    I can send you the code I use to control the motors for both Lightning PWM and Adafruit PWM. I can't see a way of attaching files on this forum though.

    Saturday, December 24, 2016 7:42 AM
  • Yes

    I have 8 rotary 360 servos connected to 8 pins on the pi2 gpio pins.

    The speed and direction is controlled by lightning drivers using software pwm setting the speed and direction of each motor (servo) individually.

    Monday, December 26, 2016 1:03 PM
  • Hi All,

    Windows 10 IoT Core does support PWM (in fact all versions of Windows have support for the Windows.Devices.* namespace and only require a provider to be implemented - We only implemented a provider for IoT Core and it's supported boards).

    Unfortunately while the RPi boards have some PWM capability, it is somewhat limited. We recommend that people looking to run PWM based motors on a Pi do so using an external motor controller board (like the Adafruit one being discussed).

    As for Lightning, it was designed to give you faster access to GPIO and using this it is possible to simulate PWM via normal everyday digital GPIO pins (I actually did this for a demo earlier in the cycle and found the that RPi2 maxed out with 4 threads bit twiddling to get simulated PWM, based on Karlssja comment though it looks like the perf work the team did has increased that a bit). Again, we'd recommend that you use a dedicated controller board (usually via SPI or I2C busses) rather than trying to run multiple threads simulating the PWM signal on pins especially if you're going to be putting loads on those motors as you'll be limited to the current the pins can provide.

    Thanks,

    Tony Goodhew, Program Manager, Windows IoT Core.

    • Marked as answer by Wasabi Fan Friday, December 30, 2016 3:31 AM
    Monday, December 26, 2016 5:52 PM
  • Thanks for all the info! I've decided to get an Adafruit PWM breakout board and external motor controllers. I don't have the devices yet so can't confirm that it works, but it looks like it should.

    Wasabi Fan

    Friday, December 30, 2016 3:31 AM
  • Thanks for the clarification Tony and thanks for following up and marking the answer Wasabi Fan!  Please let us know how your project progresses!
    Monday, January 2, 2017 11:18 PM