Pages: [1]   Go Down
Author Topic: What can't you do with PWM compared to DAC  (Read 1368 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi.

I am learning Arduino. I have read the analogWrite actually uses a digital signal, via the PWM technique.

I also read that is good enough for dimming LED's, controlling motors, generating audio...a lot of things, after all.

My question is, what are the main things you can't achieve with PWM, but you definitely need DAC instead? I am asking in general, but also particularly in the Arduino/microcontrollers arena.

Thanks,
Dan
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27113
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

With PWM, you have an oscillating signal that you filter with a low pass filter to smooth into a ripply level.
With a DAC, you are basically writing the level you want and it stays there until you write again.
You can have dual and quad DACs with higher resolution than the 8 bits offered with PWM, easily accessed with fast I2C or even faster SPI commands.
Its also possible to create more complex waveforms if desired, such as playback of sampled files from memory.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Very interesting, CrossRoads - thanks a lot.

Is the "low pass filter" you were talking about integrated into the microcontroller or is it something I should take care of?

Dan
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27113
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

low pass filter is external, just a resistor/capacitor.

there are lots of calculator websites, for example
http://www.electronics-tutorials.ws/filter/filter_2.html

PWM switches ~490 Hz, so pick values to filter out frequencies above that.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 146
Posts: 5517
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My question is, what are the main things you can't achieve with PWM, but you definitely need DAC instead? I am asking in general, but also particularly in the Arduino/microcontrollers arena.

In general? Not much.

In Arduino terms? Quite a lot. Arduino has quite a limited PWM frequency/resolution. eg. You can't do high quality audio output.

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
My question is, what are the main things you can't achieve with PWM, but you definitely need DAC instead? I am asking in general, but also particularly in the Arduino/microcontrollers arena.

To generate low frequency analog output; to generate fine analog output; to generate fast analog output; etc.
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The flip of the coin is also true: there are cases where pwm is much preferred over dac.

Both are very application specific.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17294
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
My question is, what are the main things you can't achieve with PWM, but you definitely need DAC instead? I am asking in general, but also particularly in the Arduino/microcontrollers arena.

Well I pose a question to your. If one wires a PWM signal to a digital voltmeter what would it read at 50% output? If you have a DAC that outputs 0-+5vdc what will the same voltmeter display with a 50% signal?
There lies the difference and should point to applications best suited for one or the other.

Lefty
« Last Edit: November 16, 2012, 12:59:56 pm by retrolefty » Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 146
Posts: 5517
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
My question is, what are the main things you can't achieve with PWM, but you definitely need DAC instead? I am asking in general, but also particularly in the Arduino/microcontrollers arena.

To generate low frequency analog output; to generate fine analog output; to generate fast analog output; etc.


I guess all those "1-bit-DAC" CD players are a figment of my imagination....
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27113
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

From wikipedia:
"A Bitstream or 1-bit DAC is a consumer electronics marketing term describing an oversampling digital-to-analog converter (DAC) with an actual 1-bit DAC (that is, a simple "on/off" switch) in a delta-sigma loop operating at multiples of the sampling frequency. The combination is equivalent to a DAC with a larger number of bits (usually 16-20). The advantages of this type of converter are high linearity combined with low cost, owed to the fact that most of the processing takes place in the digital domain and requirements for the analog anti-aliasing filter after the output can be relaxed. For these reasons, this design is very popular in digital consumer electronics (CD/DVD players, set-top boxes and the like)."

So not sure what you are trying to point out fungus.

Found another good description here
http://electronics.howstuffworks.com/question620.htm
« Last Edit: November 16, 2012, 01:22:54 pm by CrossRoads » Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 146
Posts: 5517
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So not sure what you are trying to point out fungus.

1-bit-DAC is an example of using PWM to generate analog signals in consumer electronics.

It does all that stuff he claims can't be done ("low frequency analog output; fine analog output; fast analog output; etc").

It may not be practical for all applications but in theory PWM+filter can do anything an DAC can do.

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Show Your Work
Offline Offline
Edison Member
*
Karma: 14
Posts: 1098
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It does all that stuff he claims can't be done ("low frequency analog output; fine analog output; fast analog output; etc").

Damn, how does TI get away with selling their expensive DACs then? smiley

http://www.ti.com/docs/prod/folders/print/dac5670.html
Logged

I have only come here seeking knowledge. Things they would not teach me of in college.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27113
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Gotta take the guy mentality for that one:
more bits/seconds
more power
more balls!

Gues it helps to have a higher power uP also to send it data that fast.

Features

14-Bit Resolution
2.4-GSPS Maximum Update Rate Digital to Analog Converter

Power Dissipation: 2 W
252-Ball GDJ Package

APPLICATIONS
Satellite Communications
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 146
Posts: 5517
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Damn, how does TI get away with selling their expensive DACs then? smiley

http://www.ti.com/docs/prod/folders/print/dac5670.html

When I say "in theory" it means there's practical limits...

eg. 1.2Gsps output with 14-bit resolution would need a 20 terahertz PWM clock  smiley-cool

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Show Your Work
Offline Offline
Edison Member
*
Karma: 14
Posts: 1098
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Guess it helps to have a higher power uP also to send it data that fast.

I think we would be well into (multiple?) CPLD/FPGA territory on that DAC.   Certainly a (relatively) slow but smart uP to direct all the action of the heavy equipment.
« Last Edit: November 16, 2012, 03:19:42 pm by JoeN » Logged

I have only come here seeking knowledge. Things they would not teach me of in college.

Pages: [1]   Go Up
Jump to: