Going Beyond Arduino # 10: PWM D-to-A vs R2R Ladder D-to-A

  Рет қаралды 20,120

Craig Hollinger

Craig Hollinger

Күн бұрын

Пікірлер: 41
@truthseeker6649
@truthseeker6649 6 жыл бұрын
i can imagine that R2R will be much smoother than PWM after filtering. nice video !
@flywittzbeats4008
@flywittzbeats4008 Жыл бұрын
Thank you so much for this! Now I dont have to build both versions to see or hear what they're like. Excellent explanation
@craighollinger9972
@craighollinger9972 Жыл бұрын
Thanks for watching!
@unregistereduser2
@unregistereduser2 3 жыл бұрын
Neat channel, some great stuff here. I'd suggest trying a higher order filter on your pwm. A 2 or 4 pole sallen key filter should allow you to increase your cutoff point, and still get good attenuation of your pwm carrier, and get some buffering too. R2r might benefit from a similar filter near your sampling frequency
@slawomirpiernikowski6150
@slawomirpiernikowski6150 6 жыл бұрын
Great job Craig. Keep going. Looking forward for more such proffesional series.
@bbreeuwer4577
@bbreeuwer4577 7 жыл бұрын
Clear story! One thing though. You can make the output with PWM much better to use an higher slope filter. 2nd order works nicely, but you could go for 3rd or 4th order. Raising the samplerate frequency also helps,about a factor 10-20. It might be interesting to use a differential PWM output to even bring down the noise more (and you actually get an higher output amplitude). Differential means that you use two outputs with one that is inverted. This is also what you typically see in Class-D power amplifiers. With a standard Arduino, I typically use 31kHz or 62kHz samplerate with a 2nd order (Butterworth) filter. Only costs an extra little opamp and a few passive components. For DC applications that works great as well, for AC signals you can get a decent bandwith up to roughly 8-10kHz.
@craighollinger9972
@craighollinger9972 7 жыл бұрын
Yes, higher order filters with steeper cut-off skirts would be an improvement as would a higher PWM frequency. If a frequency generator is wanted, a microcontroller is not the best way to do it. There are lots of dedicated D/A chips available that do a much better job. Analog Devices has a quite a number of different chips, and depending on the frequency range, they can be reasonably priced. Thanks for watching.
@noviy_polsovatel
@noviy_polsovatel 5 жыл бұрын
The best solution is to use r-2r ladder + Lowpass filter to eliminate steps. It is much easier to smooth small ladder steps, then to smooth full amplitude of PWM signal.
@craighollinger9972
@craighollinger9972 5 жыл бұрын
Correct.
@HakAtIt
@HakAtIt 3 жыл бұрын
I was thinking the same. The filter would not have so much effect on the output voltage too.
@bloguetronica
@bloguetronica 6 жыл бұрын
The PWM "DAC" is potentially noisy. The R2R ladder is a proper DAC, and can be improved by using more bits and by implementing a reconstruction filter.
@acraigwest
@acraigwest 3 жыл бұрын
Have you done a test using a filter on the output of the R2R ladder? you should be able to tune it based on the time between samples, which is much more consistent than the overall frequency
@craighollinger9972
@craighollinger9972 3 жыл бұрын
That's the way it is normally done, put a filter on the output of the ladder. Make sure the sampling frequency is much higher than the output frequency, to limit the constraints on the filter.
@albandaumer3441
@albandaumer3441 3 жыл бұрын
I'm working on a music project, would you say that the limitation you showed for the pwm would affect the audio frequencies, or is it only a problem for higher frequencies ? the osciloscope you shoed at 3:37 is around 3Khz Or maybe we can add some kind of auto-gain amplifier (or a filter that let through the band of higher frequencies + an amplifier) to the end of the pwm filter for that purpose ?
@craighollinger9972
@craighollinger9972 3 жыл бұрын
It's been a while since I made this video so I don't remember the setup. But looking at first principals, the Nyquist theorem says that you must sample at 2X the maximum desired frequency to reproduce a signal. An this is a minimum. CD quality audio is sampled at 44kHz, so you would need to do this as well. I'm not sure if my setup would work at this high of a frequency, the ATMEGA328 isn't a very powerful processor. Simply amplifying higher frequencies wouldn't do anything. You still have to satisfy the Nyquist theorem. There are electronics that are purpose built for this. Just do a search on the internet and you should find what you need. I hope this helps and thanks for watching.
@hamidreza6921
@hamidreza6921 8 жыл бұрын
thank you for sharing :) can the wave width decreasing be solved by an amplifier or something? i mean without losing resolution. and would you mind to record a similar video about amplification?
@drivera0502
@drivera0502 3 жыл бұрын
I combined an Arduino Uno with a shift register and R2R ladder to get 8-bits which I buffered using an MCP602 op-amp. With port manipulation, I was able to output a new value at ~290 KS/s by looping with a variable incrementing by 1. I was able to print audio files at about 11 kS/s from Matlab where the limiting rate was the serial port baudrate. I'm sure if I had a microSD card, the output rate would be significantly higher. If multiple shift registers shared pins, I would only need one additional pin per DAC, but I also know my "max" output speed would also drop by a third to half the current
@craighollinger9972
@craighollinger9972 3 жыл бұрын
Good luck with your experiments. There is an 8-bit port on the UNO, Port D. You won't be able to use the serial monitor but you will get an 8-bit wide R2R ladder DAC. That should increase your speed instead of going through a shift register.
@drivera0502
@drivera0502 3 жыл бұрын
@@craighollinger9972 thanks! I saw you mentioned that in your video, but most of the projects I'm working on need to keep the arduino serial port available for communication with a computer, and additional pins are needed for controlling the on/off states of some other equipment, so I moved to the shift register to reduce the pins required for the DAQ. It's definitely not as fast as setting a single port (or running port commands to manipulate the last 6 pins of 1 and the first 2 of the next with a LP filter to reduce the jitter of the pins switching asynchronously)
@drivera0502
@drivera0502 3 жыл бұрын
It may also be worth it for me to look into getting a DAC breakout module now that I think of it
@uni-byte
@uni-byte Жыл бұрын
You could do a full 8-bits using just 3 pins with a 74HC595.
@craighollinger9972
@craighollinger9972 Жыл бұрын
Could do that, might make the frequency lower though.
@uni-byte
@uni-byte Жыл бұрын
@@craighollinger9972 Should be able to get pretty close to the full audio range I think. It's doesn't take too long to shift out 8 bits.
@manny9639
@manny9639 6 жыл бұрын
Thank you, excellent comparison!!!
@aysinarseven7570
@aysinarseven7570 6 жыл бұрын
I cant find the source code of the sine wave. could you add the code please? (web site does not open) also i want to add 2 sine wave with different frequencies in arduino. is this possible ? thank you..
@craighollinger9972
@craighollinger9972 6 жыл бұрын
I've corrected the link to the schematic on GitHub, it now works. If you go to another video in my series: kzbin.info/www/bejne/mHrVhYqfitCpkKM you can find the source code there. The code produces a DAQ output using both PWM and R2R Ladder. Thanks for watching!
@francoisdastardly4405
@francoisdastardly4405 6 жыл бұрын
Very clear explained. Thanks
@microcolonel
@microcolonel 5 жыл бұрын
I guess your frequency limitation on the pwm is the main issue here. Presumably each doubling of modulation frequency gives you a bit of precision or nearly twice the bandwidth for filter of the same complexity.
@craighollinger9972
@craighollinger9972 5 жыл бұрын
Yeah, the ATMEGA328 is not a very powerful micro. Some of the higher end ARM chips running at 200+MHz would to better. But using a microcontroller to generate signals, while a good exercise, is just not very practical. Analog Devices has a lot of dedicated chips to do this. Pricey though. Thanks for watching.
@Brant_Channel
@Brant_Channel 7 жыл бұрын
Thanks for that explanation.
@craighollinger9972
@craighollinger9972 7 жыл бұрын
Thanks for watching!
@knighttime19
@knighttime19 7 жыл бұрын
Nice tutorial. There is anyway that output voltage can be adjusted to be suitable for Mic in jack of smartphone. Thanks
@craighollinger9972
@craighollinger9972 7 жыл бұрын
The maximum voltage is fixed by the logic voltage level (5V) of the microcontroller. An amplifier or an attenuator would have to be added to the output of the ladder to set the voltage level for the smartphone.
@knighttime19
@knighttime19 7 жыл бұрын
Thanks!!
@noweare1
@noweare1 6 жыл бұрын
Nicely presented, thanks
@مقاطعمترجمة-ش8ث
@مقاطعمترجمة-ش8ث 5 жыл бұрын
Great video very Great thanks .
@craighollinger9972
@craighollinger9972 5 жыл бұрын
You are welcome. Thanks for watching!
@LostDeadSoul
@LostDeadSoul 5 жыл бұрын
According to the datasheet of the Atmega 2560 it has only one 6-bit GPIO PORTG. The rest are 8-bit GPIOs
@andrewferg8737
@andrewferg8737 4 жыл бұрын
Great video! I made this version out of discrete components: kzbin.info/www/bejne/oKuYn6iKqrtmfM0 however, I not sure if I should R2R the final output where it connects to 4 NPN drivers.... any thoughts?
@craighollinger9972
@craighollinger9972 4 жыл бұрын
I'm not sure what you have done, but it looks like a good result. Don't over complicate things.
@andrewferg8737
@andrewferg8737 4 жыл бұрын
@@craighollinger9972 Thanks again for your tutorial! I changed my binary ladder to an R2R and it seems much more stable and efficient. kzbin.info/www/bejne/bJPapXSVmchpgKM
Going Beyond Arduino # 11: Using the UART Serial Port (part1)
26:56
Craig Hollinger
Рет қаралды 7 М.
Making a 12 bit DAC Using an Arduino - The Learning Circuit
7:51
element14 presents
Рет қаралды 46 М.
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 10 МЛН
Симбу закрыли дома?! 🔒 #симба #симбочка #арти
00:41
Симбочка Пимпочка
Рет қаралды 5 МЛН
Can You Find Hulk's True Love? Real vs Fake Girlfriend Challenge | Roblox 3D
00:24
Going Beyond Arduino # 8: PWM as a Digital to Analog Converter
14:40
Craig Hollinger
Рет қаралды 37 М.
DAC Methods R2R Ladder
8:58
Columbia Gorge Community College
Рет қаралды 159 М.
Digital to Analog Converter using PWM
10:57
bitluni
Рет қаралды 115 М.
PWM DAC - Ripple Cancelation
12:31
All Electronics Channel
Рет қаралды 2,8 М.
DAC using R-2R resistor ladder
22:38
bitluni
Рет қаралды 111 М.
R-2R Ladder DAC Explained (with Solved Example)
18:21
ALL ABOUT ELECTRONICS
Рет қаралды 470 М.
Arduino Basics  Digital to Analog Conversion
9:07
learnelectronics
Рет қаралды 15 М.
Such a gadget should be at hand.
0:17
Super Craft
Рет қаралды 3,5 МЛН
Что делать если разрядился iPad
0:53
Mikha Zen
Рет қаралды 117 М.
Fake Samsung Galaxy S25 Ultra Plus на iOS
0:59
Wylsacom
Рет қаралды 190 М.