What I want to achieve

To control the speed of an AC motor with DC voltage programmatically with Raspberry Pi.

I asked on Raspberry Pi.SE and was told it was an EE question, so I'm asking here.


  • Windows 10
  • Raspberry Pi 2 model B
  • AC 100 V, 50 Hz, single-phase (Japan)


I'm trying to control the speed of an AC motor from the Raspberry Pi for my project. At first I used PWM and a solid state relay, but I realized this only changes the intensity of the rotational power not the speed.

So I'm thinking about another strategy. Here it is.

  1. Convert AC to DC using a full wave rectifier circuit. I know I'll need big capacitors.

enter image description here

  1. Create a pseudo-AC signal with PWM and use it to operate the AC motor. I think if I change the duty-cycle higher when the electric wave is tall, it'll work.


I googled "raspberry pi dc current pwm ac motor" and got the following pages which didn't help me much.

https://forums.raspberrypi.com/viewtopic.php?t=134100 https://forums.raspberrypi.com/viewtopic.php?t=203350 https://forums.raspberrypi.com/viewtopic.php?t=64412

Thank you in advance!

Update 2022-11-21

The AC motor is assembled into a massager.

enter image description here
I checked the manual of the product but I couldn't find any information about what type of an AC motor it uses.

As it's a massager, there was a load on the motor. The SSR was SSR-60-DA.

The original post on RPi.SE was deleted.

  • 4
    \$\begingroup\$ There are a lot of different things called "AC motors" out there. They all have wires going in and a turning shaft coming out -- but the insides of one can be completely different from the insides of another. Can you please show a picture of your motor, or its nameplate, or a catalog listing of the motor you intend to use? \$\endgroup\$
    – TimWescott
    Nov 20, 2022 at 15:54
  • 1
    \$\begingroup\$ The really right answer here is to use a different motor, and a controller. You probably want to use a VFD, and a motor that's matched to it. \$\endgroup\$
    – TimWescott
    Nov 20, 2022 at 15:57
  • 1
    \$\begingroup\$ In addition, you may not be able to control its speed very much so how much control do you want and, have you thought about using a variable frequency motor drive? \$\endgroup\$
    – Andy aka
    Nov 20, 2022 at 15:58
  • \$\begingroup\$ When you tried the solid state relay, was there a load on the motor? Also which ssr? Some will enforce switching at the zero crossings and may not behave as you had hoped. \$\endgroup\$
    – Bryan
    Nov 20, 2022 at 17:04
  • \$\begingroup\$ It sounds like what you want is an electronic speed controller. If it is an induction motor, you may want a variable frequency drive (VFD). These are also often called inverters. It might be a bit much to design your own VFD. But searching on that term may reveal some ideas for you. \$\endgroup\$
    – user57037
    Nov 20, 2022 at 17:24

2 Answers 2


You won't like to hear this, but what you are trying to achieve, the way you are approaching it, though possible, is complicated and expensive.

You will need a Variable Frequency Drive, which is an inverter for AC motors. It converts 50/60 Hz line frequency to a variable frequency to change the motor speed. Generally, VFDs are for 3-phase motors: single phase motors are rare.

You may also need a motor that is designed to handle a VFD drive.

Therefore, forget all that: it's beyond a hobbyist's reach.


  1. Set the AC motor aside
  2. Get a power supply to power a low voltage DC motor
  3. Get a DC motor or a stepper motor instead
  4. Get a driver for that motor: "DC motor controller" / ESC for a DC motor, or a "Stepper motor driver"
  5. Connect that motor driver to your Raspberry Pi
  • 2
    \$\begingroup\$ I disagree with the assessment that it's beyond a hobbyist's reach--the common "brushless DC" motors are in fact permanent magnet synchronous motors connected to a VFD (which hobbyists like to call an ESC for some reason). \$\endgroup\$
    – Hearth
    Nov 20, 2022 at 17:03
  • 2
    \$\begingroup\$ @hearth, the VFDs used in industry are MOSTLY for induction motors (though they can drive servomotors and PMSMs with various levels of sophistication). The DC bus usually runs from rectified line voltage. The ESCs are mostly for so-called BLDC motors (PMSMs), and usually run the DC bus with battery power at a voltage lower than rectified line voltage. I realize the distinction is not hard and fast, but I do feel that hobbyist VFDs and industrial VFDs are different beasts with different purposes. \$\endgroup\$
    – user57037
    Nov 20, 2022 at 17:33
  • 1
    \$\begingroup\$ @mkeith They are different things, but I would consider them both types of VFD. I guess that is a reason to have different names for them, though. \$\endgroup\$
    – Hearth
    Nov 20, 2022 at 17:34
  • \$\begingroup\$ @Hearth I disagree with the assessment t --- I think you misread what I wrote: I said that an industrial VFD is beyond the reach, not a brushless DC motors. You and I are actually in full agreement: OP should consider a DC motor (or a stepper motor) instead of an AC motor. \$\endgroup\$ Nov 20, 2022 at 21:26
  • \$\begingroup\$ @DavideAndrea I did not downvote. I also don't see anything specifying an industrial VFD, though; as I explained above, I would consider an ESC to be a type of VFD. \$\endgroup\$
    – Hearth
    Nov 20, 2022 at 21:29

As others have said, you will probably need to use a variable frequency drive if the motor is an induction or synchronous type, and especially if it is three phase. That could be confirmed if there are three wires going to the motor (unless a controller is built into the device). It's also possible that it is a universal motor (series wound AC/DC), in which case a variable amplitude DC or AC could be used.

If it is actually an AC induction motor, it could be powered by a simple 3 phase H-bridge and a "modified sine wave" (rectangular or trapezoidal), which can be supplied using GPIO signals from the Raspberry Pi. Sine wave PWM would be best, but it is a lot more complicated.

A more definitive answer would require more information about the motor and any existing external or internal controller. In the absence of actual specifications and schematic, this will only be possible by opening the device and examining what's inside.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.