Sinusoidal PWM (O-scope Measurement) - Page 1
Forum section: electronics / beginners

author: metrologist
author_rank: Super Contributor
timestamp: June 14, 2016, 02:17:53 am
content: 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?

author: damn_dirty_ape
author_rank: Contributor
timestamp: June 14, 2016, 02:22:12 am
content: 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?

author: TrickyNekro
author_rank: Frequent Contributor
timestamp: June 14, 2016, 02:35:09 am
content: 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

author: alsetalokin4017
author_rank: Super Contributor
timestamp: June 14, 2016, 03:11:29 am
content: "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.

author: metrologist
author_rank: Super Contributor
timestamp: June 14, 2016, 03:20:38 am
content: 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-transformerhttp://interface.khm.de/index.php/lab/interfaces-advanced/arduino-dds-sinewave-generator/

author: alsetalokin4017
author_rank: Super Contributor
timestamp: June 14, 2016, 03:49:30 am
content: 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.

author: damn_dirty_ape
author_rank: Contributor
timestamp: June 14, 2016, 03:50:56 am
content: Im not sure, but you might still be confusing terms? what device are you trying to measure?

author: alsetalokin4017
author_rank: Super Contributor
timestamp: June 14, 2016, 04:08:54 am
content: Are you looking for something like this?

author: metrologist
author_rank: Super Contributor
timestamp: June 14, 2016, 04:18:53 am
content: 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.

author: metrologist
author_rank: Super Contributor
timestamp: June 14, 2016, 04:20:07 am
content: Here is averaging

author: metrologist
author_rank: Super Contributor
timestamp: June 14, 2016, 04:23:01 am
content: 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.

author: alsetalokin4017
author_rank: Super Contributor
timestamp: June 14, 2016, 04:37:21 am
content: 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.

author: metrologist
author_rank: Super Contributor
timestamp: June 14, 2016, 05:01:50 am
content: 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

author: alsetalokin4017
author_rank: Super Contributor
timestamp: June 14, 2016, 08:06:48 am
content: 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)

author: alsetalokin4017
author_rank: Super Contributor
timestamp: June 14, 2016, 08:40:41 am
content: 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 availableto get the code to compile....)

author: metrologist
author_rank: Super Contributor
timestamp: June 14, 2016, 03:27:16 pm
content: 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!

author: StillTrying
author_rank: Super Contributor
timestamp: June 14, 2016, 05:11:18 pm
content: 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

author: metrologist
author_rank: Super Contributor
timestamp: June 14, 2016, 07:51:35 pm
content: Thanks guys. I'll try that sine word out too, and I'll try and scrape up a cap and resistor...Quote from: alsetalokin4017 on June 14, 2016, 08:40:41 amMaybe 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...).

author: metrologist
author_rank: Super Contributor
timestamp: June 15, 2016, 12:56:20 am
content: I made a simpler bit pattern; it goes like 00000000, 00000001, 00000011, ...11111111, and back to zero. That's not a sine wave!

author: TrickyNekro
author_rank: Frequent Contributor
timestamp: June 15, 2016, 11:56:37 pm
content: Quote from: metrologist on June 15, 2016, 12:56:20 amIt´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 higherthan 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

author: metrologist
author_rank: Super Contributor
timestamp: June 16, 2016, 01:06:58 am
content: 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!

author: StillTrying
author_rank: Super Contributor
timestamp: June 17, 2016, 01:03:11 pm
content: I think you're going to struggle to apply any Nyquist limit theory to a PWM signal.