Author Topic: Sinusoidal PWM (O-scope Measurement)  (Read 5188 times)

0 Members and 1 Guest are viewing this topic.

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2250
  • Country: 00
Sinusoidal PWM (O-scope Measurement)
« on: June 14, 2016, 02:17:53 am »
I have a DS1054Z and a sinusoidal pwm signal. Is there a function in the scope that will operate on the signal to display a sine wavy kind of signal, or some way to look at it to ensure I am creating the signal correctly?
 

Offline damn_dirty_ape

  • Contributor
  • Posts: 31
  • Country: us
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #1 on: June 14, 2016, 02:22:12 am »
Do you mean that you want to look at a sin wave on the scope?  or that you want the scope to interpret a PWM signal as a sin wave?
 

Offline TrickyNekro

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: gr
  • Drinking Frappé on the way to Isomnia!
    • Youtube channel, electronics and more ;-)
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #2 on: June 14, 2016, 02:35:09 am »
Definitely depends on the scope and the frequency of the signal (combination thereof).

You need a low pass filter for something like that, is bandwidth limiting an analog function on this scope? Not that it is designed for something like that, but theoretically can work.
But you could go also digital low pass, does the scope support averaging? But like sample averaging, waveform averaging could be tricky with the trigger.


Cheers,
Lefteris
If you are an engineer and you are not tired...
You are doing it wrong!
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #3 on: June 14, 2016, 03:11:29 am »
"Sinusoidal" and "Pulse Width Modulation" are, I should think, mutually exclusive terms. 

PWM:



Sinusoidal:



Perhaps you could provide more details, like the actual circuit you are trying to scope, and maybe even a sketch of what you think the signal _should_ look like on the scope.
The easiest person to fool is yourself. -- Richard Feynman
 

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2250
  • Country: 00
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #4 on: June 14, 2016, 03:20:38 am »
Yes, I don't have the components to build the RC circuit. I was thinking a low pass math filter. Maybe the filter BW is not high enough. The 8-bit PWM signal is around 4Mbps.

Something like this:

http://electronics.stackexchange.com/questions/191742/how-is-a-pwm-signal-converted-to-sine-using-a-transformer

http://interface.khm.de/index.php/lab/interfaces-advanced/arduino-dds-sinewave-generator/
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #5 on: June 14, 2016, 03:49:30 am »
Oh, I think maybe I understand what you are trying to do.
 
Yes, you can try to use the Math>Filter function, Low Pass filter, with a suitable cutoff frequency. The DS1054z low-pass filter display behaviour, and available cutoff frequency, strongly depend on the Horizontal Scale setting of the timebase, so you may need to play around with it for a while to get a suitable display.

As far as amplitude accuracy... well, just change the Horizontal Scale and see what happens to the Math trace.







The easiest person to fool is yourself. -- Richard Feynman
 

Offline damn_dirty_ape

  • Contributor
  • Posts: 31
  • Country: us
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #6 on: June 14, 2016, 03:50:56 am »
Im not sure, but you might still be confusing terms?  what device are you trying to measure?
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #7 on: June 14, 2016, 04:08:54 am »
Are you looking for something like this?
« Last Edit: June 14, 2016, 04:12:13 am by alsetalokin4017 »
The easiest person to fool is yourself. -- Richard Feynman
 

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2250
  • Country: 00
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #8 on: June 14, 2016, 04:18:53 am »
I think something like this, although the sine wave is very coarse, and it may just be a coincidence. The sine wave should be just under 2 kHz (512 µs). I also tried with averaging.

 

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2250
  • Country: 00
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #9 on: June 14, 2016, 04:20:07 am »
Here is averaging
 

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2250
  • Country: 00
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #10 on: June 14, 2016, 04:23:01 am »
The circuit I am measuring is pin 1 (tx @ 4 Mbps) of my arduino pro mini. I just clipped the probe lead to that pin.
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #11 on: June 14, 2016, 04:37:21 am »
You will probably have to make something like the hardware low-pass filter described in the link you posted.

But if you'll post your ProMini code, I can fool around some here and see if I can improve on what you got with your scope.
The easiest person to fool is yourself. -- Richard Feynman
 

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2250
  • Country: 00
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #12 on: June 14, 2016, 05:01:50 am »
I copied it from post #38. You can trigger on the signal with trigger holdoff of just under 512 µs.

http://forum.arduino.cc/index.php?topic=404471.30

 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #13 on: June 14, 2016, 08:06:48 am »
OK.... well, I was able to duplicate your results shown in your scopeshots, but I couldn't find any way to get a nice sine wave at about 1.95 kHz like what I think you want.

