• I wrote a program in order to use Pulse Width Modulation to simulate a sinusoidal signal.

  • Added a low pass filter to get rid of the noise and the traces of it being a discrete signal.

  • Added a half wave rectifier in order to delete the negative part of the signal, however it only deleted 20% of it instead of the intended 50%.


  1. Why is this happening, how do I get rid of the other 30%? Does it have something to do with the high frequency of the PWM?

  2. What could I do to increase the output AC voltage from 3V to 10V or 100V? (I do know voltage multipliers) but I'm looking for another way.

  3. Can this be used to power up circuits without damaging them?

  4. How can I add 10A of current to my final AC output?

enter image description here

enter image description here

  • \$\begingroup\$ Why do you go to the 'trouble' of generating a complete sine wave with your arduino's pwm, only to try to chop half of it off with a diode externally? Wouldn't it be easier if you only generate the half-sine wave you want? \$\endgroup\$ – brhans Oct 6 '14 at 2:35
  • \$\begingroup\$ i just went with the flow, but yes you are right seems easier to just generate the positive side of the sine wave \$\endgroup\$ – GoatZero Oct 6 '14 at 16:01

To answer all your questions:

  1. See the explanation by @JonRB, in short saying: You are making a wave going from 0V to 3V with the arduino, because the arduino does not possess a negative rail to work with. So you need to make the signal relative to a ground, in stead of its current DC offset of about 1.5V

How do you do that?

You can do two things:

  1. A: You can generate a virtual ground, at about 1.5V and relate all your measurements to that and have your diode conduct into a resistor connected to that virtual ground to make it act as a rectifier. Note, however that you'll still lose about 0.7V off the signal, because that's the voltage the diode drops, or "needs to work".
  2. B: You can decouple the DC away from the signal with a capacitor:


simulate this circuit – Schematic created using CircuitLab

The resistor is there to pull the capacitor on the other side to a DC level of ground. The capacitor doesn't allow DC voltages to impose anything on the other side, but to a moving signal it becomes a frequency-dependant impedance. Note, that this will dampen lower frequencies, because the impedance of the capacitor is higher at lower frequencies. The larger your capacitor is the better lesser it will inhibit lower frequencies, so if you can get 10uF or 47uF. If you want 50Hz to be the lower limit (for audible for example) the drawn values will easily suffice.

  1. You need an amplifier for that. For such large increases you should look into audio amplifiers or power amplifier design manuals. But I'd advice the latter only if you have a very firm grasp of signals, frequencies, transistors, op-amps, capacitors and inductors. Alternatively you could increase the voltage you are switching with your PWM stage. For this you need an external power source at the voltage you want your peak-peak swing to be and a decent transistor half-bridge (BJT, MOST or IGBT) rated at the working voltage and currents.

  2. That depends on the circuits you want to power and what for. I'm getting the impression that you want to build some sort of Power Frequency Driver/Chopper. I am not going to re-itterate a full how-to on building those, but you should really consider googling those if you want to not do something very dangerous (in terms of damage or health). Also note this is a difficult and long road compared to hooking up an Arduino to a set of filters.

  3. See point 2: Amplification before or after AC filtering.

  • \$\begingroup\$ my original idea was to control several microstep motors using this since i want it to have a consistent flow that a normal stepper motor cannot do however even if i can arrange the signal as i need it to do this, i might end up having problems with the current that i need to deliver to the loads, thanks for your answer thats a bunch of info i have to land \$\endgroup\$ – GoatZero Oct 6 '14 at 16:05
  • \$\begingroup\$ @GZeromostro You can do that simply by using a fast enough half H-bridge driver at, for example 12V, and control that with your PWM signal, then filter and you get a 10Vp-p to 12Vp-p signal, but you'd also need to consider the motor's inductance and resistance in your filtering. What you should not forget to do is check whether a MicroStepper Driver, from for example Allegro, isn't more cost effective in the end. \$\endgroup\$ – Asmyldof Oct 6 '14 at 16:15

Here is what I would recommend: instead of generating a full sine wave and then rectify it with a diode, generate the rectified sinewave in software directly. Then instead of generating the signal directly with the I/O pin of the microcontroller, drive a pair of power MOSFET transistors to get the current you need. Adding one aditional drive MOSFET with a pull-up resistor should enable the use of higher voltages. Basically, build a CMOS inverter with an N channel and P channel MOSFET, and drive the input of that with an N chanel MOSFET with a pullup resistor on the output. Then follow that up with your LC filter. Just make sure to get inductors that are beefy enough for the current.


From part of the query you are implying the resultant AC signal is 3V correct?

What you are creating is a 3V pk-pk sine wave that is sitting on a 1.5V signal which lines up with the I/O of an arduino being 3v3 voltage so 100% duty (say the peak) can only be 3.3V and 0% duty (say the trough) can only be 0V

With a forward voltage drop of 0.7V on the diode the 1.5V peak signals is reduced to 0.8V which is equivalent to a 30% reduction

if your aim is to create a half wave rectified signal you need to either AC couple the output to allow the signal to swing negative OR provide an additional reference

  • \$\begingroup\$ i did not understood the AC coupling part nor the additional reference \$\endgroup\$ – GoatZero Oct 5 '14 at 21:16
  • \$\begingroup\$ You are creating an DC sine wave. Your arduino makes a wave going between 0V and 3.3V at most, AC means it goes between a positive and negative voltage, so that the current can alternate in direction, or "Alternating Current". Your diode works to the reference of your 0V, because that is where the pull-down resistor on its cathode goes, so it can conduct the upper 70% of your signal. If you want it to only conduct the upper 50%, you need to reference the diode's output to a voltage that equals that. Or remove the DC offset from your signal to make it truly AC, with AC coupling. \$\endgroup\$ – Asmyldof Oct 5 '14 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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