Measuring voltage when using pwm

Can you measure voltage with a standard digital voltmeter when issuing pwm?

Im driving a electromagnet with pwm @80hz using a sine wave. The electromagent is being "driven" forward with one pwm wire then in reverse. This is done to alternate the poles from north to south. Things are working but when I measure the voltage on the h-bridge outputs to the electromagent I'm seeing 6v rather than the source 12v.

Is this because the digital volt meter can't read as fast as 80hz and therefore I'm seeing an average?

I can give more info if needed. I'm just hoping to find out if this is the case or if I've wired something incorrect and have lost that much voltage.

That is the h-bridge I'm using.

Thanks

Is this because the digital volt meter can't read as fast as 80hz and therefore I'm seeing an average?

Yes. If the output really is a sine wave then try measuring the voltage on the AC voltage range of your meter.

Things are working but when I measure the voltage on the h-bridge outputs to the electromagnet I'm seeing 6v rather than the source 12v.

If you start with 12VDC and convert it to AC by some means using transistors then you won't see 12V as AC. AC has peaks and troughs, the maximum possible peak with a 12VDC supply is 12V. For a sine wave the RMS (DC equivalent) voltage is 0.707 of the peak voltage.

With the volt meter set to ac I'm reading 7.8 volts. As I said things are working I was just not sure if I'd done something wrong.

I'm unsure if I understand you correctly Perry but are you saying that 12vdc converted to a sine wave and measured as AC that the most I would read is 8.5v?

If so would a reading of 7.8vac equate to a peak of 11.03vdc ?

Can you measure voltage with a standard digital voltmeter when issuing pwm?

Not accurately. Sometimes you'll get an average, sometimes you'll get the peak, sometimes "random" readings between zero and the peak.

For "regular DC" PWM you can make an RC filter to get the average. If the PWM is "AC" (going positive and negative) the average of an AC waveform is zero (it's positive half the time and negative half the time) so filtering to DC won't work. It can be filtered but the filter has to be more carefully designed.

(The inertia of an analog meter movement will smooth-out the PWM giving you an average.)

I'm unsure if I understand you correctly Perry but are you saying that 12vdc converted to a sine wave and measured as AC that the most I would read is 8.5v?

Only roughly.

What I said is a simplification and misses a few things, but it tells you the maximum you might expect. There are resonable criticisms of what I said and I thought someone might have made them....

Do you understand RMS? That a sine wave has a peak voltage that is higher than its RMS voltage? RMS * square root of 2 (1.414) = peak. If you generate AC from DC then the AC peak can't be higher than the available DC voltage (unless you have a transformer involved). As RMS represents the 'DC equivalent' for a sine wave, and the RMS voltage is 0.707 of the peak, then from 12VDC you are looking at around that as the RMS voltage. This is a starting point as the actual voltage you get depends on the design of the circuitry that does the conversion from DC to AC.

Thanks for the responses.

Perry I wouldn't say I understand it, I'd never heard of it until you mentioned it. I looked it up and I'd say I have a very rough understanding, I get the premise. Not enough so that I could explain it simply to someone lol.

But I've learned something new so thank you :slight_smile:

you could also make an analizer with another board. record the values your sine wave (during small periods but enough to represent graphically)and then print it in excel.

You pretty much need a scope to really understand what's going on with a fast-changing signal.

Perry I wouldn't say I understand it, I'd never heard of it until you mentioned it. I looked it up and I'd say I have a very rough understanding, I get the premise.

I think if you get the premise you are pretty much there. While I don't consider it completely fundamental to electrical circuits knowing about RMS is pretty important if you want to do anything with AC.

Now I have some homework for you if you want it; go back and work out for yourself the maximum AC peak and RMS voltages you can get from a given DC supply. It might help to draw a graph of a sine wave against the DC used to power the converter. Also consider that you can provide 2 outputs in anti-phase, one for each of the 2 output wires.

Something I realised from telling you this is that when I first learned, maybe 40 to 50 years ago, that the ratio between RMS voltage and peak voltage is the square root of 2 seemed obvious to me. Now, while I know it's true, it doesn't seem quite as obvious why that is. My brain is getting old :frowning: !

Hi,
What is the model of the DMM you are using?
Is it a RMS or TRUE RMS DMM?

pwm @80hz using a sine wave

How?
Usually those H-Bridges are logic input, so an analog output is not possible.
What you will be getting is a square AC waveform.

Have you got an oscilloscope?

Thanks.. Tom... :slight_smile:

Hi, sorry for the late response, have had a very busy weekend.

I'll for sure do that homework Perry!

Tom. I'm pretty new to this so I could be wrong about the sine wave. Essentially it's as you say a square pmw at a high frequency to simulate a sine wave.

// Generated by generate_waveform.py

#ifndef H_WAVEFORM
#define H_WAVEFORM

PROGMEM const unsigned char waveform[] = {
	255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 255, 0, 255, 
	0, 255, 255, 0, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 
	255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 
	255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 
	255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 
	255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 
	255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
	255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
	255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
	255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 
	255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 
	255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 
	255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 
	255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 
	255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 0, 255, 0, 
	255, 0, 255, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 
	0, 255, 0, 0, 255, 0, 255, 0, 255, 0, 0, 255, 0, 255, 0, 0, 
	255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 
	0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 0, 255, 0, 0, 0, 
	0, 255, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 255, 0, 
	0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 
	0, 0, 255, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 255, 
	0, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 
	255, 0, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 
	255, 0, 255, 0, 0, 255, 0, 255, 0, 0, 255, 0, 255, 0, 255, 0, 
	255, 0, 255, 0, 0, 255, 
};

const unsigned int PDM_TARGET_FREQUENCY = 40000;
const unsigned int WAVEFORM_SIZE = 502;

#endif

The code is open source code for the slow dance frame. I've built one using the code available from their site.

Everything is working well but I'd be lying if I said I understand the code completely. It took me some time to build the circuit from just reading the source code. For now I'm happy having accomplished that. It's my first Arduino project :slight_smile: