# From PWM Output to Large Motor Control

This question stems from my own curiosity, so forgive any vagueness.

Imagine the following scenario:

We have a MCU which outputs a PWM signal to control a motor's speed and direction. We ultimately want to drive a 5hp motor using a VFD.

What would we normally need to supply to the VFD to drive the motor? How would it know which direction the motor needs to travel in? Does a PWM signal alone provide this information?

Most VFDs (variable frequency drives) designed for industrial applications have a 0 - 10 V speed control input. Your MCU is unlikely to have a 0 - 10 V output but most are capable of 3.3 V or 5 V PWM. By low-pass filtering the PWM signal we can generate a DC voltage to feed to the drive. The maximum voltage we could feed to the drive would be 3.3 V or 5 V with the pulse width at 100%.

simulate this circuit – Schematic created using CircuitLab

Figure 1. Simple PWM filter. Set RC time constant to about 3 to 10 times the pulse width time.

Figure 2. PWM to analog conversion with RC filter. Red = desired speed. Blue = PWM. Green = actual output from filter. Source: Piano with RTOS.

Depending on the VFD this might be adequate if you are able to scale up the maximum frequency. For example:

• Our application requires motor speed adjustable from 0 to 50 Hz.
• Our PWM filtered signal is 5 V at 100% pulse width.
• Set the VFD max motor frequency to 100 Hz.

Now at 5 V in the VFD will run at 50 Hz and all should be well. If this isn't acceptable, for some reason, you would need to amplify your filtered PWM analog signal by 2 (5 V) or 3 (3.3 V) to achieve full 0 - 10 V control.

What would we normally need to supply to the VFD to drive the motor?

A filtered version of the PWM to convert it into a (fairly) steady DC signal level.

How would it know which direction the motor needs to travel in?

Usually a separate direction digital signal. You might find a drive with a -10 to +10 control signal or -5 to +5.

Does a PWM signal alone provide this information?

PWM can only go from 0% to 100% so unless the drive can be programmed to be at 0 Hz at 5 V in so that 0% = full speed reverse and 100% = full speed forward the answer is no.

PWM to bipolar

I've come across many drives that use a -10 to 10 volt control signal. I take it this means <0 is reverse direction and >0 is forward direction?

Correct.

Let's say the MCU outputs both a PWM signal for speed and uses 1 pin to indicate direction (1=forward,0=reverse), how could this be converted to the -/+10v signal we need?

It might be easier to re-scale the one output as discussed below.

simulate this circuit

Figure 3. 0 to 100% PWM to +10 to -10 analog. Note inversion.

The circuit of Figure 3 has an output given by

$$V_{OUT} = - \frac {R_f}{R_i} V_{IN} + (1 + \frac {R_f}{R_i}) V_{REF}$$

where $V_{REF}$ is the reference voltage and $V_{IN}$ is the voltage after R1-C1. With the values shown in the schematic we have $V_{REF}$ = 2 V and $\frac {R_f}{R_i}$ = 4. Our formula simplifies out to

$$V_{OUT} = - 4 V_{IN} + 5 V_{REF} = - 4 V_{IN} + 10$$

Testing for 0%, 50% and 100% PWM we get:

• 0% -> $V_{IN}$ = 0 V -> $V_{OUT}$ = +10 V.
• 50% -> $V_{IN}$ = 2.5 V -> $V_{OUT}$ = 0 V.
• 100% -> $V_{IN}$ = 5 V -> $V_{OUT}$ = -10 V.

Since the circuit is inverting you have several options to obtain the correct direction:

• Add another inverting amplifier with a gain of -1.
• Invert the PWM analog out in the MCU logic.
• Invert the signal in the VFD, if it allows it.
• Swap two phases on the motor three-phase connection.
• Firstly, fantastic answer! I've come across many drives that use a -10 to 10 volt control signal. I take it this means <0 is reverse direction and >0 is forward direction? Let's say the MCU outputs both a PWM signal for speed and uses 1 pin to indicate direction (1=forward,0=reverse), how could this be converted to the -/+10v signal we need?
– M-R
May 22, 2016 at 16:29
• See the update. May 22, 2016 at 18:14
• In reality, would <5v be reverse, as I imagine a voltage can't be negative.
– M-R
May 22, 2016 at 18:28
• I don't understand the question in your comment. May 22, 2016 at 18:33
• As a signal cannot be negative, would the reverse direction be represented by <midpoint? I.e. with +/-10v, reverse would be <5 and forward >5.
– M-R
May 22, 2016 at 18:52

An industrial VFD would need digital signal RUN or RUN & DIR, or RUN(FWD), RUN(BKW) and speed setpoint 0-10V. Or you can have multiple preset speeds digital inputs signal S1, S2, S3,..Another possibility that VFD offer optionaly is communication, typicaly MODBUS RTU. With PWM output of your MCU, you can for example transform into 0-10V signal. You take the 10V reference from VFD and you interface this voltage to optoisolated ouptut generating PWM.

EDIT: Have a look: http://smoothieware.org/spindle-module

• So you wouldn't input a PWM signal to the VFD?
– M-R
May 22, 2016 at 15:57
• @MartinRand post schematics of PWM output and VFD manual. May 22, 2016 at 15:59