I think you are going to have to use a hardware LP filter.

(I used AC coupling on the CH1 to get rid of the large offset required on the Math trace)
« Last Edit: June 14, 2016, 08:11:07 am by alsetalokin4017 »
The easiest person to fool is yourself. -- Richard Feynman
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #14 on: June 14, 2016, 08:40:41 am »
Some of the difficulty may be due to the code, at least in my setup (using a genuine Uno R3). The PWM is not a smoothly varying signal that goes from short to long and back to short in a smooth manner. There are wide variations in pulse-to-pulse timing. Hardware LPF would probably smooth that out but I'm sure it confuses the Rigol's tiny little brain.

(I had to comment out the line

__builtin_avr_delay_cycles (11);  //test spare cycles available

to get the code to compile....   ???   )
The easiest person to fool is yourself. -- Richard Feynman
 

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2250
  • Country: 00
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #15 on: June 14, 2016, 03:27:16 pm »
Yes, the bit pattern first looked suspicious, but I then found that sine array all over the net, so?

I think I will try noodling out my own pattern and see what happens... Anyway, pushing the scope to its limits and learning more about it is fun...

Thanks!
 

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #16 on: June 14, 2016, 05:11:18 pm »
Just probing the PWM through a quite high value series resistor with the probe on X1 should start to show the wave shape.
Different micro, but this fella has done work on the hardware filters and getting the PWM right.
http://www.romanblack.com/onesec/Sine1kHz.htm
.  That took much longer than I thought it would.
 

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2250
  • Country: 00
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #17 on: June 14, 2016, 07:51:35 pm »
Thanks guys. I'll try that sine word out too, and I'll try and scrape up a cap and resistor... :-/O


(I had to comment out the line

__builtin_avr_delay_cycles (11);  //test spare cycles available

to get the code to compile....   ???   )

Maybe you have an older compiler or something with delay.h? I'm using a somewhat old IDE, version 1.06. That function should waste one CPU clock cycle when called with a 1 (62.5 ns delay, like a nop). The line is just there to verify how much CPU time is available to do other things before disrupting the SPI data stream (the chip is pretty busy...).
 

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2250
  • Country: 00
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #18 on: June 15, 2016, 12:56:20 am »
I made a simpler bit pattern; it goes like 00000000, 00000001, 00000011, ...11111111, and back to zero. That's not a sine wave!
 

Offline TrickyNekro

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: gr
  • Drinking Frappé on the way to Isomnia!
    • Youtube channel, electronics and more ;-)
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #19 on: June 15, 2016, 11:56:37 pm »
I made a simpler bit pattern; it goes like 00000000, 00000001, 00000011, ...11111111, and back to zero. That's not a sine wave!
It´s an overkill to try calculate a sin in an arduino, the best way (mostly in simplicity) is to use a sin table. You will be able to find some on the internet.

The sin you try to represent have to be at least half the modulation / PWM frequency. That´s Nyquist theorem look it up.
That´s mostly the theoretical absolute limit, in real life the frequency of the PWM should be around 10 times higher
than the sin you try to represent. The cutoff frequency of the low pass filter should be around the middle for best results.
The filter you are trying to do with your oscilloscope is a digital moving average filter, look it up on how you are going to set it, I do not own the Rigol to actively help you.

I hope I could point you to the right directions,
Cheers,
Lefteris
« Last Edit: June 16, 2016, 09:04:55 am by TrickyNekro »
If you are an engineer and you are not tired...
You are doing it wrong!
 

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2250
  • Country: 00
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #20 on: June 16, 2016, 01:06:58 am »
Hello Lefteris,

I have not looked up your tips, but I would like to play from what I think. If I am wrong, I can still look.  :)

Here is what I think:

PWM period is 2 µs period (500 kHz) and approximated sine wave is 32 µs period (31.250 kHz). The Rigol is set to 256 averages (I think that was the number) and I think all these scopes only provide a moving average. That is, the average of the most recent "n" number of samples. The LP filter cutoff is 50 kHz - a little lower than middle, but seemed to provide a good result.

I think these parameters match, but I should review again (the details/proof of) Nyquist, as the years have passed...

Thanks for the tips!
« Last Edit: June 16, 2016, 01:12:09 am by metrologist »
 

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: Sinusoidal PWM (O-scope Measurement)
« Reply #21 on: June 17, 2016, 01:03:11 pm »
I think you're going to struggle to apply any Nyquist limit theory to a PWM signal.
.  That took much longer than I thought it would.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf